Debugging GPU operation

Question: I have a profile on VTune and it shows something running on the GPU (the line highlighted with the pale blue dot in the attached screenshot). How can I debug what in my codebase is running on there?
To clarify: when that highlighted line is expanded, it's the nvoglv64.dll process eating up all that time, which is the driver for the GPU I believe.
Comment: Where do you see "GPU" in this image?
Comment: I will edit my post to clarify, but when you expand that highlighted line, it's the `nvoglv64` DLL, which is the driver for the GPU I believe.
Comment: On the left, there is the callstack. It seems that extract_pos_etc is the calling function. You can break at extract_pos_etc and examine the stack, variables, etc.
Comment: That highlight was me, sorry, but I think you're right, after some research it _does_ look to at least be partially responsible.
Answer: nvoglv64. dll is a file that is associated with the Nvidia based video card drivers which is the software driver for NVIDIA Graphics GPU installed on the PC. All GPU analyses using VTune Profiler are supported on Intel® processors with 9th generation of Intel HD or Iris Graphics (formerly Skylake) or newer.
In order to see the source code : Under the call stack grouping in bottom up tab , click on the line that uses the gpu driver . On the right side of the GUI , you will be able to see the related source code. As already mentioned by @soleil in the comments, it seems that extract_pos_nor_iter_poly_mesh is the calling function. When you click on that , the source code will open up and can examine the stack and variables.
Please note that in order to view the full-scale statistics on call stacks, source data, function names, etc. on Intel® VTune™ Profiler, it requires debug information for the binary files. Refer the below link for more details :
https://software.intel.com/content/www/us/en/develop/documentation/vtune-help/top/set-up-analysis-target/linux-targets/debug-info-for-linux-binaries.html

Debugging GPU operation


OpenCV undefined reference to cv::SURF::SURF() eclipse

Question: I am trying to stitch images in android like panorama view.I am trying to use surf descriptor for stitching images.I am using 2.4.0 version of openCv because upper version doesn't contain nonfree folder for surf descriptor.I have also included
<code> #include "opencv2/nonfree/features2d.hpp"
 #include "opencv2/nonfree/nonfree.hpp"
</code>
in header and also given the path  ..\jni\include and ..\native\libs\armeabi-v7a in GNU path which contains all .a  files.Below is my code which i have taken from the OpenCV example
<code> #include <stdio.h>
 #include <iostream>
 #include "opencv2/core/core.hpp"
 #include "opencv2/features2d/features2d.hpp"
 #include "opencv2/highgui/highgui.hpp"
 #include "opencv2/calib3d/calib3d.hpp"
 #include "opencv2/nonfree/features2d.hpp"
 #include "opencv2/nonfree/nonfree.hpp"

 using namespace std;
 using namespace cv;

void readme();

 int main( int argc, char** argv )
{
 if( argc != 3 )
 {
  readme(); return -1;
 }

 Mat img_object = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
 Mat img_scene = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );

 if( !img_object.data || !img_scene.data )
 { std::cout<< " --(!) Error reading images " << std::endl; return -1; }

 //-- Step 1: Detect the keypoints using SURF Detector
 int minHessian = 400;

 SurfFeatureDetector detector(400); //error:undefined reference to cv::SURF::SURF(double, int, int, bool, bool)

 std::vector<KeyPoint> keypoints_object, keypoints_scene;

 detector.detect( img_object, keypoints_object );
 detector.detect( img_scene, keypoints_scene );

//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor; //error:undefined reference to cv::SURF::SURF()

Mat descriptors_object, descriptors_scene;

extractor.compute( img_object, keypoints_object, descriptors_object );
extractor.compute( img_scene, keypoints_scene, descriptors_scene );

//-- Step 3: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_object, descriptors_scene, matches );

double max_dist = 0; double min_dist = 100;

//-- Quick calculation of max and min distances between keypoints

for( int i = 0; i < descriptors_object.rows; i++ )
{ double dist = matches[i].distance;
 if( dist < min_dist ) min_dist = dist;
  if( dist > max_dist ) max_dist = dist;}

printf("-- Max dist : %f \n", max_dist );
printf("-- Min dist : %f \n", min_dist );

 //-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
 std::vector< DMatch > good_matches;

 for( int i = 0; i < descriptors_object.rows; i++ )
 { if( matches[i].distance < 3*min_dist )
  { good_matches.push_back( matches[i]); }
  }

 Mat img_matches;
 drawMatches( img_object, keypoints_object, img_scene, keypoints_scene,
           good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
           vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );

  //-- Localize the object from img_1 in img_2
  std::vector<Point2f> obj;
  std::vector<Point2f> scene;

  for( size_t i = 0; i < good_matches.size(); i++ )
  {
  //-- Get the keypoints from the good matches
   obj.push_back( keypoints_object[ good_matches[i].queryIdx ].pt );
   scene.push_back( keypoints_scene[ good_matches[i].trainIdx ].pt );
  }

 Mat H = findHomography( obj, scene, CV_RANSAC );

 //-- Get the corners from the image_1 ( the object to be "detected" )
  std::vector<Point2f> obj_corners(4);
  obj_corners[0] = cvPoint(0,0); obj_corners[1] = cvPoint( img_object.cols, 0 );
  obj_corners[2] = cvPoint( img_object.cols, img_object.rows ); obj_corners[3] = cvPoint( 0, img_object.rows );
  std::vector<Point2f> scene_corners(4);

  perspectiveTransform( obj_corners, scene_corners, H);

 //-- Draw lines between the corners (the mapped object in the scene - image_2 )
 Point2f offset( (float)img_object.cols, 0);
 line( img_matches, scene_corners[0] + offset, scene_corners[1] + offset, Scalar(0, 255, 0), 4 );
 line( img_matches, scene_corners[1] + offset, scene_corners[2] + offset, Scalar( 0, 255, 0), 4 );
 line( img_matches, scene_corners[2] + offset, scene_corners[3] + offset, Scalar( 0, 255, 0), 4 );
 line( img_matches, scene_corners[3] + offset, scene_corners[0] + offset, Scalar( 0, 255, 0), 4 );

 //-- Show detected matches
 imshow( "Good Matches & Object detection", img_matches );

 waitKey(0);

 return 0;}

 /**
 * @function readme
 */
void readme()
{ std::cout << " Usage: ./SURF_Homography <img1> <img2>" << std::endl; }
</code>
I got the error where SurfFeatureDetector and SurfDescriptorExtractor declared.I have written error in comment.Anybody have any idea regarding this then please suggest.I am really stuck to this problem.:(  Thanks in advance.
Answer: I know I'm late but if anyone has the same problem , this worked for me.
Select your project in the Project Explorer. Then go to Project/Properties. Click on the arrow on the left of the "C/C++ Build" option to show its sublist. Now click on the "Settings" option. It will show on your right hand the Settings panel. In this panel click the "Tool Settings" tab. On the left side of the Settings panel you will see another options list. Click on the  "GCC C++ Linker" arrow to show/hide its sublist. In this sublist click on "Libraries" and the panel will show your linked libraries (Libraries(-l)) and your library search paths (Library search path (-L)). Click on the button representing a document with a plus sign on the right upper corner of (Libraries(-l)) and write opencv_nonfree . Click the OK button and then OK again in the Settings panel. Good luck!


Visual studio not running program because it needs v120 tools

Question: I made a simple C++ paint program in Visual Studio 2013. The program worked and ran in VS 2013. I moved the program to a new computer and ran it. This computer has visual studio 2015, so when I tried to run it, it said I needed v120 build tools. Can someone explain how to install these tools?
Answer: You need to change the project settings to use toolset v120
Go here and scroll down to where it says "To change the project toolset".
Comment: I did this but int the solution propertey page there is no category named general.  Is this because I have the community version.  how can I get this to work.  Thanks
Answer: Each release of Visual Studio ships with its own set of compilers, tools, etc.  Visual Studio 2015 is also known as Visual Studio version 14.0 and uses (by default) the v140 Platform Toolset.  Visual Studio 2013 is also known as Visual Studio version 12.0 and uses the v120 Platform Toolset.
Since your C++ project was originally created by Visual Studio 2013 it is configured to use the v120 Platform Toolset.  When you opened that project with Visual Studio 2015 you probably were offered a chance to upgrade the project to the v140 Platform Toolset.  It sounds like you declined that option since your build is still asking for the v120 build tools.
One option would be to go into the C++ Project Properties General Tab (not the Solution Properties) and change the Platform Toolset to Visual Studio 2015 (v140).  That tab does exist in the Community Edition.
If you do that you'll be building with the Visual Studio 2015 compilers and tools instead of the Visual Studio 2013 compilers and tools used on your old computer.  That does mean there's a chance that you'll encounter a C++ Breaking Change.  Probably a small chance but that would depend on how your program is written and the features it uses.
It also means the program built on your new computer will be different from the program built on your old computer since the two builds will be using different versions of the compilers and tools.
If you absolutely want/need compatibility between your two computers then you'll need to leave the Platform Toolset at Visual Studio 2013 (v120) which brings us back to the question you originally asked.
One way to get the v120 tools would be to install Visual Studio 2013 on your new computer.  But I'd be reluctant to do that.  I'm sure Microsoft have tested installing Visual Studio 2015 on top of Visual Studio 2013.  I'm not so sure they'll have tested the other way around (although they are very thorough).
Update
To install the v120 Platform Toolset on a system with Visual Studio Community 2015 installed, run setup from Programs and Features and then check the "Tools and Windows SDKs" box under "Windows 8.1 and Windows Phone 8.0/8.1 Tools".


Solving Error when instantiating an object of a compiled class in JSP page

Question: Please I need your Help all Java gurus in the forum, i have a problem with a jar file am importing to my jsp file when i define an object of the imported class PassBuilder.java (which is a class in the passhide jar file imported)as "PassBuider passer;" i get no error but once i instantiate the class object i get a "page cannot be displayed error". Please what can i do to solve this????Below is a sample of the code:
<code><%@ page import= "passhide.*"%>

<%
String userID = "owo123";
PassBuilder passer;//no error
passer = new PassBuiler().getPass(userID);//throws page cannot be displayed
%>
</code>
Answer: Yeah I later found the solution to this, the cause was actually me running a jar file compiled with jdk 1.7 on a jdk 1.6 environment. so I simply had to recompile with a jdk 1.6, and holla the error was gone.


Screen sharing only working when monitor connected

Question: Using Ubuntu 19.04, I can only use the built-in screen sharing (vino) when a monitor is connected. I can successfully connect even without a monitor connected, but the screen isn't updated (ie I see the screen as it was the moment I disconnected the monitor.
How do I solve this?
Comment: Isn't vino just a screen sharing program? If you want remote access without a monitor being attached don't you need a different program like SSH (secure Shell)
Comment: I have ssh working, I'd like screen sharing as well
Comment: Wil this link help - adding a fake display? https://askubuntu.com/questions/453109/add-fake-display-when-no-monitor-is-plugged-in
Comment: Nope, it breaks X completely. Also it's not exactly the same issue - I actually can connect to vino, the screen just isn't updated.
Answer: It doesn't feel like the most elegant solution but this issue was solved for me by one of those HDMI dummy plugs which emulates a connected screen. They can be picked up for about $10.
I've found the wide range of resolutions they spoof to be handy.


How does KSP simulate objects out of focus?

Question: I've attempted to perform a controlled aerobraking maneuver against Kerbin upper atmosphere (>55km) when returning from a moon and decided to speed things up with fast-forwarding from the Tracking Station. And when I had my ship circle a few rotations in the 'aerobraking' orbit, I observed that the orbit did not change, despite it should've done so.
I figure that the game does not simulate objects far from player focus properly. Is there a description what and how far from player goes out of proper simulation? A few suspected examples that I've come up with:

Eccentric sub-atmospheric orbits
Objects on collision course with one another (interaction/destruction/passing through)
Science stations in orbit and on land of distant bodies (science generation/energy consumption)

My KSP is the most latest current version - 1.0.4
Answer: KSP models the physics of all craft that are within 2.25km (thereabouts) of the currently active craft.
That means that if you fastforward from the tracking station, NO craft are getting physics calculations.
What happens to craft who get no physics calculations? They are calculated on rails. Meaning their orbit is assumed to be fixed, much like how the planetary orbits always work.
On rails calculation makes two exceptions:

Suborbital trajectories (things falling to the ground) will destroy the object correctly.
Orbits with a periapsis below an arbitrary "atmospheric height" will be assumed to aerobrake enough to become a suborbital trajectory and be destroyed.

My guess in your case would be that the 55,000m altitude you're at now is still higher than Kerbin's "atmospheric height" setting. Meaning there's not anough atmosphere for the on-rails system to assume your orbit is decaying.
Solution: Time warp while said vessel is your active vessel. Then proper physics will be calculated.
Edit
I can't say for sure, but my guess would put Kerbin's atmospheric height at 30 or 40km, given how that's where aerobraking is enough to kill most orbits in a single "dip" into the atmosphere.
Edit 2
As commented by CyanAngel, the deletion of a craft (when outside of physics) occurs when a craft gets below 23km altitude on Kerbin.
Comment: Kerbin's atmosphere height is 68km. If you're after the vessel deletion threshold it's when they pass under 23km on Kerbin when outside of physics range. Otherwise spot on answer.
Comment: Thanks. This explains a lot. I suppose science labs won't consume electricity, but will make science? And maybe you could advise what will happen to on-collision course crafts?
Comment: Collisions are physics, which don't get modeled during on-rails. Picture on-rails as just an **unchanged** orbital path. I'm not sure about science lab generation, but I figure this is a time-driven gain, not a physics-driven one. I do believe power usage is modeled _somewhat_, as, I used to have RT2 and had satellites going down due to being eclipsed by a planet. That could've been RT2 specific, though.


Android: What is the Correct URL to use to when connecting Android to PHP using local host?

Question: I am unsure of what url to use for my application to connect to my WAMP server on local host.
Currently I am using:
<code> String link = "http://10.0.2.2/login.php?username="
</code>
Is this correct or is should it be something else?
e.g.:
<code>String link = "http://localhost/login.php?username="
</code>
Answer: None of them, first open cmd to find out your computer ip by command ip config and then go to firewall and enable port 80 listening and use that ip address.
look at this :
http://josephshaaia.wordpress.com/2012/12/22/connecting-android-device-to-a-database-on-mysql-wamp-server/
Comment: I am not 100% sure what you mean? How can I find the IP address? I also do not know how to enable port 80. Sorry this is my 1st experience with a server
Comment: look at the link if you are on windows, and you must take similare steps on other platform. you and the localhost must be on the same wifi network, and you must find your pc ip, ip config command on windows shows your ipv4 of your pc and other steps are described in the link...
Comment: Thanks, I was able to find the ipv4 but i was unable to change the http.conf file as I was unable to find the section to change? Please see this question where I am desicribed the problem: http://stackoverflow.com/questions/25105926/wamp-server-changing-httpd-conf-for-apache
Comment: go to firewall of windows and add rules to enable port 80 and thats it. now run your wamp server. in your app use ipv4 of your pc and enjoy !!
Comment: I have done the two steps you last mentioned thanks. However It doesnt seem to work as I cant change the http.conf file? I describe the problem here: http://stackoverflow.com/questions/25105926/wamp-server-changing-httpd-conf-for-apache


How do I set up cljsbuild to move non-compiled files into a specific folder?

Question: My Clojurescript project is starts with three files -- an index.html, a css file, the hand-written .cljs code.
When cljsbuild builds the .cljs file into a .js file, it puts it in an arbitrary location. I'd like to also move the index.html and css files there too.
The reason I want this is so I can have multiple profiles, and easily load both. I have a dev profile where the javascript isn't optimized, and a release profile that does optimize javascript. But switching between them is annoying -- I have to somehow take the single existing index.html file and change the javascript file it's pointing at. (If I have two index.html files, each pointing to a different javascript file, making a change to one html file means duplicating the change in the other)
I'd rather have two builds:
dev build builds to project/dev.
release build builds to project/release.
Both builds would have index.html, style.css, and compiled.js files. Is there any way to make this happen?
Answer: For doing that I think you are going to need additional tooling to your project.
Frontend tooling is a tough world with lots of alternatives and workflows each with their tradeoffs.
The simplest way would be having a makefile and invoke it when you want HTML and CSS copied/compiled. That should get you started but it is hard to get working on Windows.
For a established cross platform solution I'd look into integrating grunt to the workflow. With grunt you can easily have a file watcher copy/compile your HTML and CSS to your folders and even have the files minified/linted. The tradeoff is a steeper learning curve and initial setup of the project.
There are lots of options but not any cljs specific tooling that I know of.
Comment: Thanks for the input. This situation is what is, but is suboptimal -- with `lein cljsbuild auto`, I don't have to stop to run a build; it's a shame I have to add extra tooling or have an entirely different workflow for release builds.
Comment: What you would have to do is have two tools watching (cljsbuild looking at .cljs files and (make/grunt/...) looking at html/css/less/js files). If you just want something to be executed when cljsbuild recompiles, then you can use `:notify-command` for that (but that wont make cljsbuild file-watch html and css files, it may be enough, tough). Here is a link to the example conf: https://github.com/emezeske/lein-cljsbuild/blob/70a0d85782182a09c1116049b09a5f8ca5a7bd30/sample.project.clj#L73-L78


How can I muffle a loud doorbell?

Question: I live in an apartment, in which the doorbell emits an unreasonably loud tone (kind of square-wave-y) continuously and at constant volume for as long as someone has the button depressed. Since people buzzing me from the complex's front door have no feedback that the bell is actually working, they tend to press it multiple times and for a long time; this gets to be very annoying.
I would like to figure out a way to dampen the bell's sound. Since I do not own the property, I cannot replace or alter the bell in any way, so I'm looking for non-invasive ways of quieting it down. I'm not really concerned about aesthetics; if I need to make the thing look like a Lovecraftian horror to quiet it down, so be it.
My first instinct is to purchase some acoustic foam (like this) and tape it over the speaker; does that seem like the kind of thing that would work?
Here is a photograph of the thing for reference:
Comment: A Cthulu plushie somewhat larger than the speaker panel hung over it - you could lift to speak and hear clearly once the visitor lets off the bell button. Might as well have a tasteful and functional Lovecraftian horror... If less ambitious, a Cthulu potholder would probably do just as well for function.
Comment: Even painter's tape becomes permanent after months in place - I'm still trying to scrape it off a baseboard that I forgot to untape after repainting last year.
Comment: It's likely that you don't even need special acoustic foam - plain old duct tape will dampen the sound considerably. Try it just over the speaker area first, then across the whole louvered front piece if that's not enough dampening. I know you said you don't care about aesthetics, but you might try taking out those two screws and see if you can put the tape on the inside of the plastic faceplate. The drawback is that dampening the speaker also dampens your voice and the visitor's voice when you try to talk to them.
Comment: @Johnny, I wouldn't recommend duct tape since it has a habit of leaving sticky gunk when it's been left on too long.  But I agree, a layer of tape will probably do the trick.  Just stick with masking or painters tape.
Answer: You can get some wide white gaffer tape and cover the speaker grille. If you did it neatly, you would barely be able to tell it is there. Gaffer tape looks similar to duct tape, but it sticks better and leaves much less sticky residue when it is removed. That way your modification would be completely reversible.
Answer: It's always debatable what exactly you can alter and can't.  A lot of times, as long as the process is reversible, the landlord can't stop you.  Plus you can always ask for permission.
If you wanted to reduce the volume electronically, you could place a resistor in parallel to the speaker.  A resistor of the same impedance of the speaker (usually 6 or 8 ohms) would cut in half the power (not volume) to the speaker.
You need a resistor large enough to handle the power of the speaker, a few watts probably - a standard 1/2 or 1/4 watt resistor isn't likely going to do it.  And you might need to play around with resistor values to get the ideal volume level.
Answer: Drive to your local craft store and pick up some felt and hot glue. You can glue a few pieces of felt over the cover, and it will dampen the sound so it is not as shrill or loud, and it may even look nicer than foam!

How can I muffle a loud doorbell?


/etc/acpi/powerbtn.sh for full shutdown menu?

Question: I'm having the same problem as How to prevent the Power button to shutdown directly the system? and Ubuntu 13.10 with Cinnamon Desktop Environment
This answer seems to be the way to go, but I don't know what the command is.
My /etc/acpi/events/powerbtn calls /etc/acpi/powerbtn.sh which probably looks like everyone else's:
#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

[ -r /usr/share/acpi-support/power-funcs ] && . /usr/share/acpi-support/power-funcs

# getXuser gets the X user belonging to the display in $displaynum.
# If you want the foreground X user, use getXconsole!
getXuser() {
        user=`pinky -fw | awk '{ if ($2 == ":'$displaynum'" || $(NF) == ":'$displaynum'" ) { print $1; exit; } }'`
        if [ x"$user" = x"" ]; then
                startx=`pgrep -n startx`
                if [ x"$startx" != x"" ]; then
                        user=`ps -o user --no-headers $startx`
                fi
        fi
        if [ x"$user" != x"" ]; then
                userhome=`getent passwd $user | cut -d: -f6`
                export XAUTHORITY=$userhome/.Xauthority
        else
                export XAUTHORITY=""
        fi
        export XUSER=$user
}

# Skip if we just in the middle of resuming.
test -f /var/lock/acpisleep && exit 0

# If the current X console user is running a power management daemon that
# handles suspend/resume requests, let them handle policy This is effectively
# the same as 'acpi-support's '/usr/share/acpi-support/policy-funcs' file.

[ -r /usr/share/acpi-support/power-funcs ] && getXconsole
PMS="gnome-settings-daemon kpowersave xfce4-power-manager"
PMS="$PMS guidance-power-manager.py dalston-power-applet"
PMS="$PMS mate-settings-daemon"

if pidof x $PMS > /dev/null; then
        exit
elif test "$XUSER" != "" && pidof dcopserver > /dev/null && test -x /usr/bin/dcop && /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon; then
        exit
elif test "$XUSER" != "" && test -x /usr/bin/qdbus; then
        kded4pid=$(pgrep -n -u $XUSER kded4)
        if test "$kded4pid" != ""; then
                dbusaddr=$(su - $XUSER -c "grep -z DBUS_SESSION_BUS_ADDRESS /proc/$kded4pid/environ")
                if test "$dbusaddr" != "" && su - $XUSER -c "export $dbusaddr; qdbus org.kde.kded" | grep -q powerdevil; then
                        exit
                fi
        fi
fi

# If all else failed, just initiate a plain shutdown.
/sbin/shutdown -h now "Power button pressed"

Mine seems to go to the last two lines every time, only shutting down:
# If all else failed, just initiate a plain shutdown.
/sbin/shutdown -h now "Power button pressed"

What script can bring up the logoff/shutdown/suspend menu like how it was in 13.04?
Answer: Found the command on the Linux Mint forums.
First, edit /etc/systemd/logind.conf as jeremija recommends.
Then, simply comment out that last line that shuts down and add
gnome-session-quit --power-off


Basic application of the Nullstellensatz to locus of hypersurfaces

Question: Let $k$ be an algebraically closed field. For $f \in k[x_1,...,x_n]$, write $V(f) \subset k^n$ for the hypersurface defined by $f=0$.
As an application of the NSS, I want to prove the following.
If $f$ is irreducible and $f$ does not divide $g$, then $V(f) \not\subset V(g)$.
My idea is to reason by contradiction and to suppose that $V(f) \subset V(g)$.
Now I consider the ideal generated by $f$. Since $f$ is irreducible, $(f)$ is prime and thus $(f) \neq k[x_1,...,x_n]$.
Since I supposed that $V(f) \subset V(g)$, the NSS (which I can apply since $k$ is algebraically closed) tells me that there exists $n \in \mathbb{N}$ such that $g^n \in (f)$. But this is a contradiction to the fact that $f$ does not divide $g$.
I am really unsure about my reasoning and my understanding of the NSS.
Any comments would be appreciated.
Answer: It seems reasonable to start with a contradiction, i.e., that $V(f)\subseteq V(g)$.  At this point, however, it may be better to observe that $I(V(f))\supseteq I(V(g))$.  You are essentially making such an observation, but the ideal $I(V(f))$ should be identified directly.
Now, the Nullstellensatz (and algebraic closure) comes in to show that $I(V(f))=\langle f\rangle$.  This requires the Nullstellensatz and algebraic closure since otherwise $V(f)$ might be empty, so $I(V(f))$ would be larger than $\langle f\rangle$.
Now, if $I(V(f))\supseteq I(V(g))$, then $g\in I(V(f))=\langle f\rangle$.  This, however, contradicts the fact that $f$ does not divide $g$.
Comment: @riri92 A follow-up question should be posed as a new question so that others also have a chance to answer.  To note: this new question is weaker than the original question as it doesn't require the Nullstellensatz or an algebraically closed field.
Comment: Thank you for your reply.
Comment: Dear Michael, I wondered if I could ask for some more help. I now want to deduce that if $g =$ const $\cdot \Pi f_i^{n_i}$, then the irreducible components of $V(g)$ are of the form $V(f_i)$. If I understand correctly, this follows from the counterpositive statement of what we showed above right?
Comment: makes sense, sorry !


Non-trivial values of error function $\operatorname{erf}(x)$?

Question: The so called error function $\operatorname{erf}(x)$ is defined as
$$\operatorname{erf}(x)=\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2}dt,$$
and it is well known that $\operatorname{erf}(\infty)=1$.
Are there any other known closed-form values of $\operatorname{erf}(x)$, except for $\operatorname{erf}(0)$ and $\operatorname{erf}(\pm\infty)$?
Comment: @QiaochuYuan: I believe I mean something like this: Does there exist any $x$ such that both $x$ and $\operatorname{erf}(x)$ can be expressed as values of some elementary function?
Comment: @Mårten: this is not what you want. Every real number is the value of some elementary function (namely the constant elementary function with value that real number). But see http://www-math.mit.edu/~tchow/closedform.pdf for another suggestion (with the definition in that paper I would be extremely surprised if the answer was yes, but I would also be extremely surprised if you could prove it).
Comment: Wolfram only knows additional "values" at erf($\pm i \infty$) (which are $\pm i\infty$), see http://functions.wolfram.com/GammaBetaErf/Erf/03/. It's not a proof of nonexistence but it's rather discouraging
Comment: What do you mean by "actual example"? In what sense is, say, $\pi$ a known number but $\int_0^1 e^{-t^2} \, dt$ an unknown number? After all, $\pi$ is just $4 \int_0^1 \sqrt{1 - t^2} \, dt$.
Comment: What do you mean by "known"?
Comment: @QiaochuYuan: I mean an actual example, as opposed to existence proofs (although that would also be interesting).
Comment: @robjohn There is another one. Kindly see my answer below.
Comment: Interesting question, but I've never seen anything other than those three.
Comment: @MårtenW: See [here](http://en.wikipedia.org/wiki/Error_function).
Comment: Values $z\infty,a i\pm \infty$ give closed forms. For example Wolfram Alpha [implies](https://www.wolframalpha.com/input?i=erf%28%281-+i%29+*9%5E9%29) $\text{erf}((1-i)\infty)=1$ and states $\text{erf}(i-\infty)=-1$
Comment: Let's name the mathematical problem: We want to see where the values and the arguments of the error function both are [elementary numbers](https://en.wikipedia.org/wiki/Elementary_number) or [closed-form numbers](https://en.wikipedia.org/wiki/Closed-form_expression#Closed-form_number).
Answer: If the values aren't listed on the Wolfram function page, I would be surprised if you found them anywhere else. The only listed closed form values are for $0$, $\pm\infty$, and $\pm i\infty$. However, you can find various equivalent formulations, continued fractions, and the like on that page. A good reference, generally, for most well-known functions.
Answer: I'm 10 years late for this 2013 party, but better late than never. Yes, there is another closed-form value of $\operatorname{erf}(x)$. This is,
$$\operatorname{erf}\Big(\sqrt{\tfrac12}\Big)=1-\frac{\Gamma\big(\tfrac12,\tfrac12\big)}{\Gamma\big(\tfrac12\big)}=0.68268949\dots$$
the decimal expansion of which is https://oeis.org/A178647. This was found using a beautiful identity by Ramanujan (which I was coincidentally investigating),
$$\sqrt{\frac{\pi\,e}{2}}
=1+\frac{1}{1\cdot3}+\frac{1}{1\cdot3\cdot5}+\frac{1}{1\cdot3\cdot5\cdot7}+\dots\color{blue}+\,\cfrac1{1+\cfrac{1}{1+\cfrac{2}{1+\cfrac{3}{1+\ddots}}}}$$
Since $\Gamma\big(\tfrac12\big)=\sqrt{\pi}$ and the series and continued fraction have closed-forms, Ramanujan's identity can also be expressed in two ways,
\begin{align}
\Gamma\big(\tfrac12\big)\sqrt{\frac{e}{2}}
&= \,\sqrt{\frac{e}{2}} \times\,\Gamma\big(\tfrac12\big)\,\operatorname{erf}\Big(\sqrt{\tfrac 12}\Big) \;\color{blue}+\; \sqrt{\frac{e}{2}} \times\,\Gamma\big(\tfrac12\big)\left(1-\operatorname{erf}\Big(\sqrt{\tfrac 12}\Big)\right)\\
&= \sqrt{\frac{e}{2}}\times\Big(\Gamma\big(\tfrac12\big)-\Gamma\big(\tfrac12,\tfrac12\big)\Big) \color{blue}+\, \sqrt{\frac{e}{2}}\times\Big(\Gamma\big(\tfrac12,\tfrac12\big)\Big)
\end{align}
where the first way is in this post, and the second in this post. Equating the first addends,
$$\Gamma\big(\tfrac12\big)\,\operatorname{erf}\Big(\sqrt{\tfrac 12}\Big) = \Gamma\big(\tfrac12\big)-\Gamma\big(\tfrac12,\tfrac12\big)$$
one can then easily solve for $\operatorname{erf}(x)$.
Comment: This uses a more generalized function, $\Gamma(a,x)$, as a non-trivial value of the error function. One also may use $\text{erf}(x)=1-\frac{\Gamma(\frac12,x^2)}{\Gamma(\frac12)}$ to get a closed form for any positive value of the error function. Are you sure it cannot be "expressed as values of some elementary function" as said in a comment by the OP?
Comment: @ТymaGaidash I see. At least I found the relation via a rather unusual context. Regarding the OP's statement, I've been in fact trying to find expressions for $\Gamma\big(\tfrac12,\tfrac12\big)$ and $\Gamma\big(\tfrac13,\tfrac13\big)$ using other functions since they have nicer cfracs compared to others. Maybe the polygamma function?


Why don't my nodes in Fez have pictures on them?

Question: I play Fez on PC. When I get the ability to check the world map, all the nodes are blank, like no pictures. You can still make them gold, they just don't have any pictures. I don't know if this is a bug or not, because I can't find any articles about this.
Comment: Please try to limit yourself to one question per question. You can edit your question using the edit button below the tags. It's easier to search and answer that way. Thank you.
Comment: One post, one question. I've removed your extra question—please submit it as a separate question.
Answer: If you run the game on machine with Intel HD GPU, you may experience this bug. According to game changelog, it has been fixed in version 1.04.


Update the column I searched for

Question: is there any possibility to update a column-value in cassandra that I searched for (is part of my primary key)?
I have a (huge) list of items with a field calld "LastUpdateDateTime" and from time to time I search for columns that haven't updated for a while.
So, the reason i searched for this columns is cause I want to update them and after I update them I want to set the timestamp to the current date.
How to do this with cassandra?
Answer: You can't update primary key column, It will insert another record.
That's how cassandra work.
May be you will have to use spark-cassandra connector OR Delete the records with old values and insert new values.
Note: Deleting and inserting is not recommended if you have many records as it will create corresponding number of tombstones
Comment: Hmm okay, what about a secondary index ?

Update the column I searched for


How do I break into houses in GTA V?

Question: Can one break into a house in GTA V?
There's a mission in which Franklin breaks into Michael's house so I was wondering if this activity is an option outside of missions in GTA V.
Comment: Such a missed occasion to name your question "How to break into a house"
Answer: You cant. The only break in jobs are during heists or single player and even then there's not the opportunity to pick and choose which building you break in to.
Answer: This is just a specific mission. Kind of in the same way that there is a mission to chase down Michael's boat with Franklin (just an example), you won't be doing that activity again. Unless a mission happened to call for that.
Comment: I should add that I haven't owned the game in about a year and this could have been patched in since, but I asked a friend who still owns it and he said there is no such activity.

How do I break into houses in GTA V?


New user, new computer: system asked a password to uptade

Question: I'm a new user, recently bought a new machine with Ubuntu.
It's my first time with this OS.
The first task I tried to do was update the system.
I was asked about a password, but I don't know any.
The first doubt is: how to set the first password?
The second: which tutorial do you recoomend for start learning ubuntu?
Thanks a lot.
Comment: I would prefer you re-installed ubuntu 14.04LTS on that machine and start on a clean slate.The best tutorial to start ubuntu withis the [manual](http://ubuntu-manual.org/) download the pdf file and you are good to start.
Comment: @Hugo: if it was a pre-installed Ubuntu you should ask the manufacturer for the administrator password. [Here is reasons](http://askubuntu.com/a/381883/3940) why it may be better to just re-install your own Ubuntu on that machine.
Comment: Have you tried entering your login password?
Comment: The system doesn't ask for a login password. It just ask for password when I tried to update the system. The login name is 'centrium' and I suppose it was set by the manufacturer.
Comment: If there is no password for the user, please set one in the system settings.
Comment: Good idea, I'll try it and report here later. Some advice about a source for learning the basics of Ubuntu?
Comment: Please only ask one question per post. If you have another question, please ask it in another post using the *Ask Question* button at the top. Why not simply look at https://help.ubuntu.com/.
Answer: Welcome to Ubuntu World.How did you login to your system?
If your User Account is previously set to login without password you may try this.

Open up Terminal and type in passwd.
Enter a new password (For a strong password make sure it has capitals, more than 8 characters and numbers) and press enter.
Retype your new password and press enter.
Comment: Prompt will ask for current password, which op doesn't know. Won't do
Answer: Go to System > Preferences > keyboard shortcuts
run a terminal: Ctrl+Alt+t and type:
 passwd user

.. enter new password for user

If no luck You can refer the link From the official Ubuntu Lost Password documentation:

Reboot your computer.
Hold Shift during boot to start GRUB menu.
Highlight your image and press E to edit.
Find the line starting with
"linux" and append rw init=/bin/bash at the end of that line.
Press
Ctrl + X to boot. Type in passwd username.
Set your password.

Please refer the Tutorial links:

https://help.ubuntu.com/community/GraphicalInstall and https://askubuntu.com/
Comment: @DnrDevil `passwd user` does not set the password for root.


call script after element is fully visible

Question: I'm using this script below for loading a hidden div, inside another:
$(document).ready(function(){
    $(function() {
        $('#menu a').click(function(e) {
            e.preventDefault();
            $('#menu a').removeClass("selected");
            $(this).addClass("selected");
            var h = $(this).attr('href');
            $("#conteudo").fadeOut("slow", function() {
                $(this).html($(h).html()).fadeIn("slow");
            });
        });
 });

But in some pages, I use some mCustomScrollbar, which only works if the div is not hidden. So I need to call the script after the div is fully visible. How I can do that with the code above?
This is the scrollBar script call:
$("#mcs_container").mCustomScrollbar("vertical",400,"easeOutCirc",1.05,"auto","yes","yes",10);

In the page of script, it has this example code, but my script load is valid for the entire menu ... and this example it is setting what page he wants to carry. Do I make myself clear?
$("#mcs_container .content").load("new.html", function(){
    $("#mcs_container").mCustomScrollbar("vertical",400,"easeOutCirc",1.05,"auto","yes","yes",10);
});

Answer: You can pass a callback function to the .fadeIn() function that will be executed once the animation has ended (making the
 visible). It should look something like this:
$("#conteudo").fadeOut("slow", function() {
    $(this).html($(h).html()).fadeIn("slow", function() {
        $("#mcs_container").mCustomScrollbar("vertical",400,"easeOutCirc",1.05,"auto","yes","yes",10);
    });
});

Comment: great! As I have not thought of that before? And if i want to call the Scrollbar only in some `div`, i can make a `if` condition... right?


How enable use GeForce MX150?

Question: I have notebook Xiaomi Mi Pro 15.6. The notebook has GeForce MX150 graphic adapter. I enable Nvidia driver in additional drives,

but when I go to Settings -> Details -> About I see:
Graphics: Intel® UHD Graphics 620 (Kabylake GT2)

How enable GeForce MX150 ?
Answer: Given than you installed the drivers using the additional drivers tab, you should have already installed Nvidia Settings. Look in there for the PRIME Profiles menu and use it to switch between the two cards as shown in the image:

Alternatively, you can open your terminal and write the command
prime-select query

to check which of the cards is your system using, and the commands
sudo prime-select nvidia

or
sudo prime-select intel

to change between the two cards and then restart the session.
Answer: Here is explained the right answer, i hope it helps you.
https://www.linuxbabe.com/ubuntu/install-nvidia-driver-ubuntu-18-04
Comment: Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it's there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.
Comment: It does not help me, after install driver I can see the same picture. Device uses internal graphic
Comment: What does `prime-select query` return?
I have the same NVidia graphics card, just got it working by selecting nvidia-driver-418
Answer: When it is about Nvidia, it is better to install the proprietary driver.
Here is a detailed answer:
To remove the installed Nvidia drivers, run:
sudo apt-get purge nvidia*
sudo apt remove nvidia-*
sudo apt autoremove

Then, check which is the recommended driver for your Nvidia card by running:
ubuntu-drivers devices

If you want to install the driver automatically, run :
sudo ubuntu-drivers autoinstall

If you want to install a specific driver, run:
sudo apt install nvidia-<driver number>

Once the installation is finished, run prime-select query to check which graphic card is being used by your device.
If you want to change the graphic card used by your PC, run : sudo prime-select <intel/ nvidia>; choose between Nvidia and Intel graphic cards.
After that, restart your PC to apply changes
Answer: I had the same issue on a HP Spectre x360 and I solved it by disabling secure boot in the BIOS.
Comment: Are you sure this is what fixed the problem?  The only reason I could see for that would be that the NVidia drivers could not be loaded due to code signing forced by secure boot.
I'm not saying you're wrong, just that I find it highly unlikely.

How enable use GeForce MX150?


Asking for ideas: Incorporating a Redux CRA App into express backend SSR App

Question: Hi I am new to React and have a general design question. I am developing an app that's kind of similar to scratch (scratch.mit.edu), with a highly interactive program that enables user to create a project, drag and drop and connect to play with modules. And also it should has a multiple pages dashboard for user login, profile, home, and also open up a project and go to the interactive program to edit.
Currently our progress are quite separated: the 'playable' program is build by create-react-app and has redux to control the state; and the multiple pages dashboard is build on express server with server side rendering.
Now I need to incorporate the two parts and asking for some suggestions: Is it a good idea to switch the CRA project to ssr and route it in the express project? Does that create issues with Redux? Or is it better to just keep them seperated and they will be running on two different servers?
Answer: This is a common scenario and generally can be solved by one of three ways.

Use separates servers
Use a proxy
Have express server run dynamic routes and use express.static for pre-built React bundle

The third option is usually the easiest, say if you are deploying to a PaaS environment like Heroku.
This article - How to deploy a create-react-app with an Express backend to Heroku - details the steps needed for the third option.


How can I implement Robot Framework-style variables in this nestable For Loop?

Question: I've seen a lot of "nestable" For loops in Robot Framework, mostly creating a keyword with a For loop inside, then calling that keyword within another For Loop. I made a nestable For Loop using Python 2.7.13, but because it primarily uses Run Keywords syntax I couldn't create a variable using Robot Framework-style syntax (e.g. ${variable_name}=  My Keyword). For the record, this is Run Keywords under the BuiltIn Robot Framework library, which uses the following syntax:
Run Keywords    Keyword1    arg11   arg12   AND     Keyword2    arg21   arg22

Equivalently, it can be written like this:
Run Keywords    Keyword1    arg11   arg12
...     AND     Keyword2    arg21   arg22

It doesn't typically support variables being created within it. But, I used Run Keywords as a part of the nestable For Loop. Here's the Python code for that keyword.
from robot.libraries.BuiltIn import BuiltIn

class Loops(object):
    def __init__(self):
        self.selenium_lib = BuiltIn().get_library_instance('ExtendedSelenium2Library')
        self.internal_variables = {}

    def for_loop(self, loop_type, start, end, index_var, *keywords):
        #   Format the keywords
        keywords = self._format_loop(*keywords)

        #   Clean out the internal variables from previous iterations
        self.internal_variables = {}

        #   This is the actual looping part
        for loop_iteration in range(int(start), int(end)):
            keyword_set = self._index_var_swap(loop_iteration, index_var, *keywords)
            #   If it's a one-keyword list with no arguments, then I can use the fastest possible keyword to run it
            if len(keyword_set) == 1:
                BuiltIn().run_keyword(keyword_set)
            #   If it's a one-keyword list with arguments, then I can use a faster keyword to run it
            elif 'AND' not in keyword_set:
                BuiltIn().run_keyword(*keyword_set)
            #   If it's a multiple-keyword list, then I have to use Run Keywords
            else:
                BuiltIn().run_keywords(*keyword_set)

    def _format_loop(self, *keywords):
        keywords = list(keywords)   # I need to format the keywords as a list.
        changed = False             # Whether or not I changed anything in the previous iteration.
        index = 0                   # The item index I'm at in the list of keywords
        del_list = []               # The list of items I need to delete
        swap_list = []              # The list of items i need to swap to AND for the use of Run Keywords
        #   For each argument
        for x in keywords:
            #   Format it to a string
            x = str(x)
            #   If the keyword in question happens to be one of the 'Assign Internal Variable' keywords, then I need
            #       to run it now, not later.
            #   By splitting it up, I add a little complexity to the code but speed up execution when you're just
            #       assigning a scalar variable as opposed to having to search through the next few items just to find
            #       what I know is just going to be the next one.
            #   So, if it's the simple assignment...
            if x.lower() == 'assign internal variable':
                #   ...run the Assign Internal Variable keyword with the two inputs
                BuiltIn().run_keyword(x, *keywords[int(index)+1:int(index)+3])
            #   If it's the more complicated variable...
            elif x.lower() == 'assign internal variable to keyword':
                #   ...initialize variables...
                deliminator_search = 0
                k_check = x
                #   ...search the next few keywords for a deliminator...
                while k_check != '\\' and k_check != '\\\\':
                    deliminator_search = deliminator_search + 1
                    k_check = keywords[int(index)+deliminator_search]
                #   ...and run the Assign Internal Variable to Keyword keyword with the found keyword
                BuiltIn().run_keyword(x, *keywords[int(index)+1:int(index)+2+deliminator_search])

            #   If the previous element was not changed...
            if not changed:
                #   If the current item is not the last one on the list...
                if x != len(keywords) - 1:
                    #   If the current item is a deliminator...
                    if x == '\\':
                        #   If the next item is a deliminator, delete this item and set changed to True
                        if keywords[int(index) + 1] == '\\':
                            del_list.append(index)
                            changed = True
                        #   If the next item is not a deliminator...
                        else:
                            #   If this isn't the first deliminator on the list, swap it to an 'AND'
                            if index != 0:
                                swap_list.append(index)
                                changed = True
                            #   If this deliminator is in position index=0, just delete it
                            else:
                                del_list.append(index)
                                changed = True
                    #   If the current element is not a deliminator, then I don't need to touch anything.
                #   If the current element is the last one, then I don't need to touch anything
            #   If the previous element was changed, then I don't need to "change" this one...
            elif changed:
                changed = False
                #   ...but if it's a deliminator then I do need to set it up for the inner for loop it means.
                if keywords[index] == '\\':
                    keywords[index] = '\\\\'
            index = index + 1   # Advance the index

        # These actually do the swapping and deleting
        for thing in swap_list:
            keywords[thing] = 'AND'
        del_list.reverse()
        for item in del_list:
            del keywords[item]

        # I also need to activate my variables for this set of keywords to run.
        keywords = self._activate_variables(*keywords)

        return keywords

    @staticmethod
    def _index_var_swap(loop_iteration, index_var, *keywords):
        #   Format the keywords as a list for iteration
        keywords = list(keywords)
        index = 0
        #   For every line in keywords
        for line in keywords:
            #   Replace all instances of the index_var in the string with the loop iteration as a string
            keywords[index] = str(line).replace(str(index_var), str(loop_iteration))
            index = index + 1
        return keywords

    def assign_internal_variable(self, variable_name, assignment):
        # This keyword works like any other keyword so that it can be activated by BuiltIn.run_keywords
        # The syntax for an internal variable is '{{varName}}' where varName can be anything
        self.internal_variables[variable_name] = assignment

    def assign_internal_variable_to_keyword(self, variable_name, keyword, *assignment):
        # This keyword works like any other keyword so that it can be activated by BuiltIn.run_keywords
        # The syntax for an internal variable is '{{varName}}' where varName can be anything
        self.internal_variables[variable_name] = BuiltIn.run_keyword(keyword, *assignment)

    def _activate_variables(self, *keywords):
        #   Initialize variables
        keywords = list(keywords)   # Cast keywords as a List
        index = 0                   # The index of the keyword I'm looking at

        #   For each keyword
        for keyword in keywords:
            keyword = str(keyword)  # Cast keyword as a String
            assignment = False      # Whether or not the found variable name is in a variable assignment
            for key in self.internal_variables.keys():
                key = str(key)      # Cast key as a String
                #   If I can find the key in the keyword and it's not an assignment...
                if keyword.find(key) > -1 and not assignment:
                    #   ...replace the text of the key in the keyword.
                    keywords[index] = keyword.replace(str(key), str(self.internal_variables[key]))
                #   If the keyword I'm looking at is an assignment...
                if keyword.lower() == 'assign internal variable'\
                        and keyword.lower() != 'assign internal variable to keyword':
                    #   ...then my next keyword is going to definitely be a known variable, so I don't want to touch it.
                    assignment = True
                #   If the keyword I'm looking at is not an assignment...
                else:
                    #   ...set assignment to False just in case the previous one happened to be an assignment.
                    assignment = False
            index = index + 1   # Advance the index
        return keywords     # Return the list of keywords to be used in the format loop

As you can see, my workaround is to create a new keyword called Assign Internal Variable and its partner Assign Internal Variable to Keyword. However, this changes the syntax of a Robot Framework loop a little too significantly for my liking, and is somewhat limited in that the internal variables are completely separate from the outside variables. An example of this keyword in action in a Robot Framework test case is as follows:
*** Variables ***
${gold_squadron} =  Gold
${red_squadron} =   Red

*** Test Cases ***
Test For Loop
    For Loop    IN RANGE    0   1   INDEX0
    ...     \\  For Loop    IN RANGE    1   6   INDEX1
    ...     \\  \\  Assign Internal Variable    {{standing_by}}     Standing By Red Leader
    ...     \\  \\  Run Keyword If      INDEX1 == 1     Log to Console  ${red_squadron} Leader Standing By
    ...     \\  \\  Run Keyword Unless  INDEX1 == 1     Log to Console  ${red_squadron} INDEX1 {{standing_by}}
    ...     \\  For Loop    IN RANGE    1   6   INDEX2
    ...     \\  \\  Assign Internal Variable    {{standing_by_2}}   Standing By Gold Leader
    ...     \\  \\  Run Keyword If      INDEX2 == 1     Log to Console  ${gold_squadron} Leader Standing By
    ...     \\  \\  Run Keyword Unless  INDEX2 == 1     Log to Console  ${gold_squadron} INDEX2 {{standing_by_2}}

That loop works as intended, assuming you have imported the Loops.py python file as a Library correctly. The syntax I'm looking for, however, is something along the lines of the following:
*** Variables ***
${gold_squadron} =  Gold
${red_squadron} =   Red

*** Test Cases ***
Test For Loop
    For Loop    IN RANGE    0   1   INDEX0
    ...     \\  For Loop    IN RANGE    1   6   INDEX1
    ...     \\  \\  {standing_by}=      Standing By Red Leader
    ...     \\  \\  Run Keyword If      INDEX1 == 1     Log to Console  ${red_squadron} Leader Standing By
    ...     \\  \\  Run Keyword Unless  INDEX1 == 1     Log to Console  ${red_squadron} INDEX1 {{standing_by}}
    ...     \\  For Loop    IN RANGE    1   6   INDEX2
    ...     \\  \\  {standing_by_2}=    Standing By Gold Leader
    ...     \\  \\  Run Keyword If      INDEX2 == 1     Log to Console  ${gold_squadron} Leader Standing By
    ...     \\  \\  Run Keyword Unless  INDEX2 == 1     Log to Console  ${gold_squadron} INDEX2 {{standing_by_2}}

For anyone who doesn't feel like tearing into the base code of Robot Framework (not recommended, it's painful), the reason For Loops aren't typically nestable in Robot Framework is because at the basic level, Keywords and For Loops are two completely different objects. Some keywords are coded so that they can use other keywords (like "Run Keyword"), but For Loops are not coded that way. If someone can figure out a way to change up the syntax of my For Loop, that would make the end result a lot more intuitive to use for someone just coming from Robot Framework.
Just to be clear, if it wasn't clear from the examples, I CAN use Robot Framework variables from outside the Test Case and For Loop just fine. I'm asking about creating them in the For Loop itself.
Comment: Thank you, fixed.
Comment: God news is that newer `FOR` syntax replaces the ugly `\\ ` with an `END` reserved word. I wish that the `... If` keywords would do the same, so it could be easier to assign vars in their blocks. For now, I've been using `Set Test Variable` --though that only works with right-hand-side expressions, not  function/keyword calls.
Answer: I figured it out, finally. Here's the corrected code.
from robot.libraries.BuiltIn import BuiltIn

class Loops(object):

    def __init__(self):
        self.selenium_lib = BuiltIn().get_library_instance('ExtendedSelenium2Library')
        self.internal_variables = {}

    def for_loop(self, loop_type, start, end, index_var, *keywords):
        #   Format the keywords
    keywords = self._format_loop(*keywords)

        #   Clean out the internal variables from previous iterations
        self.internal_variables = {}

        #   This is the actual looping part
        for loop_iteration in range(int(start), int(end)):
            keyword_set = self._index_var_swap(loop_iteration, index_var, *keywords)
            #   If it's a one-keyword list with no arguments, then I can use the fastest possible keyword to run it
            if len(keyword_set) == 1:
                BuiltIn().run_keyword(keyword_set)
            #   If it's a one-keyword list with arguments, then I can use a faster keyword to run it
            elif 'AND' not in keyword_set:
                BuiltIn().run_keyword(*keyword_set)
            #   If it's a multiple-keyword list, then I have to use Run Keywords
            else:
                BuiltIn().run_keywords(*keyword_set)

    def _format_loop(self, *keywords):
        keywords = list(keywords)   # I need to format the keywords as a list.
        changed = False             # Whether or not I changed anything in the previous iteration.
        index = 0                   # The item index I'm at in the list of keywords
        del_list = []               # The list of items I need to delete
        swap_list = []              # The list of items i need to swap to AND for the use of Run Keywords

        def _new_variable():
            #   Default to a variable declaration of 'name='
            t = 1
            #   If my variable declaration is 'name ='
            if x[-2:] == ' =':
                #   Reflect that in the value of t
                t = 2

            #   Count the number of cells until the end of the line
            length = self._deliminator_search(index, x, *keywords)

            if length == 3 and not BuiltIn().run_keyword_and_return_status("Keyword Should Exist", keywords[index + 1]):
                #   If I'm assigning a value to my variable
                self._assign_internal_variable(x[:-t], str(keywords[index + 1]))

            elif length == 3:
                #   If I'm assigning the result of a keyword without any arguments
                self._assign_internal_variable_to_keyword(keywords[index][:-t], str(keywords[index + 1]))
            else:
                #   If I'm assigning the result of a keyword with arguments
                self._assign_internal_variable_to_keyword(keywords[index][:-t], keywords[index + 1],
                                                          keywords[index + 2:index + (length - 1)])

            #   Add the variable declaration code to the delete list.
            del_list.extend(range(index - 1, index + length))

        #   For each argument
        for x in keywords:
            #   Format it to a string
            x = str(x)
            #   Assign new variables
            if x[-1:] == '=':
                _new_variable()

            #   If the previous element was not changed...
            if not changed:
                #   If the current item is not the last one on the list...
                if x != len(keywords) - 1:
                    #   If the current item is a deliminator...
                    if x == '\\':
                        #   If the next item is a deliminator, delete this item and set changed to True
                        if keywords[int(index) + 1] == '\\':
                            del_list.append(index)
                            changed = True
                        #   If the next item is not a deliminator...
                        else:
                            #   If this isn't the first deliminator on the list, swap it to an 'AND'
                            if index != 0:
                                swap_list.append(index)
                                changed = True
                            #   If this deliminator is in position index=0, just delete it
                            else:
                                del_list.append(index)
                                changed = True
                    #   If the current element is not a deliminator, then I don't need to touch anything.
                #   If the current element is the last one, then I don't need to touch anything
            #   If the previous element was changed, then I don't need to "change" this one...
            elif changed:
                changed = False
                #   ...but if it's a deliminator then I do need to set it up for the inner for loop it means.
                if keywords[index] == '\\':
                    keywords[index] = keywords[index]*2
            index = index + 1   # Advance the index

        # These actually do the swapping and deleting
        for thing in swap_list:
            keywords[thing] = 'AND'
        del_list.reverse()
        for item in del_list:
            del keywords[item]

        # I also need to activate my variables for this set of keywords to run.
        keywords = self._activate_variables(*keywords)

        return keywords

    @staticmethod
    def _index_var_swap(loop_iteration, index_var, *keywords):
        #   Format the keywords as a list for iteration
        keywords = list(keywords)
        index = 0
        #   For every line in keywords
        for line in keywords:
            #   Replace all instances of the index_var in the string with the loop iteration as a string
            keywords[index] = str(line).replace(str(index_var), str(loop_iteration))
            index = index + 1
        return keywords

    def _assign_internal_variable(self, variable_name, assignment):
        # This keyword works like any other keyword so that it can be activated by BuiltIn.run_keywords
        self.internal_variables[variable_name] = assignment

    def _assign_internal_variable_to_keyword(self, variable_name, keyword, *arguments):
        # Uses assign_internal_variable to simplify code.
        # BuiltIn().log_to_console(BuiltIn().run_keyword(keyword, *arguments))
        self._assign_internal_variable(variable_name, BuiltIn().run_keyword(keyword, *arguments))
        # BuiltIn().log_to_console(self.internal_variables[variable_name])

    def _activate_variables(self, *keywords):
        #   Initialize variables
        keywords = list(keywords)   # Cast keywords as a List
        index = 0                   # The index of the keyword I'm looking at

        #   For each keyword
        for keyword in keywords:
            keyword = str(keyword)  # Cast keyword as a String
            assignment = False      # Whether or not the found variable name is in a variable assignment
            for key in self.internal_variables.keys():
                key = str(key)      # Cast key as a String
                #   If I can find the key in the keyword and it's not an assignment...
                if keyword.find(key) > -1 and not assignment:
                    #   ...replace the text of the key in the keyword.
                    keywords[index] = keyword.replace(str(key), str(self.internal_variables[key]))
                #   If the keyword I'm looking at is an assignment...
                if keyword.lower() == 'assign internal variable'\
                        and keyword.lower() != 'assign internal variable to keyword':
                    #   ...then my next keyword is going to definitely be a known variable, so I don't want to touch it.
                    assignment = True
                #   If the keyword I'm looking at is not an assignment...
                else:
                    #   ...set assignment to False just in case the previous one happened to be an assignment.
                    assignment = False
            index = index + 1   # Advance the index
            #   NOTE: Replaces the EXACT text, even if it's in another keyword or variable, so be very careful
        return keywords     # Return the list of keywords to be used in the format loop

    @staticmethod
    def _deliminator_search(start, keyword, *keywords):
        index = 0
        while keyword != '\\' and keyword != '\\\\':
            keyword = keywords[int(start) + index]
            index = index + 1
        return index

And here is the code to test it:
*** Variables ***
${blue_squadron} =      Blue
${gold_squadron} =      Gold
${green_squadron} =     Green
${red_squadron} =       Red

*** Test Cases ***
Test For Loop
    For Loop    IN RANGE    0   1   INDEX0
    ...     \\  For Loop    IN RANGE    1   6   INDEX1
    ...     \\  \\  {standing_by}=      standing by
    ...     \\  \\  Run Keyword If      INDEX1 == 1     Log to Console  This is ${red_squadron} Leader standing by
    ...     \\  \\  Run Keyword Unless  INDEX1 == 1     Log to Console  ${red_squadron} INDEX1 {standing_by}
    ...     \\  For Loop    IN RANGE    1   6   INDEX2
    ...     \\  \\  standing_by_2 =     standing by
    ...     \\  \\  Run Keyword If      INDEX2 == 1     Log to Console  This is ${gold_squadron} Leader standing by
    ...     \\  \\  Run Keyword Unless  INDEX2 == 1     Log to Console  ${gold_squadron} INDEX2 standing_by_2
    ...     \\  For Loop    IN RANGE    1   6   INDEX3
    ...     \\  \\  standing_by_3=      Get Blue Squadron
    ...     \\  \\  Run Keyword If      INDEX3 == 1     Log to Console  This is ${blue_squadron} Leader standing by
    ...     \\  \\  Run Keyword Unless  INDEX3 == 1     Log to Console  ${blue_squadron} INDEX3 standing_by_3
    ...     \\  For Loop    IN RANGE    1   6   INDEX4
    ...     \\  \\  standing_by_4 =     Get Green Squadron   null input
    ...     \\  \\  Run Keyword If      INDEX4 == 1     Log to Console  This is ${green_squadron} Leader standing by
    ...     \\  \\  Run Keyword Unless  INDEX4 == 1     Log to Console  ${green_squadron} INDEX4 standing_by_4

*** Keywords ***
Get Blue Squadron
    [Return]    standing by

Get Green Squadron
    [Arguments]     ${null_input}
    [Return]        standing by

To add some clarification to this solution, I don't need the variable to be in a particular format. It can be, should you wish to specify further exactly what your variable is with no ambiguity, but it's not necessary. I'd rather leave more options open in this kind of program.


Segments on a real line

Question: Cosider a set of a closed segments on a real line, each two of them have an intersection. Is it true that there exists a point, which is contained in all of that sets?
My suggestions: 1) First of all, we can build a construction, based on a principe of  nested segments (Cauchy-Cantor).
But, the thing is that that we can only cope with it in the case, where we work with a finite number of segments.
How to consider this in a common way?
Thank you in advance.
Comment: Open or closed or arbitrary segments?
Comment: Closed segments, actually )
Comment: Just to clarify for those who may be considering this question: Do you intend that all of the segments are finite closed segments with positive length?
Answer: Let $[a_i,b_i]$ with $i\in I$, $-\infty< a_i\le b_i< +\infty$ be your segments. Wlog. $I\ne\emptyset$, and we can pick one segment $[a_0,b_0]$. Then by assumtion $a_i\le b_0$ and $b_i\ge a_0$ for all $i\in I$. Then  $a=\sup\{\,a_i\mid i\in I\,\}$ and $b=\inf\{\,b_i\mid i\in I\,\}$ are both finite (namely $a,b\in [a_0,b_0]$). Assume $a>b$. Then for suitable $i\in I$ we have $a_i>\frac{a+b}2$ and for suitable $j\in I$ we have $b_j<\frac{a+b}2$, hence $[a_i,b_i]\cap [a_j,b_j]=\emptyset$, contrary to assumption. We conclude that $a\le b$. Then for all $i\in I$ we have $a_i\le a\le b\le b_i$, i.e.
$$ \emptyset \ne [a,b]\subseteq \bigcap_{i\in I} [a_i,b_i]$$

If we allow the closed intervals to be unbounded, we are lost: Consider the closed unbounded intervals $[n,\infty)$, $n\in\mathbb N$.
If we allow open intervals, we are also lost: Consider $(0,\frac1n)$, $n\in\mathbb N$.
Answer: I am assuming that a segment is a compact interval.
Let $I_k$ be the segments. I claim that any finite intersection is non-empty.
This is clearly true for $I_1 \cap I_2$. Suppose this is true for $I_1 \cap \cdots \cap I_n$, but
$(I_1 \cap \cdots \cap I_n) \cap \cdots I_{n+1} = \emptyset$. Then we must have
$\inf I_{n+1} > \min_{k=1,...,n } \sup I_k$ or the corresponding condition
on the other side. Suppose $k_0$ is an index for which the minimum is achieved, then this says that $\inf I_{n+1} > \sup I_{k_0}$ which means that
$I_{n+1} \cap I_{k_0} = \emptyset$, a contradiction.
Since $I_{k_1} \cap \cdots \cap I_{k_n} \supset I_1 \cap \cdots \cap I_{\max(k_1,...,k_n)}$, it is clear that this is true for arbitrary finite intersections.
Clearly $I_1 \cap \cdots \cap I_n \subset I_1$, $I_1 \cap \cdots \cap I_n$ is closed. Since $I_1$ is compact, the collection $I_k$ satisfies the
finite intersection property, we have $\cap_{k=1}^\infty I_k \neq \emptyset $.
Comment: I wonder if you could re-select Hagen's answer please? He was first, you had previously selected his answer and I was adding my answer as an alternative, not to capture the vote. Much appreciated.
Comment: Unfortunately, i haven't got used to the interface of the service, so the click wasn't made intentionally. )
Comment: No problem, much appreciated!

Segments on a real line


Use 'using enum' in C++20 in classes possible?

Question: In this answer it was mentioned that in the upcoming C++20 standard it is possible to use the using statement on enum class and import the enum fields into the local namespace.
I was wondering if that also means that I can also use it within class definitions like this:
class Foo {
    enum class Color
    {
        red,
        blue
    };
    using enum Color;
};

int main()
{
    Foo::Color c = Foo::red;
}

Or do I still need to give the full namespace?:
    Foo::Color c = Foo::Color::red;

I tried it in wandbox.org, but it seems that neither gcc nor clang know about using enum yet.
Comment: Do note that C++20 has not yet been ratified so it is not surprising that compilers do not have full support.
Comment: @NathanOliver yes, I know. It wasn't meant as a criticism. Just an observation.
Answer: Yes, Foo::Red will work fine. using enum E behaves as, from [enum.udecl]:

A using-enum-declaration introduces the enumerator names of the named enumeration as if by a using-declaration for each enumerator.

And the standard contains an example of exactly this case:

[ Note: A using-enum-declaration in class scope adds the enumerators of the named enumeration as members to the scope. This means they are accessible for member lookup. [ Example:
enum class fruit { orange, apple };
struct S {
  using enum fruit;             // OK, introduces orange and apple into S
};
void f() {
  S s;
  s.orange;                     // OK, names fruit::orange
  S::orange;                    // OK, names fruit::orange
}

— end example ] — end note ]

Note however that there is some controversy around the particular spelling for this feature. enum E is what's known as an elaborated type specifier (much like class C or struct S). Typically, elaborated type specifiers behave exactly the same was as their underlying versions. Elaborating is just meant to disambiguate, and you rarely need to disambiguate, so you wouldn't see it very often. However, in this particular case, using enum E and using E actually mean wildly different and wholly unrelated things. So keep in mind that there is a chance that this feature may not yet actually make C++20, despite currently being in the working draft and even having been published in the CD. As such, it's unlikely that compilers will implement this feature until they're sure it's necessary to implement (C++20 isn't exactly lacking in work for compiler writers...)
Comment: That's even better than I imagined. Importing enum classes from outside the class. That should make it much easier to move to enum classes now without most users noticing it.
Comment: Interestingly, the chosen solution to the elaborated type specifier issue was to define `using enum` as simply the `using` keyword followed by an `enum`'s elaborated type specifier, thus defining `using enum E` as a special case of `using E` rather than as unrelated to `using E`.
Comment: @JustinTime-ReinstateMonica I don't understand your point?
Comment: Just commenting on how they solved the issue of `using enum E` and `using E` meaning different things, @Barry.


Search for a Column filter for blanks and loop through workbook

Question: im a bit of a vba beginner but im trying to write a macro that searches for a column then once its found it filter out blanks then loop it for all the sheets in the workbook
i started with this to find the column
SearchCol = "ID"

Dim rng1 As Range
Set rng1 = activesheet.UsedRange.Find(SearchCol, , xlValues, xlWhole)

With Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter field:=rng1.Column, Criteria1:="<>"
End With

then im trying to combine it with this to loop it through worksheets
Dim ws As Object

For Each ws In Worksheets

    With ws.Range("A2")
        .AutoFilter field:=1, Criteria1:="<>"
        .AutoFilter field:=1, Criteria1:="<>"
         End With

Next ws

Any help with this would be much appreciated
Answer: Try this:
Sub test()
    Dim SearchCol As String
    Dim rng1 As Range
    Dim ws As Worksheet

    SearchCol = "ID"

    For Each ws In Worksheets
        Set rng1 = ws.UsedRange.Find(SearchCol, , xlValues, xlWhole)
        If Not rng1 Is Nothing Then
            With ws.Range("A2")
                .AutoFilter field:=rng1.Column, Criteria1:="<>"
            End With
        End If
    Next ws
End Sub

Comment: right now i want to search for another column leaving that filter on and fill values red that are less than 4 for each cell in that column
Comment: I think you can post it like new question


Preventing redirecting from the start

Question: I'm experience some auto redirecting at the page when it first loaded.
These are my codes:
def editUser = {
    if(params.account_expired != null )
    {
    String updateQuery = "UPDATE user SET expired='"+params.account_expired+"'"

    def update = sql.executeUpdate(updateQuery)
    redirect (action: listUser)
    [update:update]

    }

    else
    {

    }
 }

so what happen is, when the page got loaded, it auto redirect back to listuser page. This is actually an edituser page and I want it to stay there until the user clicks a button. And then redirect to listuser. Any idea guys?
Comment: Just as a suggestion, you should not use groovy sql. Defeats the whole purpose of Grails apps being database independent. Also you are highly prone to sql injection with that code above. Switch to using HQL or GORM methods.
Answer: It's common to use POST method to send update, and GET to show form (as it suggested by W3C, and used in Grails by default). So you can use:
def editUser = {
  if (request.method == 'GET') {
     render(view: 'editUser')
  } else if (request.method == 'POST') {
     //.... current code
  }
}

by default Grails creates POST form, when you're using <g:form tag, but if you're using plain HTML tags, you should specify POST method as:
<form method="POST">

</form>

Answer: That's exactly what your code is supposed to do, because you have this executed:
redirect (action: listUser)

If you want it stay in editUser page, you should remove it. Then
[Query1:Query1]

will render editUser.gsp with this parameter passed.
Comment: So how do I redirect myself to the listuser page instead of staying in the same page.
Comment: You can not render a page and redirect to another page at the same time. Your purpose is: "I want it to stay there until the user clicks a button." So put a link or a form submit in the button with "[action: 'listPage']" parameter.
Comment: Is it okay if you were to show me an answer with example? This will benefit other users too. I will try it on my own at the same time.
Comment: I tried, but I think you need to rewrite your code first. When I was trying to add an example, I found that your code was set all the user instances to the same expire status, listUser action in the redirect should be quoted, and Query1 properties is not defined...... That code just won't got compiled successfully. And, As James Kleeh suggested, there are GORM methods which enable a better database access method.
Comment: Sorry i made some edits already. I think i copied wrongly. So sorry, I'm still trying it out.

Preventing redirecting from the start


Bathtub/showerhead leak, short water pipe

Question: I bought a new home recently and found that the water in the bathroom tub/shower comes out of both the showerhead and tub spout (when the diverter is "off").
I removed the spout to see if there was anything clogged inside.  As I was removing it, I noticed that there was some caulk/glue on the base of the spout where it met the wall tiles.  Turns out the spout wasn't clogged, so I put it back on for now.  To my dismay, water now sprays out of the now-unsealed spout base when the shower is on.
I have a few questions:
1) It seems like the water output pipe coming from the wall is much shorter and looks different compared to the pictures I've seen online.  In all the pictures I've seen, the water pipe is a thin copper   My pipe extends approximately 1 inch from the wall (see pictures)  Is this normal?  And if not, what should I install to extend the pipe?
2) What is causing the initial problem of having water come out of both the showerhead and the spout? Will replacing the spout do the job?  Is the short water pipe a concern?
3) Do I need to put some sort of sealant/caulk around the spout base like it had before?
Thank you.
Comment: use a razor to shave the wall washer off. Than try to re-install the spout. If you feel a positive fitment and it seems rigid, check for proper operation (no leaks), and caulk the spout base to the wall with silicone.
Answer: What you will have to do is remove the round piece that is shown in your photo. I believe it was an integral piece from the spout. The small thin O-ring that you see on the most forward section should be pressed into the tub spout for a pressure fit. Since that is what keeps it connected to the spout (as opposed to being mechanically secured) it most likely (and easily) loosened as you were repairing the spout. If you use a pipe wrench or a pair of channel lock wrenches (protect the pipe with a rag wrapped around it) it should unscrew counter clockwise. With some luck you will have removed only the spouts base and not the 1/2" pipe nipple inside the wall (you should be able to see the threads inside the wall). Re-connect the spouts base by pressing the two pieces together. Apply Teflon paste to the female threads on the bottom at tighten back in place. What is causing the water to leak is most likely: 1)the valve handle is not exactly in the off position , 2) the washers or valve cartridge needs replacing, 3) the water may not be a leak , but residual water that remains in the pipe after the valve is closed.
Comment: Thank you for your reply.  I managed to find the product information for the tub spout model I have and see what you mean now.  http://cdn08.grohe.com/lib/1/tpi/696965.pdf
So it sounds like I need to unscrew the part that's sticking out from the wall and attach it to the spout before screwing the entire thing back on.
Comment: I might've been unclear about the "leak" I described in the initial post.  The water comes out of both ends only when the valve handle on (but diverter is set to spout).  There are no leaks when the water is off.  Does this sound like a cartridge issue?
Comment: I don't think it is the valve. Your first answer regarding the diverter on the spout is most likely why water is not flowing to only the shower head when the diverter valve is open, but leaks from the spout also. There is usually a rubber washer that seals the spout opening so that water can not flow through it when the knob is pulled up. This is most likely the cause for the leak. It is much simpler to purchase a new spout ,but if the original is of higher quality materials (brass, chrome, stainless steel) than repairing the damaged washer is also worth the time.
Comment: And to reply to your first comment, yes ,if the spout doesn't fit back onto the base (when the base is secured to the pipe in the wall) remove the base and re-attach it. Apply tape and/or paste (Teflon) and tighten securely.
Comment: I went to the link you posted. Purchase the Grohe part #45617. Also you will need a hex wrench to remove the base. Very well made and quality spout. I have ordered parts for Grohe faucets at: http://www.amazon.com/s/ref=nb_sb_ss_i_5_5?url=search-alias%3Daps&field-keywords=grohe+replacement+parts&sprefix=grohe%2Caps%2C243
Comment: Hm, the issue I'm describing is that the water is supposed to only flow through the spout (diverter knob is down), but for whatever reason water is also flowing up to the shower head.
I understand the reverse issue (knob is up, but water leaks from spout) that you describe, but I don't think I have that problem.  And again, thanks for your help!
Comment: The problem is still with the washer in the diverter not closing properly. The pdf diagram shows what parts are available for replacement. The part you will need is #45-617.
Comment: I see. I'm going to give that a try.  Thanks!
Comment: Also note that the pdf diagram shows a set screw on the underside of the spout. This is what will secure the base to the spout before it is re-installed. You will need a 4mm hex wrench to loosen and then tighten the set screw.
Comment: Right. That's how I got the spout off in the first place :)  OTOH, it's not so clear how to replace part #45617 from the diagram
Comment: If you look closely at the pdf diagram (the second photo) were part # 45816 is shown there is a cap as the first part than the pull tab. The third part is a nut and this is what secures the remaining parts below it. If you can carefully remove the cap or the pull and the cap so as to expose the nut it should be easy to disassemble the rest.


Getting closed before endTest call in Selenium using Extent Reports

Question: BaseTest.java:
<code>private static ReportService reportService; // Calling report service interface

@BeforeSuite:
reportService = new ExtentReportService(getConfig()); // New instance of ExtentReportService.

@BeforeMethod:
reportService.startTest(testname); // Starting the test and passing the name and description of the test.

@AfterMethod:
reportService.endTest(); // Ending the test

@AfterSuite:
reportService.close(); // Closing the test

**ExtentReportService.java:** // Contains different extent API methods. (These are designed to be generic.)

protected static ExtentReports extent; // static instance of ExtentReports
protected static ExtentTest test; //static instance of ExtentTTest

@Override // StartTest method
startTest(Method method) {
testMetaData = getTestMetaData(method);
test=extent.startTest(testMetaData.getId(),testMetaData.getSummary());
}

@Override //End test method
endTest() {
extent.endTest(test);
extent.flush();
}
</code>

The above is my selenium code.
When I am executing my suite file with parallel="methods" and thread count="3", I am getting the following error: "com.relevantcodes.extentreports.ExtentTestInterruptedException: Close was called before test could end safely using EndTest.".
While debugging, I found that even before all endTest() in AfterMehtod were executed, AfterSuite was being called.
I tried different variations such that the code works, such as, removing static, calling endTest() in the test itself rather than after method, removing close() call from AfterSuite and many other variations. But still getting the same error.
I tried all the possible solutions given on the internet, but to no use.

Attaching a hierarchy file for the ExtentReport used in my project
I also the following solution given in StackOverflow:
Extent report :com.relevantcodes.extentreports.ExtentTestInterruptedException: Close was called before test could end safely using EndTest
Unsynchronized output
XMF file for parallel test.
Comment: You are calling extent.endTest(test); method under endTest method,if so which method is this calling. Try to flush report before it.
Comment: My endTest() in BaseTest is calling endTest() in ExtentReportsService class. There, first it will end the test, and then flush the report. I tried flushing it before ending the test. It doesn't work. Also another thing is, all my test cases are executing perfectly well. But only the extent report is not generating properly.
Comment: First, quite the driver and then flush the extent Report.
Comment: Also tried that, but not working. I am getting successful test runs. Just no proper Extent Report document.
Comment: You should be doing the `extent.flush()` in your `@AfterSuite`
Comment: Remove the call to close, it's not required. It closes the stream which is why you see this exception. Also, upgrade to version 3 if possible since version 2 is no longer supported. This issue is most probably due to an existing suite being completed even though tests from a different suite are yet to be run in entirety.
Comment: I am executing flush() in @AfterSuite now. Also I upgraded to the lastest version of Extent. But still getting the same problem.
Comment: Did you remove the close method call as @Anshoo suggested?
Comment: Yes. I removed the close() call. I added the flush() call in AfterSuite. Can this issue be caused by multithreading?
Comment: Please refer to the image named "Unsynchronized ouput in the description."
Comment: Hi, did You try using synchronized in methods, could You provide xml where You're calling  this parallel execution, there is possiblity that You close something before intended
Comment: Yes, I tried that too. I have attached the XML file screenshot for the parallel test I am working on. I am initializing extent report in BeforeSuite, then initializing driver in BeforeMethod and calling driver.quit() in Aftermethod. Then I am calling extent.flush() in AfterSuite. I have also tried with and without alwaysRun=true.
Comment: I am still stuck with the issue. But I think it is caused because of multi-threading. When I don't use Extent Reports, the TestNG emailable report shows the steps as they are in their corresponding test case. But in Extent Reports, the steps are getting jumbled.
Answer:
ExtentReports Intialized in ExtentManager class using Singleton().
public class ExtentManager {
private static ExtentReports extent;
public static ExtentReports getInstance() {
    if(extent == null) {
        extent = new ExtentReports(System.getProperty("user.dir")+"\target\surefire-reports\html\extent.html", true, DisplayOrder.OLDEST_FIRST);
        extent.loadConfig(new File(System.getProperty("user.dir")+"src\test\resources\extentconfig\ReportsConfig.xml"));
    }
    return extent;
}
}
Declared in TestBase class as global.
public ExtentReports repo= ExtentManager.getInstance();
public static ExtentTest test
Call startTest in public void onTestStart(ITestResult result)
test = repo.startTest(result.getName().toUpperCase());
Call endTest in CustomListener Class both in a)public void onTestFailure(ITestResult result); b)public void onTestSuccess(ITestResult result).
repo.endTest(test)
Call close() OR flush() in @AfterSuite in TestBase class but NOT both!
//repo.close();
repo.flush();

Note: I have ExtentReports ver-2.41.2, and TestNg ver-7.1.0.
After the above steps, error 'Getting closed before endTest call in Selenium using Extent Reports' got resolved.
Extent report generates each test successfully in the report.
Try it out!
Comment: Thanks. But this question was old and I re-wrote the code from scratch as there were many other problems. Your solution, if seen logically, will work out. Thanks for the effort and sharing your answer.


Create Windows Python virtualenv with a specific version of Python

Question: I have multiple versions of Python. I need to create a virtualenv for my project and make sure that it's using Python 2.7.
I've tried to accomplish this with the combination of this guide for virtualenv on Windows and this SO post on virtualenv with a specific kind of Python.
Unfortunately it's not working, which is probably because the latter resource was written by someone using Linux.
Here's what I did:
C:\Python27\Scripts>pip install virtualenv You are using pip version
6.0.6, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Collecting virtualenv   Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
    100% |################################| 1.8MB 3.7MB/s eta 0:00:01 Installing collected packages: virtualenv

Successfully installed virtualenv-15.1.0

C:\Python27\Scripts>pip install virtualenvwrapper-win You are using pip version 6.0.6, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Collecting virtualenvwrapper-win   Downloading virtualenvwrapper-win-1.2.1.zip Requirement already satisfied (use
--upgrade to upgrade): virtualenv in c:\python27\lib\site-packages (from virtualenvwrapper
-win) Installing collected packages: virtualenvwrapper-win   Running setup.py install for virtualenvwrapper-win Successfully installed virtualenvwrapper-win-1.2.1

C:\Python27\Scripts>mkvirtualenv c:\users\hackr\Desktop\P27_D19  --python=C:\Python27\python.exe

'python.exe' is not recognized as an internal or external command, operable program or batch file.

'virtualenv.exe' is not recognized as an internal or external command,
  operable program or batch file.

Update: I just got this to work using plain virtualenv instead of the recommended mkvirtualenv command, which I assume is part of the wrapper they had me install. If someone would like to help me understand what happened and if there are any downfalls of not using the wrapper, that would be a good way to write up the answer.
Answer: If having multiple Python versions installed, it's best to always specify full paths (to be sure) and not rely on environment variables (at least it's how I do it):

pip install virtualenv: I do it like : "C:\Install\x64\Python\3.5.3\python.exe" -m pip install virtualenv (don't mind the paths) to control the Python installation (same thing for virtualenvwrapper).

I don't have a mkvirtualenv in my "%PYTHON_INSTALLATION_DIR%\Scripts" (e.g. "C:\Install\x64\Python\3.5.3\Scripts") folder, but (this is an example that I "crafted" now):

"c:\Install\x64\Python\3.5.3\Scripts\virtualenv.exe" -p "c:\Install\x64\Python\2.7.13\python.exe" "c:\venvs\py2713"

From then on:

"c:\venvs\py2713\Scripts\activate.bat"
python ......

I know, it's kind of annoying to specify all those funky paths (on Lnx is soooo much easier), but at least it's safe. Anyway, after setting up the virtual environments, you can adjust your environment (%PATH%), so you don't have to specify full paths.
I noticed your comment while writing, and I  must say that PyCharm (Professional Edition) is an excellent tool to work with Django (as a matter of fact with Python in general). If on the other hand, you go for Community Edition it's not quite so great (as expected). [SO]: Run/Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? is one of the painful issues that I had to deal with.
@EDIT0:
Just now I installed virtualenvwrapper-win: "C:\Install\x64\Python\3.5.3\python.exe" -m pip install virtualenvwrapper-win. Running mkvirtualenv, either by its full path or by adding its parent folder in %PATH% (mkvirtualenv a), yielded the same error:

'python.exe' is not recognized as an internal or external command, operable program or batch file.

but it created the VEnv (under %USERPROFILE%\Envs). So the error is benign. Anyway it can be fixed by either:

Setting %PYTHONHOME%
Adding the path to python.exe in %PATH%

An additional step that I did, was setting %WORKON_HOME% to the folder where I want my VEnvs to be located. Note that the environment variables must be persisted (since I only did this for testing purposes I only set them in the cmd console that I used for this task), otherwise they'll have to be set every time you need to use these tools.
After that workon, lsvirtualenv worked like a charm (well, not as great as in Lnx, but close enough).
Note (about mkvirtualenv v1.2.1): It will use the default python.exe (see above), as a base for the new VEnv, it's not as flexible as virtualenv.exe (which accepts the -p/--python argument).
Comment: I think what you wrote would work and I am upvoting your answer. Please check the update that I just appended to my question as an edit. I got it to work about 10 minutes ago, but I'm not sure why the wrapper recommended by the tutorial didn't work or if I am causing future problems by not using it. If you have any knowledge on this please add it to your answer and I'll accept it as the solution.Yes, I agree it's a fine IDE, but an IDE doesn't really have anything to do with the question/answer IMHO (and even if it did, being forced into using some specific IDE would be restrictive).
Comment: Not using _virtualenvwrapper_, should definitely have no negative impact on the future since it's a simple wrapper over _virtualenv_. I remember from the _Lnx_ + _Django_ "era" the `workon` feature which was truly awesome ("navigating" over _VEnv_ names from the commandline using _TAB_ as if they were files/folders). However, I couldn't do the same on _Win_ (I also must say that I didn't try very hard).
Comment: Many thanks; I have marked your answer as the solution
Comment: `mkvirtualenv` on `virtualenvwrapper-win` now also takes `-p` parameters to pass the python executable (all the other virtualenv flags are also available).
Comment: @thebjorn Yes, that's true, I am using it in one of the commands from the answer.
Comment: I'm just saying that your final note is no longer accurate (mkvirtualenv now passes "all" flags onto virtualenv, including `-p`/`--python`).
Comment: @thebjorn: Ah, thank you, I added the version in the note.