No drivers in Addition Drivers

Question: I just installed Ubuntu 12.04, and the installation went good, all seemed fine, did my updates. After that I decided to install the proprietary drivers for my Graphics card.
Before I did my updates I checked and all was good, I just needed to install them, but now I get this:

Is there any way to fix this? Is my driver already installed, or do I need to reinstall Ubuntu again?
Just for the record if it helps my graphics card is NVidia Geforce 740m
Comment: Should i just  "sudo apt-get install nvidia-current", wont that install the propriatery drivers?
Comment: Have you installed any nVidia drivers? And did you restart?
Comment: Hit update and after that, restarted my pc.
Comment: Okay, let's install them and see what appears
Comment: Either you need to  update the system or it is this: http://askubuntu.com/questions/36930/is-a-nvidia-geforce-with-optimus-technology-supported-by-ubuntu
Answer: As you haven't installed the drivers yet, let's try that.
If you want the latest drivers add the repository to software sources:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update

sudo apt-cache search nvidia | grep -oE "nvidia-[0-9]{1,3}"

I have a list like this:
nvidia-340
nvidia-346
nvidia-346
nvidia-346
nvidia-346
nvidia-346
nvidia-346
nvidia-346
nvidia-346
nvidia-352
nvidia-352
nvidia-355
nvidia-355

View full output here.
Then you need to install one of them. I currently have nvidia-355 (the latest at time of writing) active, but I have also got 352, 346 and 340 as well.
I'd suggest installing the latest non-dev version, which you can find by searching the nVidia site. This is 355 at the moment, so run this command:
sudo apt-get install nvidia-355

Then restart the computer when this completes. When it boots up, check everything is okay and login and then check the Additional Drivers window.
If anything looks buggy, use Ctrl + Alt + F2 to enter tty and login. Then you can install an earlier version, with one of the following commands:
sudo apt-get install nvidia-331
sudo apt-get install nvidia-340
sudo apt-get install nvidia-346
sudo apt-get install nvidia-352
sudo apt-get install nvidia-355

Answer: Remove nvidia drivers:
sudo apt-get purge '^nvidia.*'
sudo reboot

Install the latest drivers:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update

You need to find the latest driver:
sudo apt-cache search nvidia | grep -oE "nvidia-[0-9]{1,3}"

And you will see a list of drivers. At the time of writing, 355 is the latest, but 358 will be released soon, so make sure you run the command and look at the last, newest version, and install that with:
sudo apt-get install nvidia-355
sudo reboot

If you have a laptop with hybrid graphics:
sudo apt-get install nvidia-prime

To switch between intel and nvidia graphics open NVIDIA X Server Settings -> Prime Profiles
Comment: Do you mean a laptop with 2 graphics cards? Like Intel and Nvidia?
Comment: @NikolaAtanasov yes - if you have an intel CPU, that will be the case
Comment: So let me just be sure, in both cases first remove right?
Comment: @NikolaAtanasov yes
Comment: Ok instalation went fine, how do i check if it is the right one?
Comment: @NikolaAtanasov there is no "right one" - if you get no problems with this driver, then that's fine
Comment: And now i can choose from the Addition Drivers tab. Should i?
Comment: @NikolaAtanasov if you can, you could... but don't nessesarily need to
Comment: 355 is latest not 352.

No drivers in Addition Drivers


solving select n + 1 automatically

Question: This provides a simple example of select n + 1 problem in ORM in pht, but the idea should be the same in other ORM of other languages.
A typical solution is to use eager loading to reduce it to 1 query, which I don't think is very hard, but, OTOH, it's quite brittle, because latter refactoring would require the developers to change two places, otherwise this select n + 1 problem re-occurs.
My intuition is that it should be possible to do some path analysis to figure it out that those children attributes would be used in later part of the code, so let's generate the query to collect all the necessary info in one go.
This is probably quite too much to ask for ORM implemented using interpreted langs, such as ruby, php, etc. However, neither Java (NHibernate) nor C# (Entity framework) is doing this path analysis, AFAIK. Why is this?
Answer: i don't understand, if you use EntityFramework, you can use Include(....) to specify which lazily loadable child relationtship entities to load in the same query, and if you specify a clause that take into account some field on that included entity, you get a single request (in few words, just use joins in your linq query)
btw here you can find an old and related question like your: What is SELECT N+1?
as i commented below, a way could be to have a method that you call to add all your needed Include, so that when you add a new navigable property/collection you have just to remember to add there, this answer shows you the concept: https://stackoverflow.com/a/14520939/1716620
Comment: Yes, I can use `Include` to solve the select n+1 problem, but whatever I put in `Include` must be consistent with the usage below. For example, in later refactoring, I added one more item in the view, but forget to update the `Include`, I would suffer from this select n+1 problem again. I understand this select n+1 concept, but I am curious why it couldn't be solved automatically by the compiler.
Comment: compiler can't know how you want to handle your entities, it's up to you to specify which kind of related entities load eager or lazy

whenever you create a linq query, you are just creating an IQuearable rapresentation of the query, and it's not solved at compile time but at runtime, compiler just check if the generic implementation constraint are satisfied but only at runtime the query get solved and translated to SQL or whatever idiom it need to be converted

anyway you could implement your logic to append includes before enumerating your IQuerable (so before generating SQL)
Comment: That would require the compiler to be aware of the ORM. It's possible you might be able to do something like what you are thinking of using Roslyn in C# though.
Comment: i'd add that if you find yourself in the position of having always to use Include, maybe it's a candidate to be eager loaded
Comment: updated the answer with another link with an example about the mentioned "implement your logic to append includes before enumerating your IQuerable" : http://stackoverflow.com/a/14520939/1716620

solving select n + 1 automatically


How to disable dock in some apps in Ubuntu

Question: I've enabled the "Auto-hide the Dock" option in settings. So the dock pops out when I move the cursor down. But it is very useless in some applications.
How can I fully disable the dock in certain apps?
Comment: @user535733, sorry, i forgot that i am using 22.04 now. I just enabled "auto-hide the dock" option in settings/appearance and didn't "make" something.
Answer: To make sure the dock is not revealed by moving the cursor to the edge of the screen, turn "autohide" off:
gsettings set org.gnome.shell.extensions.dash-to-dock autohide false

Reset to default with the command
gsettings reset org.gnome.shell.extensions.dash-to-dock autohide

As such, you can not have this change applied automatically when a specific application is in focus (unless you are rather advanced in scripting, perhaps). However, you can assign the commands to enable (replace false by true) or disable autohide to shortcut keys to be able to quickly change the setting.
You may also set up a single shortcut key that toggles the setting with a little script:
#!/bin/bash
STATUS=$(gsettings get org.gnome.shell.extensions.dash-to-dock autohide)
case $STATUS in
    true )
        gsettings set org.gnome.shell.extensions.dash-to-dock autohide false
    ;;
    false )
        gsettings set org.gnome.shell.extensions.dash-to-dock autohide true
    ;;
esac

To create the script, 1) copy the code into a text file ~/.local/bin/autohide_dock. 2) Make that file executable (right-click, "Properties", "Permissions" tab. 3) Create a shortcut key and provide the file path of the executable script as the command: /home/<yourlogin>/.local/bin/autohide_dock


No wired connection from router when waking up from suspend/reboot/reconnect

Question: So up until recently my 5 year old Linksys WRT54GL router was working fine, but for a few days now everytime I wake up Ubuntu from suspend I have no wired internet (wireless devices still have internet), and the only way to fix it is to turn off and turn on the router.
If I don't do that I can't even access administrator page at 192.168.1.1. It's the same if I disconnect ethernet cable and plug it in again to laptop, I won't have internet unless reboot router once again.
How can I fix it, because it was working perfectly before.
Comment: I have the same problem. Rebooting my machine also seems to work.
Comment: @caarlos0 Well I think for me it's opposite - if I reboot or wake up Ubuntu, then I need to restart router, otherwise no internet.
Answer: I checked my /etc/network/interfaces and it was like this (I never changed anything before):
auto lo
iface lo inet loopback

So I modified it:
auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp

And now it automatically connects when I reboot or plug the ethernet cable. Not sure why was this the solution because I never touched interfaces file.


Structures induced from other structures

Question: As is well known, inner products induce norms, norms induce metrics and metrics induce topologies. I was wondering, are there any other well known (or common) mathematical structures that can be added to this chain (in either side)?
$$
\text{Inner product} \longrightarrow \text{Norm} \longrightarrow \text{Metric} \longrightarrow \text{Topology}
$$
Answer: You can insert "uniformity" between metric and topology, see wikipedia, e.g..
If you're more functional analysis minded, insert Fréchet spaces between normed spaces and metric spaces. They're an important class as well. There is an even weaker class, the metrisable linear spaces, inbetween Fréchet and metric (see topological vector spaces). the latter need not be complete nor locally convex, so are less useful in applications.
Also, unrelatedly to metrics or vector spaces, linear orders induce an order topology on a set.


gcloud compute scp - Connection Failed (Sometimes with 4010 Error Code)

Question: "Connection Failed
You cannot connect to the VM instance because of an unexpected error. Wait a few moments and then try again."
When I tried to copy file from one virtual machine to another using scp, ssh client loses connection. Command that I run is the following:
gcloud compute scp --recurse file_name account@instance_name:~/folder --zone zone_name --project project_name

What can be the reason of it?
Comment: Hello, have you found an answer for this? I'm facing something similar when I try to deploy a Google Cloud VM instance via Terraform. Thanks.
Answer: Make sure that you have opened port 22, which is the port that allows communication with SSH. If you are not sure, you can create a rule by going to VPC -> Firewall Rules -> port 22.
Here is an article that can help with allowing SSH connection
This other article can help you troubleshooting SSH
You can also run the following command to check which ports you have open netstat -tuplen, make sure you have port 22 listening.
Comment: Port 22 is open and properly defined in Firewall Rules.
Comment: Can you please share the complete 4010 Error Code you get? The only 4010 error code I was able to find is the following "Code: 4010 - Connection via Cloud Identity-Aware Proxy Failed".


How to perform multiple selections in a Qlikview Straight Table?

Question: How would I go about making multiple selections in a QlikView straight table?
For example, how would I select the 1st and 5th rows at the same time?
Comment: Can't you just CTRL+Click?
Answer: There is a section about multiple selections in the QlikView 11 - Reference Manual :

14.5 Multiple Selection Within a Field
Multiple selections within a field (from one lisstrong textt box) can be made in a number of ways:

Position the cursor in the list box, then drag it over a number of field values while pressing the
      mouse button.
Click the first field value to be selected, then CTRL-click each additional selection.
Click the top item to be selected, then SHIFT-click the bottom item to be selected. This way all the
      items in between will be selected. However, if the sort mechanism is on, the first selection may cause
      the order to change, which makes it difficult to make a correct second selection.
Confirm a text search (see below) by hitting the ENTER key. This will result in all matching field
      values being selected. By keeping the CTRL key depressed while pressing ENTER the selections
      from the text search will be added to previous selections.

To deselect a previously made additional selection, CTRL-click it.
      If a multiple selection is made in one list box, and make a new selection from the available optional values
      in another list box, some of the selected values in the first list box may get excluded. However, when the
      selection in the second list box is canceled, the previous selections will, by default, be recovered.
      A multiple selection can be interpreted in two different ways, either as a logical or or as a logical and.
      Default is logical or, i.e. QlikView will find a solution that is associated to one or more of the selected field
      values.

HTH
Answer: For straight tables, you can only select items next to each other. Ctrl-Select only works for listboxes


How does CameraX library can turn ON/OFF the torch?

Question: I am developing a feature with the possibility of switching the torch into ON/OFF states. Some days ago, we saw a new library from Google in io2019. I came up with an idea, why not use it.
After some time, I don't see any possibilities to use the only torch from the library.
Even in the official documentation, I wasn't able to find any good pieces of information for me, what's more, the sample app from their also don't have to handle my case.
Do you have something in mind what is easy to implement or perhaps you know how to do it with CameraX?
I am worried about using camera or camera2 because the amount of code to be paste is terrible.
Links:
[1] https://developer.android.com/training/camerax
[2] https://proandroiddev.com/android-camerax-preview-analyze-capture-1b3f403a9395
[3] https://github.com/android/camera/tree/master/CameraXBasic
[4] https://github.com/android/camera/tree/master/CameraXBasic
CameraX is an Android Jetpack library that was built with the intent to make camera development easier.
Answer: androidx.camera:camera-core:1.0.0-alpha10

You can check is torch available or not with this:
val camera = cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, preview, imageAnalyzer)

camera.cameraInfo.hasFlashUnit()

And you can enable torch with:
camera.cameraControl.enableTorch(true)

Comment: thank you so much!  I put in the latest syntax in an answer.
Answer: 2021 syntax.
Turn on torch on Android, using Java.
Your typical camera preview code (such as from the google example) generally ends like this:
cameraProvider.bindToLifecycle((LifecycleOwner)this,
                 cameraSelector, imageAnalysis, preview);

to turn on/off the torch...
Camera cam = cameraProvider.bindToLifecycle((LifecycleOwner)this,
                 cameraSelector, imageAnalysis, preview);

if ( cam.getCameraInfo().hasFlashUnit() ) {
    cam.getCameraControl().enableTorch(true); // or false
}

and that's it!
Comment: editors - cheers, don't remove phrases which are there for the benefit of search engines
Comment: Got it, ImageCapture.FLASH_MODE_AUTO
Comment: For anyone who just wants to turn flash on, you still need the camera permission to make it work and also at least 1 use case to bind to cameraProvider.
Comment: @Fattie How can we implement auto flash on/off using CameraX?
Answer: 2022 Syntax
imageCapture = ImageCapture.Builder()
                .setFlashMode(ImageCapture.FLASH_MODE_ON)
                    .build()

val camera = cameraProvider.bindToLifecycle(
             this, cameraSelector, preview, imageCapture, imageAnalyzer)

if (camera.cameraInfo.hasFlashUnit()) {
     camera.cameraControl.enableTorch(true)
}

Comment: Make sure you're using at least version `'1.2.0-alpha04'` in your gradle.build file and this should lead you to success, young Padawan.
Answer: This is one way you can do it (Kotlin). If there is a better way please let me know. Following code assumes you have already established the availability of flash on the device.
Declare a flashMode var
private var flashMode: Int = ImageCapture.FLASH_MODE_OFF

In updateCameraUI set a listener
controls.findViewById<ImageButton>(R.id.flash_button).setOnClickListener {
    when (flashMode) {
        ImageCapture.FLASH_MODE_OFF ->
            flashMode = ImageCapture.FLASH_MODE_ON
        ImageCapture.FLASH_MODE_ON ->
            flashMode = ImageCapture.FLASH_MODE_AUTO
        ImageCapture.FLASH_MODE_AUTO ->
            flashMode = ImageCapture.FLASH_MODE_OFF
    }
    // Re-bind use cases to include changes
    bindCameraUseCases()
}

In bindCameraUseCases set the flash mode
            imageCapture = ImageCapture.Builder()
                .setCaptureMode(ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY)
                .setTargetAspectRatio(screenAspectRatio)
                .setTargetResolution(screenSize)
                .setTargetRotation(rotation)
                .setFlashMode(flashMode)
                .build()

Comment: No need to bindCameraUseCase again after changing the flashMode from clicklistener
Answer: // CameraX
def cameraXVersion = "1.0.0-beta07"
implementation "androidx.camera:camera-camera2:$cameraXVersion"
implementation "androidx.camera:camera-lifecycle:$cameraXVersion"
implementation "androidx.camera:camera-view:1.0.0-alpha14"

    private fun initializeFlashButton() = with(binding) {
        camera?.apply {
            if (cameraInfo.hasFlashUnit()) {
                flashButton.setOnClickListener {
                    flashButton.visibility = View.VISIBLE
                    cameraControl.enableTorch(cameraInfo.torchState.value == TorchState.OFF)
                }
            } else {
                flashButton.visibility = View.GONE
            }

            cameraInfo.torchState.observe(viewLifecycleOwner) { torchState ->
                if (torchState == TorchState.OFF) {
                    flashButton.setImageResource(R.drawable.ic_flash)
                } else {
                    flashButton.setImageResource(R.drawable.ic_flash_active)
                }
            }
        }
    }

You need execute this method after initialize camera object
Comment: Brilliant answer. Thanks for taking advantage of observing the torch state. Could use a little more explanation though. Still a great answer.
Answer: I can't comment so I'm answering to expand on yevhen_69's answer.
Setting enabledTorch(true) didn't work for me either, however I found I had to set enableTorch(true) after the call to CameraX.bindToLifecycle
val previewConfig = PreviewConfig.Builder().apply {
        setLensFacing(lensFacing)
        // Any setup
        setTargetRotation(viewFinder.display.rotation)
}.build()

val preview = Preview(previewConfig)

CameraX.bindToLifecycle(this, preview)
preview.enableTorch(true)

However on a side note, CameraX is still in Alpha so its advisable still to use Camera2 API.
Answer: Use CameraControl as global variable and boolean for turn off and on.
 lateinit var cameraControl: CameraControl
 private var flashFlag: Boolean = true

Turn off and on by click listener.
flashFlag = !flashFlag
cameraControl.enableTorch(flashFlag)

In this function I have started the camera preview.
private fun startCamera() {
        val cameraProviderFuture = ProcessCameraProvider.getInstance(this)

        cameraProviderFuture.addListener({
            // Used to bind the lifecycle of cameras to the lifecycle owner
            val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()

            // Preview
            val preview = Preview.Builder()
                .build()
                .also {
                    it.setSurfaceProvider(binding.cameraView.surfaceProvider)
                }

            // Select back camera as a default
            val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA

            try {
                // Unbind use cases before rebinding
                cameraProvider.unbindAll()

                // Bind use cases to camera
                val camera = cameraProvider.bindToLifecycle(
                    this, cameraSelector, preview
                )
                cameraControl = camera.cameraControl
                cameraControl.enableTorch(flashFlag)

            } catch (exc: Exception) {
                Log.e(TAG, "Use case binding failed", exc)
            }

        }, ContextCompat.getMainExecutor(this))
    }

Comment: What is the binding?
Comment: that's for viewBinding, You can just call your cameraView here.
Comment: what about auto flash mode?
Comment: you can use auto flash mode like this  imageCapture?.flashMode = ImageCapture.FLASH_MODE_AUTO
Answer: val previewConfig = PreviewConfig.Builder().apply {
            setLensFacing(lensFacing)
            // Any setup
            setTargetRotation(viewFinder.display.rotation)
}.build()

val preview = Preview(previewConfig)

preview.enableTorch(true)

Comment: Sorry but enableTorch does not seem to work on my Huawei P10 Lite using Android 8.0. Preview is working fine but it seems that it just does not care about enableTorch(true).  ¯\_(ツ)_/¯

Any ideas?
Comment: `enableTorch` is no longer a method of the class `Preview`; see https://developer.android.com/reference/androidx/camera/core/Preview.html
Answer: androidx.camera:camera-core:1.0.0-alpha06

CameraX new release provide these features. CameraInfo added with check Flash Available and Sensor Rotation APIs, refer this link
try {
    CameraInfo cameraInfo = CameraX.getCameraInfo(currentCameraLensFacing);
    LiveData<Boolean> isFlashAvailable = cameraInfo.isFlashAvailable();
    flashToggle.setVisibility(isFlashAvailable.getValue() ? View.VISIBLE : View.INVISIBLE);
} catch (CameraInfoUnavailableException e) {
    Log.w(TAG, "Cannot get flash available information", e);
    flashToggle.setVisibility(View.VISIBLE);
}

Comment: Where is this class `CameraX` you are using? I think CameraX is a library not a class, I cannot find any static method `CameraX.getCameraInfo` like what you have called here. also, this code snippet will only check the flash state and set the visibility of a toggle based on the flash state, it won't actually set the flash state
Comment: This is the example when cameraX is in alpha, in latest version may be this class removed.
Answer: You can enable the torch on the Preview object.
https://developer.android.com/reference/androidx/camera/core/Preview.html#enableTorch(boolean)
And you can set the flash mode (on/off/auto) on the ImageCapture object or on the config builder associated.
https://developer.android.com/reference/androidx/camera/core/ImageCapture.html#setFlashMode(androidx.camera.core.FlashMode)
https://developer.android.com/reference/androidx/camera/core/ImageCaptureConfig.Builder.html#setFlashMode(androidx.camera.core.FlashMode)
Comment: Looks like that method `enableTorch` has now since removed from the API


Should I implement the django rest framework above django?

Question: Currently i have a Django blog website. (Fully functional)
This blogwebsite is something like a social media website...
I have read that django rest framework helps you to serialize your data.
Could I just check about the DRF:

Is serializing data important? Meaning to say what huge benefits would I get by having an additional django rest framework, and also any possible disadvantages?

Would it be very difficult to "add" the framework into my project. Eg does it require me to download a lot of things and change a lot of my codes?

Where does DRF stand, is it in the backend of frontend or is it more of like in the middle. How does it integrate into my current IT architecture: with django as backend, htmlcssjs as frontend and postgresql as database

Thank you!
Also if anyone is kind enough to share resources about DRF/ open to a short zoom sharing session on DRF, please feel free to contact at firstname.lastname@example.com
Comment: Do you need a REST api to your project? If not you don't need DRF.
Comment: What determines if I need a rest API? Also, if assuming I need,where does DRF stand and the difficult of implementing it in?
Answer: The idea of Django Rest Framework (DRF) is to simplify and cut down a lot of code from your Backend (aka API).
Django (standalone Django, not DRF) is a framework that allows you to build Backend (and also Frontend).
DRF is a cool library that allows you to create a backend with Django but a lot easier.
DRF allows you to create endpoints that allow you to manipulate the Data (ie. models) very quickly and with very little code.
The "Serialization part" of DRF just automatically (also magically) transforms your models data into a response (usually json) for the client and vice versa.
It does take some learning and coding to transform your current backend into DRF. but in my opinion unless you backend is really special, DRF can allow you to create an awesome API with very little code


If your login is an email, should you canonicalize/lower-case it?

Question: A lot of sites today don't have a username, just a "login email".
If a user opened an account as email@example.com, and are now trying to login using email@example.com - should we accept this login as true? Should we just convert the email to lower case before storing and validating it?
Answer: Yes, you should accept it as a login but internally lowercase it to rule out matching problems in your database and to ensure you don't have unintended duplicates. If the user makes a typo or simply prefers to write email@example.com, why not go ahead and let them? It doesn't affect you if you don't let it. :-)
Gmail does something similar. You can register an email address with a . in it and Gmail just ignores that for its internal email address. So you can get firstname.lastname@example.com and that's effectively the same email address as email@example.com. Back in 2004 when Gmail launched, I found this to be an especially user friendly feature of their email service and few competing services have yet to implement it themselves.
The important lesson here is that you shouldn't allow your internal application architecture to surface to the end user unless it benefits them in someway. If you can keep it invisible, do it.
Edit: concerning case sensitivity, here's what About.com has to say:

But Case Typically Does Not Matter
Since the case sensitivity of email addresses can create a lot of confusion, interoperability problems and widespread headaches, it would be foolish to require email addresses to be typed with the correct case. Hardly any email service or ISP does enforce case sensitive email addresses, returning messages whose recipient's email address was not typed correctly (in all upper case, for example).
This means that

it does not typically matter what case you type an email address in when you send a message
(If the recipient did give you an email address with distinct case, preserve it, however.)
and you should always only use lower case characters when creating a new email address to rule out any confusion.

So if you want to comply with the email RFC, don't follow my advice. If you know what email addresses will be used in your system (for instance, for an intranet for your company), I would just lowercase everything.
Comment: Why lowercase the email? If you need to show it you would not be displaying the case that they recognise.  According to your own reasoning you should keep your functionality invisible, so why not store the case they entered but make your checks (and uniqueness) case insensitive?
Comment: From a pure 'User Experience' point of view I would totally agree. Otherwise you'll have to label all the email fields with 'Caution: This is CASE SENSITIVE' and other such instructions that would annoy the user. Also, I believe that RFC 5321 is trying to discourage sensitivity of case anyway: http://tools.ietf.org/html/rfc5321: "However, exploiting the
   case sensitivity of mailbox local-parts impedes interoperability and
   is discouraged.  Mailbox domains follow normal DNS rules and are
   hence not case sensitive."
Comment: Case is rarely a matching issue in databases; every common SQL engine comes with case sensitive matching off by default. There's still no reason I can imagine to store it case sensitive though; for displaying the email I'd just always lowercase it and not sweat what the user enters in though.
Answer: Sounds like this question has mixed results.  The de facto standard is to treat local mailboxes as case insensitive, but the official standard says case matters (though even the official standard mentions the de facto standard).
As other people have pointed out, it is possible that email@example.com and firstname.lastname@example.com are two different people, and both of them want to use your site.  But on the other hand, it is far more likely that email@example.com and email@example.com are in fact the same person.  If they type it one way one time, and another way another time, you probably want to let them in either way.
I'd suggest keeping track of both.  Since using case insensitivity is so widespread, take their sign up email address and make it lower case.  Whenever they try to log in, convert that to lowercase as well, for comparison purposes, when you go to see if the user exists.  As far as sign up and sign in go, do a case insensitive comparison.  If the person signs up as email@example.com, you'll still want to allow them to sign in later with firstname.lastname@example.com or email@example.com.
But you should also keep track of the email address that they signed up with in a case sensitive fashion.  Any time you send an email to them, be sure to send it with that original casing.  This allows the email server to handle it however it feels like it needs to.  So even though the person may always be signing in to your site with email@example.com, if they signed up as firstname.lastname@example.com, you'll always send email to firstname.lastname@example.com, just to be safe.
Some day, the de facto standard and the official standard will hopefully be the same.  It's too bad we have to deal with this issue at all.
A couple of related side notes.  The domain name (after the '@' sign) is always considered case insensitive, so you can always treat that in the same way.  Second, just as important as the case sensitivity issue, you want to also be sure your site accepts all legal email addresses, which includes allowing all symbols that are allowed in email addresses.  It is really frustrating for users who enter their legal email address, only to have the system say "the character '!' is not allowed."  The standard defines what is allowed, but Wikipedia also has a good summary of this.
Comment: This answer is the closest to what the standard actually requires of SMTP servers - "The local-part of a mailbox MUST BE treated as case sensitive. Therefore, SMTP implementations MUST take care to preserve the case of mailbox local-parts."  The system can do whatever it wants to for login ids (and should probably ensure unique case insensitive ids), but if the system is going to use the email address to send via SMTP then it MUST preserve the case.
Answer: No. The local part of an email address must be treated as case-sensitive.
For example, email@example.com and email@example.com could specify different mailboxes. If you converted the email to lower case, firstname.lastname@example.com would be unable to use your site. Also, if a firstname.lastname@example.com mailbox existed, it would receive any emails your site should have sent to email@example.com.
After firstname.lastname@example.com had created an account, one could create a email@example.com email account at the same mail service and use a password reset to use firstname.lastname@example.com's account at your site.
Comment: Technically true although it also goes on to say *However, exploiting the case sensitivity of mailbox local-parts impedes interoperability and is discouraged*. Thus providing case insensitivity would be the desirable course of action, while *enforcing* the case sensitvity would be just unnecessary.
Comment: @Roger Attrill See my edits about how one could reset the password of an account whose login/email address had upper case characters in a case-sensitive mail service.
Comment: This could be a good reason to reject the "login email" concept. Another would be that it enforces "one account per email" as a technical matter without considering whether this is a desired policy or not.
Answer: No
I would never do that -- cannot say all mail IDs are going to stay case-agnostic. At some point you may have to rework the logic, and anything else dependent on it, if things do change.


storing objects in hazelcast

Question: I am trying to store my object in Hazelcast map but its not working. It creates a new instance which i am able to see in console and mancenter as well. It also creates the map but it has nothing inside. Also, System.out.println (accountMap.get()) prints nothing.
I even tried by doing a put operation with simple string, still same result.
Here is my code:
userAccount user = new userAccount();
user.name = "pras";
user.pass = "12345";

HazelcastInstance instance = Hazelcast.newHazelcastInstance (new Config());
                Map<Integer, userAccount> accountMap = instance.getMap("userMap");
                accountMap.put(1, user);
                System.out.println (accountMap.get(1));

Comment: please share some logs
Comment: also share the Hazelcast config xml you had used.
Comment: did you find the reason
Answer: Given:
    package com.hazelcast;
import java.io.Serializable;

public class userAccount implements Serializable {
    String name;
    String pass;
}

And your code from above, I get the following output:
INFO: [192.168.1.70]:5701 [dev] [3.8.1]

Members [1] {
    Member [192.168.1.70]:5701 - f8f3cf77-9b02-48b7-8a61-f353c40a6267 this
}

Apr 21, 2017 3:19:28 PM com.hazelcast.core.LifecycleService
INFO: [192.168.1.70]:5701 [dev] [3.8.1] [192.168.1.70]:5701 is STARTED
Apr 21, 2017 3:19:28 PM com.hazelcast.internal.partition.impl.PartitionStateManager
INFO: [192.168.1.70]:5701 [dev] [3.8.1] Initializing cluster partition table arrangement...
com.hazelcast.userAccount@70ab80e3

Hope this helps

storing objects in hazelcast


How to deselect all other's positions value on recycler view item click?

Question: I have written following code to change background of selected item from recyclerview click :
<code> @Override
    public void onBindViewHolder(final ProductAdapter.CardViewHolder cardViewHolder, final int position) {

        final Product product = mProduct.get(position);

        cardViewHolder.pName.setText(product.getName());

        cardViewHolder.cardProduct.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                product.setSelected(!product.isSelected());
                cardViewHolder.view.setBackgroundColor(product.isSelected() ? getContext().getResources().getColor(R.color.blue) : Color.red);
            }
        });

    }
</code>
Now this is working. When i click on recycler view item then its change background color but i want like When i click on any particular item from recyclerview then all other item must be deselect and change their background to red.
I just want to give sing selection option.
How can i do this ?
Answer: Use a variable to keep an index of the selected element.
e.g:
<code>@Override
public void onBindViewHolder(final ProductAdapter.CardViewHolder cardViewHolder, final int position) {

    final Product product = mProduct.get(position);
    cardViewHolder.pName.setText(product.getName());

    cardViewHolder.cardProduct.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            selectedItemId = product.getId();
            notifyDataSetChanged();
        }
    });
    if(product.getItemId()== selectedItemId )
            ((CVH)holder).itemView.setBackgroundColor(getResources().getColor(R.color.colorAccent));
        else
            ((CVH)holder).itemView.setBackgroundColor(Color.WHITE);
}
</code>
Answer: Try this:
<code>@Override
public void onBindViewHolder(ProductAdapter.CardViewHolder cardViewHolder, final int position) {

    Product product = mProduct.get(position);

    cardViewHolder.pName.setText(product.getName());

    if (product.isSelected()) {
        ardViewHolder.view.setBackgroundColor(context.getResources().getColor(R.color.blue));
    } else {
        ardViewHolder.view.setBackgroundColor(context.getResources().getColor(R.color.Red));
    }

    cardViewHolder.cardProduct.setTag(position);
    cardViewHolder.cardProduct.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int pos = (int) view.getTag();

            for (int i = 0; i < mProduct.size; i++) {
                Product product = mProduct.get(i);
                if (i != pos) {
                    product.setSelcted(false);
                } else {
                    product.setSelcted(true);
                }
            }
            notifyDataSetChanged();
        }
    });
}
</code>


Recovering my Clash of clans and save to other device

Question: I want to recover my clash of clans that connected to facebook. And i will save it to google play store. But I dont know how.
Comment: http://gaming.stackexchange.com/questions/192516/can-clash-of-clans-be-linked-with-facebook-account?rq=1
Answer: Clash of clans is not connected to your facebook. Your data is only covered by Game Center (iOS) or Google Play Store/Games (Android). You can always contact Supercell through Help and Support in the settings (cog icon above Shop button). Provided by your problem/issue, your in-game name, etc. describing your account. Don't worry, Supercell will asked more questions regarding your account for recovery.


How to create listing screen with image in android

Question: I'm working on android mobile app.(I'm new to this field )
I'm having trouble in creating listing screen with image, (as in image) any help would be appreciated. Thanks in advance
Below is my code
<code> <ImageView
    android:id="@+id/img"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"/>

<TextView
    android:id="@+id/name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/img"
    android:layout_toRightOf="@+id/img"
    android:textStyle="bold" />

<TextView
    android:id="@+id/dist"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/name"
    android:layout_gravity="center"
    android:layout_marginTop="2dip"
    android:layout_toRightOf="@id/img"
    android:gravity="right"
    android:textSize="8dp"
    android:textStyle="italic" />
</code>
Comment: whats your problem?? and what you have done so far??
Comment: what you have done to do this. and what is your problem.
Answer: Actually there is a lot going on so I recommend you to check this tutorial http://www.javacodegeeks.com/2013/06/android-listview-custom-adapter-with-imageview.html


Sink drain pipe leaking

Question: I recently replaced my bathroom sink and the new drain pipe isn't threaded like the older one.  So instead of a connection to the P trap with a threaded male/female piece and a tightening ring, the new drain simply slides into the P trap piece.  This is where the leak is happening.  I tried to use silicone to seal the open space but if running the water on a higher pressure, or if soap is used, the leak is immediate.   What is the best way to eliminate the leak?  Help!
Note: Both new and old piping is PVC.
Comment: Best way to eliminate the leak  is use the right size pipe. I believe there may be an adapter to mate the two different size pipes. Someone will post what piece you need to correct this, in addition it's not lined up very well.
Answer: These compression fit plumbing pieces need to fit together very straight to get a good seal.  Try to adjust all the joints to be as straight as possible.  Because each joint can either slide or rotate, this is normally possible to do without much effort.
Also, many bathroom sink drains use 1 1/4" pipe, but many P traps and the pipes coming out of the wall are 1 1/2".  It's a small difference, but it matters to make a proper seal.  Most P-trap kits these days come with an adapter washer that is thicker than the normal 1 1/2" washer.  It may have gotten lost in the packaging, or you may not have gotten one, but they are sold separately and are normally very cheap.
Answer: You've got what looks like a 1-1/4" tailpiece going into a 1-1/2 trap adaptor. With that type of pipe (white stuff) it may be difficult to find a fitting that allows you to reduce the size to 1-1/4. Your best bet is is to take the compression ring from the trap adapter and the tailpiece to the hardware store and replace the tailpiece with one that fits both your sink and the trap adapter.
This picture shows the components of a sink drain.
http://dogepay.me/sink-stopper-parts/sink-stopper-parts-sink-pop-up-stopper-bathroom-sink-drain-stopper-parts-small-images-of-parts-of-bathroom-sink-delta-bathroom-sink-stopper-replacement/
I would suggest changing all the white pipe but that may lead to more trouble. Adapting the tailpiece is your best bet. You may have to change the basin as well depending on how deep of a product line your hardware store carries.

Sink drain pipe leaking


JSF external linking

Question: I was wondering if is it possible to external link - something like domain.tld/jsfview - to a specific jsf view/page.
I don't want the start page of my jsf app, which would be triggered by
 <navigation-rule>
  <navigation-case>
   <from-outcome>start</from-outcome>
   <to-view-id>/jsf/index.xhtml</to-view-id>
  </navigation-case>
 </navigation-rule>

Tried this config
 <navigation-rule>
  <navigation-case>
   <from-outcome>reminder</from-outcome>
   <to-view-id>/jsf/remind/index.xhtml</to-view-id>
  </navigation-case>
 </navigation-rule>

But I only getting a redirect to my startpage.
I forgot one important thing to mention: The JSF app is running in a portal enviorment with the jboss portlet bridge
Comment: check the logs for any messages
Comment: already done - there are no messages
Comment: If you're thinking in terms of pages and you're using portals, you're doing it wrong.
Answer: I'm not sure what you mean. Do you mean, you want to link from an external site to a page in your JSF application?
In your example, you could link to /jsf/remind/index.faces (or whatever extension you have the JSF servlet mapped as) and it should load up your page.
Not sure if I have misunderstood you though!
Comment: You got me right Phil - link to a specific page in my JSF app. Thats my problem: it doesn't load the page. I only get my start page
Answer: I've found the solution due my JSF app is in a portal enviorment used with a portlet bridge, there seems no way to link to a JSF page directly.
I solved my problem with a workaround - sure this may not fit other similiar problems:
I'm using the porlet modes to direct linking the page from outer sources.
 <init-param>
   <name>javax.portlet.faces.defaultViewId.edit</name>
   <value>/jsf/remind/index.xhtml</value>
 </init-param>

Don't get me wrong: If I'm in my JSF app <h:outputLink /> everything works as excepted.
Answer: The init parameters javax.portlet.faces.defaultViewId.[mode] can be used to set the initial view for each mode.
You can probably create a bookmarkable URL to a different view utilising FACES_VIEW_ID_PARAMETER ("_jsfBridgeViewId" - assuming JSR 329; I haven't looked at JSR 301).

JSF external linking


How can I take apart this kind of tap to replace the washer?

Question: I need to replace the washer on this tap as it keeps leaking.
The tap design seems quite similar to the one described here, but it seems the middle section cannot be turned (it's completely round, doesn't have any nut ridges).
Can this model be taken appart?

The top cap seems to have some notches to be able to turn it, but I think it's actually fused to the handle. Maybe it needs lot of WD40?

Update:
With lots of fiddling around, the top came off by turning (didn't pry up), so those notches actually helped.

Now, I think the cover should come out by spinning, but there is no way to grab hold to spin it. The tiny notch seems to be more likely a defect, or maybe made by some previous guy attempting to fix it. It's not deep enough to insert a screwdriver to help spin it.
Any ideas on how to proceed next?
Comment: Those notches are decorative, not meant for turning.
Comment: Thanks, @TheEvilGreebo, but I managed to get the cap off, any ideas next?
Comment: Follow the rest of the steps in the tutorial you linked to. Next remove the "fancy part of the tap" by turning it anti-clockwise...
Comment: @Tester101: I know that's the next step, but I can't grab hold of it to spin it.
Comment: Try [Tongue and groove Pliers](http://en.wikipedia.org/wiki/Tongue-and-groove_pliers). Wrap the "fancy part" with a rag (so you don't scratch it), and don't squeeze too hard (or you could deform it). Or grab it with one hand, then use your other hand to add torque by turning your first hand. Or give it a blast of [Penetrating oil](http://en.wikipedia.org/wiki/Penetrating_oil), and let it sit for a bit.
Answer: The top cap should simply pry up from the knob.  Then under the cap you should find a screw you can remove to release the handle and access the valve stem.
Shut off the water first, of course. :D
Comment: now the top section will screw off, you will have to use a wrench, be carefull not to damage the copper finish, protect by using a cloth between the grips and the brass cap.. Minor scratches will show excessively now,will blend in over time
Comment: Thanks, your answer made me try it harder, and I managed to take off the cap, only it was actually screwed in. Any ideas next?
Answer: As discussed in answers and comments, channel pliers or locking pliers can be used to remove the screwed down cap that hold in the stem (the grooved top of which you show). As indicated, tape or a cloth may reduce the chance of damaging the finish. A wide, thick rubber band is also useful in gripping under pliers to avoid scratches.
An alternative is a strap wrench.

It can be used for this purpose and also to turn or hold pipes.


How do I find out why my phone is incompatible with a game?

Question: When I try to install some Android games, the Google Play site says they are not compatible with my phone, without stating the specific reasons. How can I find out what about my phone is incompatible?
Comment: It could be any number of reasons, probably your phone is running a version of Android that is incompatible with the game (too old or too new), or your phone does not have certain hardware that is necessary for playing the game.
Comment: Whatever game you're looking at should have requirements listed on the app page.
Comment: If you feel lucky, you can try [forcing the apps to install](http://www.howtogeek.com/116456/how-to-install-incompatible-android-apps-from-google-play/).
Comment: @fredley Seems a useful link.
Comment: For what it's worth, when I had an HTC Wildfire (original one), that had a very low resolution, that was typically the reason for incompatibility.
Comment: I have checked my Android version (2.3 Gingerbread), that is OK with the mentioned games. The problem is how to find out the actual reasons? Say, I am going to get another phone, how to make sure these games will run or not?
Answer: I'm an android developer for work and all I can tell you is that we have to deal with very different devices running the same android version. Dealing with a cheap device, with poor graphic support, not enough memory and low res, to publish a 3D game (example) is very annoying.
We have to deal with so many things already, that we set a base limit. If our game is designed to be at least 800x600, any device with less than that resolution won't be able to play the game. It's just easier than trying the impossible.
Try this example: why should a game that uses gps be installed on a device without gps? You may say this is an extreme example, but for us developers the same applies to lower-level limits (coding/design related)
See this link to understand how we limit things and what you can do to filter apps in the playstore
Comment: As much as I like this answer, you haven't addressed the base question at all, which is how to find out if you can play the game or not.
Comment: @Samuele Mattiuzzo Why can't the Google play store state something (with reasons) like "You can't install this game because your phone does not support GPS"?
Comment: It's true that you can't change your phone's video card, or give it a GPS when it doesn't have one, but if you knew what about your device makes it incompatible with a particular app, you **could** use that information to inform your decision on what device to buy next time. If I knew that the issue was needing Android version XYZ, I might just wait for an OTA update. If I knew I needed a minimum resolution display, I'd compare those specs the next time I shop. If I knew I just needed >= 2GB RAM, I'd know I could be fine with just a midrange upgrade rather than needing an S7
Comment: As i stated in the end, you can filter them out on the play store or buy a compatible phone. It's almost impossible to fix any compatibility issue. "if you can play it" --> you already know it when you enter the play store... "why" --> you can't know, actually (ask the dev maybe? but they probably can't help... there's so much different hardware around, we need to put restrictions... on the ios side it's easier, 3 ipad versions and 2 different resolutions...)
Comment: @DUKE I don't know exactly. Maybe because it would be impossible anyway for you to fix that (you can't change the video card) so it's pointless
Comment: Yeah, correct. The real problem here is how free-form the app stores are, there's no real way of filtering based on what your device is (eg: could by default hide all the incompatible apps, same way as they hide those not available on your region). It's all dealt in a "we chuck them apps in a bin, you just pick one" kind of way, which is all but ideal. Far from it...
Comment: @SamueleMattiuzzo That and the fact that the store simply doesn't filter right, when it's certain hardware issues.  I have an old ASUS TF101 that I wanted to play some games on, for a larger screen.  2 of them could not be installed because the store blocked me.  1 Worked.  The other 5 installed, but could not be run due to processor architecture issues (One of the apps simply wouldn't run, and the other 4 popped up with the architecture error, upon launch.)
Answer: It may be for 2 reasons :

Hardware Incompatibility
Outdated Software

If your Software is outdated, then a pop-up will tell you that you are running too old an version for the app when you click 'Download'. Now, you may or may not be able to download a newer version of android.
Otherwise, it must be Hardware Incompatibility, and you can't do anything about it (short of buying a new phone).


How to disable production/research recommendations in Civilization IV BtS?

Question: Is there a way to turn off the adviser's recommendations for research plans and city production?
I already disabled the Sid's tips and tutorial advice in game settings, but the two 'recommended' technologies or units/buildings still pop up at the top of the research/production list. This at times can be really disturbing, as it frequently attracts me to discover technology I currently don't need or changes the order of units/buildings displayed in city production menu, making some units apparently 'disappear'.
Just note I play Civilization IV: Beyond the Sword, if that matters.
Thank you in advance.
Answer: As far as I know, there isn't. You should just learn to ignore it completely, no other way apart from moding.


Changing KML polygon color over time?

Question: I wrote a program that periodically outputs KML files.  These files contain a grid of polygons, always with the same  spatial coverage.  I want to use the polygon's fill color to represent a data values for each grid cell.  I know how to set the fill color of the polygon with the Style tag.  Is it possible to change to polygons color over time using the TimeStamp or TimeInterval?  If not, is there a way to hide an "old" polygon and draw a "new" polygon at the same location, but with a different color?  Is there a better way to represent a grid that has data value for each cell, like a Ground Overlay?
Comment: I think my answer below still stands - most of what you are asking requires programatic control over the UI (eg. the google map) do you have this? (I.e. is some third party loading you KML outside of your control, or are your users viewing it on your website? - as an example.) More details on what you are attempting to accomplish can help others provide a better answer.
Answer: For changing the polygon color, you need to use 3rd party kml parsers like geoxml3.
see this,
changing the color of Polygons from KML rendered using geoxml3 on mouseover

Changing KML polygon color over time?


Algorithm or requirement behind Bowtie?

Question: BOWTIE maps test reads to a reference genome.
Basically it's a String comparison.
Reference String could be a million base pair made by combinations of A C T & G, also the test reads,
Now what is the criteria to call a test read as match, mutation, SPM mismatch, cigar etc
I am thinking in a perspective that, if I have to write my on BOWTIE in the language I like, what must be the test read, reference genome comparison rules I need to follow.
Comment: You may gain some insight from the original Bowtie [paper](http://genomebiology.com/2009/10/3/R25).
Comment: @H2CO3, I am talking about an executable, not the one around any body's neck. Please read b4 u write
Answer: Bowtie has two main alignment modes: -v mode and -n mode.
-v mode doesn't care about quality scores while -n cares for the seeding region.
Bowtie requires you to specify the maximum number of mismatches you allow and the maximum number of locations each read can map to. Bowtie2 considers gaps.
BTW, the reads not only contain ACGT but also N's.

Algorithm or requirement behind Bowtie?


What is the !=~ comparison operator in ruby?

Question: I found this operator by chance:
ruby-1.9.2-p290 :028 > "abc" !=~ /abc/
 => true

what's this? It's behavior doesn't look like "not match".
Comment: Doesn't seem to be a real operator. most likely it's `!`  and `=~`
Answer: That's not one operator, that's two operators written to look like one operator.
From the operator precedence table (highest to lowest):

[] []=
**
! ~ + - [unary]
[several more lines]
<=> == === != =~ !~

Also, the Regexp class has a unary ~ operator:

~ rxp → integer or nil
  Match—Matches rxp against the contents of $_. Equivalent to rxp =~ $_.

So your expression is equivalent to:
"abc" != (/abc/ =~ $_)

And the Regexp#=~ operator (not the same as the more familiar String#=~) returns a number:

rxp =~ str → integer or nil
  Match—Matches rxp against str.

So you get true as your final result because comparing a string to a number is false.
For example:
>> $_ = 'Where is pancakes house?'
=> "Where is pancakes house?"
>> 9 !=~ /pancakes/
=> false
>> ~ /pancakes/
=> 9

Answer: !~ is the inverse of =~ NOT !=~


How to install mcz file to squeak?

Question: I'm squeak beginner. And I want a help about library install on squeak.
in squeaksource.com, there are libraries that I want to install
but when I execute
<code>(Installer ss project: 'WebClient')
    install: 'WebClient-Core';
</code>
I failed to install for network problem.
So I download mcz file to pc, but I don't know how to install that mcz file to squeak.
Would you let me know how to handle mcz file??
ps. thanks for reading my poor english. If you feedback wrong english expression, it also very helpful for me.
Answer: you can also just drag and drop the mzc file into the image, and when the popup appears you choose "file in".
cheers
Answer: Squeaksource (the code repository you were trying to access) was probably was down. It happens. Your script was fine, though (apart from the trailing ';').
Try
<code>(Installer ss project: 'WebClient') install: 'WebClient-Core'
</code>
or
<code>MczInstaller installFileNamed: '/path/to/WebClient-Core-ar.89.mcz'
</code>
Comment: b.t.w. I would've assumed you could load your downloaded mcz file via the "file list" tool or programmatically via "MczInstaller installFileNamed: '/Volumes/Fast/Squeak/Fresh Images/Squeak4.2 Final/package-cache/WebClient-Core-ar.89.mcz'", but neither seems to do the right thing (may be a bug).
Comment: MczInstaller installFileNamed message was work!!!! I successed to install libraries for your help. thanks a lot. My netwrok problem seems related to firewall condition of my office.

How to install mcz file to squeak?


Invalid Column Error while using dynamic SQL

Question: I am attempting to use dynamic SQL for the first time. There are two sets of SQL to execute based on conditions. When trying to Execute @sql4 the Else part executes fine with no errors. However the first part of SQL throws an error:

invalid column/The multi-part identifier "tp.Acquisition Date" could not be bound

The dynamic SQL used in both cases is the same and somehow the first part throws an error saying tp is not recognized which is the nothing but an alias name for Temp.property table.
Declare @SQL4 NVARCHAR(MAX)
SELECT @sql4=

     'CREATE TABLE dbo.DIM_PROPERTY (' + Stuff(
      (SELECT N', ' + Concat(Column_Name, ' ', ColDT) FROM #TempProp
       FOR XML PATH(''),TYPE)
      .value('text()[1]','nvarchar(max)'),1,2,N'') + ');'
        +
        'IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES
                 WHERE TABLE_SCHEMA = ''TEMP''
                 AND  TABLE_NAME = ''PROPERTY''))
      BEGIN ' +
      'INSERT INTO dbo.DIM_PROPERTY  ('+ Stuff((SELECT N', ' + Column_Name FROM #TempProp
        FOR XML PATH(''),TYPE)
      .value('text()[1]','nvarchar(max)'),1,2,N'') + ') ' +'Select ' + Stuff(
      (SELECT N', ' + Concat(TblAlias,Column_Name)  FROM #TempProp
      FOR XML PATH(''),TYPE)
      .value('text()[1]','nvarchar(max)'),1,2,N'') +
    ' from (select imp.PROPERTY_MINI.propertyID as PropertyKey,* from imp.PROPERTY_MINI) mp
    join Temp.PROPERTY tp on tp.PropertyKey = mp.PropertyID
    left join imp.PROPERTY_PHOTO_VIEWER pv
    ON mp.PropertyID = pv.PropertyID

        END

        ELSE
        BEGIN
        INSERT INTO dbo.DIM_PROPERTY  ('+ Stuff((SELECT N', ' + Column_Name FROM #TempProp
        FOR XML PATH(''),TYPE)
      .value('text()[1]','nvarchar(max)'),1,2,N'') + ') ' +'Select ' + Stuff(
      (SELECT N', ' + Concat(TblAlias,Column_Name)  FROM #TempProp
      FOR XML PATH(''),TYPE)
      .value('text()[1]','nvarchar(max)'),1,2,N'') +
    ' from (select imp.PROPERTY_MINI.propertyID as PropertyKey,* from imp.PROPERTY_MINI) mp
    left join imp.PROPERTY_PHOTO_VIEWER pv
    ON mp.PropertyID = pv.PropertyID
    END'
        exec sp_executesql @SQL4;

Comment: replace `exec sp_executesql @SQL4;` by `select  @SQL4`. this way you will be able to check your SQL statement.
Comment: I suggest `PRINT`ing or `SELECT`ing the value of your Dynamic Statement and debugging that; then propagate that fix to the SQL that creates it. I also suggest properly quoting your dynamic object names with `QUOTENAME`.
Comment: Hi Priya - welcome to Stack Overflow.  You may attract better answers to this question by including a [MCVE].
Comment: Sure, added the sql to show the error in more detail. Please review and comment.
Comment: Looks like when you get to your `else` condition, you only have two tables, aliased as `mp` and `pv`.  That's why you're getting an error trying to select from a tabled aliased as `tp` in that section.
Answer: I think you got your answer by APH in the comments.  And you got further advice by Luuk and Lamu with respect to converting sp_executesql @sql4 to select @sql4 or print @sql4, copying the result into an editor, and reviewing the error message there.
But I would further recommend that you build your inserts into the dynamic statement outside of the statement itself:
declare

    @col_types nvarchar(max) =
        Stuff((
            SELECT N', ' + Concat('[' + Column_Name + ']', ' ', ColDT)
            FROM #TempProp
            FOR XML PATH(''),TYPE
        ).value('text()[1]','nvarchar(max)'),1,2,N''),

    @cols nvarchar(max) =
        Stuff((
            SELECT N', ' + '[' + Column_Name + ']'
            FROM #TempProp
            FOR XML PATH(''),TYPE
        ).value('text()[1]','nvarchar(max)'),1,2,N''),

    @col_aliases nvarchar(max) =
        Stuff((
            SELECT N', ' + Concat(TblAlias,'[' + Column_Name + ']')
            FROM #TempProp
            FOR XML PATH(''),TYPE
        ).value('text()[1]','nvarchar(max)'),1,2,N'');

Also note that I wrapped any column_name in brackets, which may resolve another problem, given that 'Acquisition Date' has a space in the name.
Then insert them as variables:
declare @SQL4 NVARCHAR(MAX) = '

    CREATE TABLE dbo.DIM_PROPERTY (' +  @col_types + ');

      IF (EXISTS (
          SELECT * FROM INFORMATION_SCHEMA.TABLES
          WHERE TABLE_SCHEMA = ''TEMP''
          AND  TABLE_NAME = ''PROPERTY''
      ))
      BEGIN

          INSERT INTO dbo.DIM_PROPERTY  (' + @cols + ')

          Select ' + @col_aliases + '
          from (select imp.PROPERTY_MINI.propertyID as PropertyKey,* from imp.PROPERTY_MINI) mp
          join Temp.PROPERTY tp on tp.PropertyKey = mp.PropertyID
          left join imp.PROPERTY_PHOTO_VIEWER pv ON mp.PropertyID = pv.PropertyID

      END
      ELSE
      BEGIN

          INSERT INTO dbo.DIM_PROPERTY  (' + @cols + ')
          Select ' + @col_aliases + '
          from (select imp.PROPERTY_MINI.propertyID as PropertyKey,* from imp.PROPERTY_MINI) mp
          left join imp.PROPERTY_PHOTO_VIEWER pv ON mp.PropertyID = pv.PropertyID

      END

     ';

With this approach, you have a little more chance of avoiding or catching errors as you write the code (for instance, it is easier to see that the second query is missing a join statement that the first has).  And it is more clear what the 'big picture' intent is of your entire query.


Unlocalized SC2 version for localized server

Question: Can I use the English version of Starcraft 2 to play on a localized server (for example Russian)?
If yes what should I do for it? Where can I download an English version of Starcraft 2?
Answer: If you're asking if you can play the English version of Starcraft 2 on a non-English server (eg. SEA), then the answer is: No.
If you're asking if you can play the English version on a non-Blizzard server, that question is beyond the scope of gaming.se and you'll have to go else where for an answer.
Comment: You should mention that it's "beyond the scope.." because it's illegal (or at least against the ToS)
Comment: I'm asking about blizzard servers :(
Comment: @Sly sorry I couldn't tell from your phrasing
Answer: You cannot play the game in a region where a certain language is not available when you purchase it.
I had that very same problem, and after a lot of mail exchanges with blizzard support, the asked me to post the request in the forums, and so I did.
You can show your support in that thread and in the many others about the same topic, and perhaps someday it'll be possible.


Ubuntu won't boot without external hard drive connected

Question: I am dual booting ubuntu and windows 10 on my laptop. I recently installed the plex server and followed the instructions on this link to fix a permissions issues I was having. Now however, ubuntu will not boot unless the hard drive is plugged in. When it is not plugged in, the purple ubuntu screen comes up and then goes to a black screen that says "welcome to emergency mode". I try pressing ctrl-D to continue but it just goes back to the emergency mode screen.
Thanks in advance!
Comment: Did you put the external hard drive in /etc/fstab?
Comment: What is on that external hard drive? Ubuntu seems to think it needs something from it. Is it automounting it?
Answer: Funny you ask, because I saw that today in our lab just today.
Drives are lettered in the order they are found, sda, sdb, and so forth. Those letterings can be shifted when new devices are inserted. If the old config is looking for a partition in a place, but it finds MS Windows instead, for example, then blam!
If you put settings in /etc/fstab using drive letters, then the setup is fragile because the letters change when something is unplugged. I saw exactly the error you describe.
If your /etc/fstab file uses UUID names for devices, this won't happen. Know what I mean?  Use this sort of entry, rather than one that begins /dev/sdXX:
<code>UUID=bc9f628b-8ad3-4cff-910b-d1ee751c4790 /boot           ext2    defaults        0       2
</code>
If you start the working system, then run
<code>$ /sbin/fdisk -l
</code>
to list the drives.  I'm assuming you have old style partitions.  If you have GPT, problem is likely same, but details differ.


mongo db $push finding maximum number of something

Question: i wanted to write pipleline code, that gives me the 5 users with the most tweets, i tried to use $push, i looked up the mongo db documentation and it also showed $sort. I get an syntax error on the text line, but atleast to me it is not an obvious one.
Would be really nice if someone could point me in the right direction, since i watched some videos and read pages, but did not find what is wrong with my code.
pipeline = [
            {"$group" : {
                        "_id": "$user.screen_name",
                        {
                        "$push": {"texts" : "$text"}},
                        {
                        "$sort" : {"texts":-1}}},
                        {
                        "$limit" :5}}

            ]

Comment: Hello Stephan. We all hope that the answers you find here on StackOverflow are useful to you. If it is so, please remember that [you _should_ vote up and/or accept those answers](http://stackoverflow.com/help/someone-answers). Accepting is especially important as this will mark the question as "answered" and will provide feedback about how you solved your issue to other users coming to this question from the Internet.
Answer: This aggregation pipeline document gives you a very good structured way on how aggregation works, with examples.
And as per your question, you are asking the same things more than once.
Anyway, in your query $group should not contain $sort and $limit check syntax, and $push is placed wrongly $push syntax. So your aggregation query should be as below:
pipeline = [{
  "$group": {
    "_id": "$user.screen_name",
    "teet_data": {
      "$push": {
        "texts": "$text"
      }
    }
  }
}, {
  "$sort": {
    "texts": -1
  }
}, {
  "$limit": 5
}]

Comment: @SylvainLeroux Sorry for the misunderstanding, that was meant for the answerer as the OP has never accepted any previous good answers on questions which are somehow related :P
Comment: @StephanKetterer it would be a good idea to go through your old questions and accept those answers that have helped you now you know how - will help to keep a good name on the site :)
Comment: Sorry, I've never used aggregation pipeline of MongoDB. What is `"teet_data"` ? Is it an arbitrary name for the result "record" ?
Comment: Good luck with getting your valid answer accepted ;)
Comment: @SylvainLeroux yes `tweet_data` is an arbitrary name
Comment: @chridam Thank you for explaining that. Did I mention that I'm not the OP? ;)
Comment: Honestly i did not know about accepting the answer or how someone does it. Now i know and will do it of course from now on. Thank you for explaining it to me !
Answer: "I wanted to write pipleline code, that gives me the 5 users with the most tweets"
I can't say if this is an improvement over @yogesh' answer, but given your description, you only need to count the tweets. Not to pass them all along your pipeline. At the very least, using a $sum would be much more memory efficient:
pipeline = [{
  "$group": {
    "_id": "$user.screen_name",
    "count": { "$sum": 1 }
    }
  }
}, {
  "$sort": {
    "count": -1
  }
}, {
  "$limit": 5
}]


How to tell number of rows changed from JDBC execution

Question: I'm uncertain as to how to get the number of rows affected from a SQL execution.
I do like this:
boolean isResultSet = statement.execute(arbitrarySQLCommand);

and I can get the number of rows affected from the getUpdateCount() method. That is all fine. The problem I have is when update count is zero. This can either mean:

It was a DML statement but it didn't affect any rows. Zero rows affected is a valid response. I just means that some condition was not met.
It was a non-DML statement (DDL statement most likely) .. which by definition does not change rows so therefore update count is always zero (duh!). Or to put it another way: The concept of update count is meaningless for such statements.

What I would like is to be able to distinguish between situation 1 and 2 above. How?
I'm not interested in statements that produce output so I could also use executeUpdate() but as I see it the return value from that method has the same flaw:

Returns:
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing

Arghhh!
I wish it was:

Returns:
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) -1 for SQL statements that return nothing

(note: I do not know the contents of arbitrarySQLCommand beforehand)

Final chosen solution
There just doesn't seem to be a true JDBC-like solution to the problem. In my mind the designers of JDBC has made a serious mistake on the getUpdateCount by using the value 0 (zero) to signify a statement that doesn't (by definition) affect rows because zero rows affected is also a perfectly valid value for the outcome of a DML statement.
The only possible solution seems to be to do some kind of pattern matching on the SQL statement to figure out if it is a DML statement (INSERT,UPDATE,DELETE) or another type of SQL statement. Something like this:

Extract first word from arbitrarySQLCommand. A word is terminated
by either a whitespace or a EOL line char.
If that word (ignoring
case) is either INSERT, UPDATE or DELETE then it is a DML statement
and the output from getUpdateCount() is relevant, otherwise the
output from getUpdateCount() is irrelevant.

Ugly and error prone. But the only possible solution that came out of this SO question. :-(
Comment: Normally you would *know* whether your SQL statement was an update statement or not, so you would know whether to call executeQuery(), executeUpdate(), etc.
Comment: @EJP: If I'm creating a GUI application where the user can input an arbitrary SQL statement then I *don't* know the SQL statement in advance. It doesn't really matter if I use `executeQuery()`, `executeUpdate()`, etc, as they all suffer from the described problem.
Comment: @EJP:  Let us review: As an example (that you say will fit the requirement) lets look at the returned value from `executeUpdate()`: *either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing*. The problem is that 0 (zero) is also a possible return value from a DML statement so I cannot from the return value distinguish between DML statements and non-DML statements.
Comment: Have you read [this](http://www.webdbtips.com/205029/) ?
Comment: @The New Idiot: Thanks, but as I see it that blog just points to the same design problem in JDBC as I have run into.
Comment: No, they *don't* all 'suffer from the described problem' at all. executeUpdate() and executeBatch() both return *exactly what you are looking for.* I suggest you revise your design or else take the hint from the answer here and call a different method depending on the first word of the query. It's not difficult and thanks to the syntax of SQL it's not in the least ambiguous.
Comment: You're just repeating yourself. I know what they return. My point is that normally you know what you've executed so you know what the return value means. The problem could only arise if you are building a library for some reason.
Answer: Maybe my answer does not help you with what you asked exactly, but I got here when I searched how to get the affected row count after running a DML, not found row count - with MySQL. And I write here what I found to help others.
My problem was that when I run a statement that does not do any change in the table, for example
UPDATE table SET field=1 WHERE field=1

method Statement.executeUpdate(...) returned the number of found rows, not the number of changed/affected rows. So I couldn't tell if the query modified something in the table.
To change this, an option should be provided in the url when the connection is created ( withDriverManager.getConnection()), like this:
jdbc:mysql://${jdbc.host}/${jdbc.db}?useAffectedRows=true
I found it here:
http://mybatis-user.963551.n3.nabble.com/Return-number-of-changed-rows-tp3888464p3903155.html
And MySQL documentation:
https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html
Answer: The best you can do is checking the SQL statement
Set<String> dmlCommands = new HashSet<String>() {
  {
    add("UPDATE"); add("INSERT"); add("DELETE"); //Add more DML commands ....
  }
};
int updateCount = statement.getUpdateCount();
for(String dml : dmlCommands) {
    if(arbitrarySQLCommand.toUpperCase().contains(dml) && updateCount == 0) {
        updateCount = -1;
        break;
    }
}

Comment: You might want to do `startsWith()` rather than `contains()` to make it a little bit more safe. However it still doesn't feel like the right way to solve the problem to me.
Comment: I'll accept this as an answer - reluctantly. The reason why I'm reluctant is that I really don't like the solution but it seems to be the *only* solution and for this you should of course be credited. :-)
Comment: this is not a full proof solution. I can have column name as insert or update


magento 2 custom phtml page

Question: Having just got myself acquainted (enough) with Magento 1.9, and able to make the customisations required, I've been told that once it's out, we're moving to Magento v2.0.
Having found the differences in the file structure, I believe I can see where to place my code for the custom pages we use, but how can I add this page from my project to a static block for later use?
Previously, the method used was as follows (I realise this may not follow the best practise, but it worked):

Create element folder within theme or core templates directory.
eg. /app/design/frontend/<theme>/default/template/myelement/mypage.phtml
Add this page/element to a static block using the following in the content editor:
{{block type="<theme>/default" template="myelement/mypage.phtml"}}

This block can then be added to the category pages as required.
In Magento 2, I have tried what I believe to be required, which is replicating the file structure and adding phtml files to this, so the template file now resides in:
/app/code/<supplier>/<module>/view/frontend/templates/mypage.phtml

Adding to the content editor the following:
{{block type="<supplier>/<module>" template="mypage.phtml"}}

Unfortunately, this does not display the intended page (element). It doesn't display the calling "{{block" entry either, which usually happens when the line is invalid, so I can only assume that I'm missing something with the link to this template.
If anyone can offer some assistance with this, I would be most grateful.
EDIT:
Continued research on this has led me to the following assumptions:

Magento 2 requires more than just a new .phtml page, even for simple customizations.
I'm still missing something.....

Having gone through 3 different tutorials on creating new modules for Magento 2, each providing slightly different methods, but fundamentally being the same thing, I now have what I believe should be all the code elements to make a new .phtml template for display in a static block.
This has led to an additional problem though.
While I have the required code, I cannot add the module. Adding the module to etc/config.php, as suggested in 2 out of the 3 tutorials, simply crashed M2, both admin and frontend when you try to clear the cache. This is the case after manually clearing cache folders in the var directory.
Also, still unable to add the .phtml template file to a static block or page using content editor.
Not much hair left to pull out here, so looking for help! Thanks in advance
Answer: There are a few samples on GitHub, including https://github.com/magento/magento2-samples/tree/master/sample-module-newpage which shows a module adding a new page with a very simple PHTML template file. This example does not use CMS content editing however - it is a sample based on using layout files.
You mentioned you were getting crashes. Would need more details to help on that one. If you got it solved, could you update this question and accept a response to close it out? Thx!
Comment: Work on this project has been temporarily halted. Will be re-visiting it later. For now we are continuing with Magento 1.9 and migrating to Magento 2 further down the line. Thanks for your input though, will keep it in mind when we do revisit Magento 2.
Answer: You Should try "class" instead of "type". So your code should look like.
{{block class="<package>\<module>\Block\MyBlock" template="mypage.phtml"}}

Comment: Thanks aziz. Unfortunately it appears that, while your answer may be correct, I'm still missing something.
Comment: Thanks aziz.
While I'm sure your answer is right, certainly appears to make sense, I must still be missing something.
I have gone through tutorials for creating modules (overkill for what I want, but might as well learn).
When adding module to config.php as suggested in tutorials, Magento2 simply crashes (admin and frontend).
Using full module file structure, using the code you suggested prevents the whole block from displaying.

Any thoughts?
Answer: You Should try "VenderName_Modulename::myelement/mypage.phtml" instead of "myelement/mypage.phtml". So your code should look like.
 {{block class="VenderNameModulename\Block\MyBlock" template="VenderName_Modulename::myelement/mypage.phtml"}}

magento 2 custom phtml page


Graph median, mode, range

Question:
The question is:
A scientist collects data. He determines both the mean of the data and the median of the data are equal to 7 and the data are symmetrical about this value. He starts to create a bar graph shown, but does not finish the graph.
If the range of the data is 8 and the maximum value of the data is 11, then how many data points fall above the value 7?
The answer is 14, but I don't know how this is the answer.
Answer: The range is $8$, max $11$, and it's symmetric around $7$. So we know we have at least:

one $3$ (giving us a range of $8$, or alternately because there is an $11$ and they symmetry)
two $4$'s (from the symmetry, as there are two $10$'s)
four $9$'s (from the symmetry, as there are four $5$'s)
and seven $8$'s. (from the symmetry, as there are sevel $6$'s).

Checking, it turns out that this gives the correct range, median, mean, and symmetry, so we see fourteen (seven $8$'s, four $9$'s, two $10$'s, one $11$) above $7$.
Answer: Use the fact that the data are supposed to be symmetric about $7$.  So fill in  stuff to make it symmetric, completing what the scientist did not get to finish. The symmetry automatically makes the mean and median equal to $7$.
For symmetry, we need a black bar of height $7$ at Value $8$, to balance the black bar of height $7$ at Value $6$. We also need a black bar of height $4$ at Value $9$, to balance the black bar of height $4$ at Value $5$.
We also need a couple of short black bars on the left, to balance the short black bars at Values $10$ and $11$. These short black bars are at Values $4$ and $3$ respectively.
We already have range $8$, So there is no more stuff to fill in. Now add up the heights of the black bars to the right of Value $7$. We get $14$.
Comment: Thank you, this was a good answer

Graph median, mode, range


Oracle text search default Stop words for non english locales

Question: Oracle documentation lists following default stop words.
http://docs.oracle.com/cd/B28359_01/text.111/b28304/astopsup.htm#CCREF1400
This includes stop words from all languages. But when i query my database to view list of stop words, it only shows English words.
SELECT * FROM ctx_stopwords;
It doesn't list non english stop words. I may be missing something here. I am looking for a query which returns all the default oracle stop words in all languages. Is there a way to achieve this?
Thanks!
Answer: Look for scripts in $ORACLE_HOME/ctx/admin/defaults/
<code>drdefus.sql - american
drdefd.sql  - german
</code>
Comment: Thank you. I see all locale specific files in that location. If i want to use stop words from all locales, does that mean i have to manually install all those locales?
Comment: Yes, but you can write a simple script to run all scripts if a folder


ARM Template - Validating parameters

Question: I have created a simple JSON which creates a storage account. After I introduced a parameter of type object I am getting a validation error.
<code>"parameters": {
  "storageAccountType": {
    "type": "string",
    "defaultValue": "Standard_LRS",
    "allowedValues": [
      "Standard_LRS",
      "Standard_GRS",
      "Standard_ZRS",
      "Premium_LRS"
    ],
    "metadata": {
      "description": "Storage Account type"
    }
  },
  "location": {
    "type": "string",
    "defaultValue": "Australia East",
    "metadata": {
      "description": "Location for all resources."
    }
  }, "objectToConvert": {
    "type": "object"

}
</code>
Output from Octopus
<code>{"storageAccountType":{"value":"Standard_LRS"},"location":{"value":"Australia East"},"objectToConvert":{"value":[{"a":"b"},{"c":"d"},{"c5":"d"},{"6a":"b"},{"cfg":"d"}]}}
</code>
I am sure the problem has been introduced due to the parameter objectToConvert.
The value of objectToConvert is being passed from Octopus and is

Error
Answer: Problem solved after changing the data type from object to array

ARM Template - Validating parameters


Error Running Matplotpp with C++

Question: I'm trying to run matplotpp (https://code.google.com/p/matplotpp/) inorder to output graphs on Lubuntu. Once downloaded and installed, I try to run my code but end up getting this error:

graph.c:2:22: fatal error: matplotpp.h: No such file or directory
compilation terminated.

My code, graph.c, looks like this:
#include<stdio.h>
#include<matplotpp.h>
using namespace std;

class MP :public MatPlot
    {
        void DISPLAY()
            {
                vector<double> x(100), y(100);
                for(int i=0; i<100; ++i)
                    {
                        x[i]=0.1*i;
                        y[i]=sin(x[i]);
                    }
                plot(x,y);
            }
    }mp;

void display()
    {
        mp.display();
    }

void reshape(int w, int h)
    {
        mp.reshape(w,h);
    }

int main(int argc, char* argv[])
    {
        glutInit(&argc, argv);
        glutCreateWindow(100, 100, 400, 300);
        glutDisplayFunc( display );
        glutReshapeFunc( reshape);
        glutMainLoop();
        return 0;O
    }

The compiler terminates when it reads the "include matplotpp.h" line.
I've also tried "include matplotpp/matplotpp.h" but no luck. Anyone know what I am doing wrong?
Comment: you should use include"matplot.h" not
Answer: There is difference between include<> and include"". When we use the latter one it. It first searches your own custom headers then go to system's own header file. And when we use the former it directly looks into system's header file. So, when you are using <matplotpp.h>, it goes to look in the system specific headers, and it is not present there. So you should use "matplotpp.h"
Comment: Hi, thank you very much. Unfortunately I did that initially but faced the same problem. I only changed it in my attempts to debug it.
Comment: If it's something that interests you... You can get matplotpp and compile it in under 3 minutes and test it out to see what you get.
Comment: Ok. Give me the link of matplotpp
Comment: Can you also give me GL folder of yours. i dont have glut. installed on my machine

Error Running Matplotpp with C++


HTTP method/standard for obtaining a list of files

Question: Is there any protocol or method specifically for listing files (or a list of file meta-data) in a directory?
I saw nothing obvious at http://www.iana.org/assignments/http-methods/http-methods.xhtml . The closest I think I could see was SEARCH which might be used for this purpose but defined no semantics. Are there no standards based on top of HTTP which allow for this?
Answer: What you're looking for is PROPFIND (http://greenbytes.de/tech/webdav/rfc4918.html#METHOD_PROPFIND)


flipviews inside Dynamic listview not swipable

Question: I have a listview that is populated during runtime from a webservice. Inside the data template of the listview I have made flipview, each flipview gets three images that user can swipe. I have attached an image of what i am looking for.

ISSUE
The flipview doesnt get user interactions. here is the xaml below
<ListView   ManipulationMode="None" IsZoomedInView="False"  IsSwipeEnabled="False" >
    <ListView.ItemTemplate >
        <DataTemplate>
            <Grid>
                <FlipView ItemsSource="{Binding image}" ManipulationMode="All">
                    <FlipView.ItemTemplate>
                        <DataTemplate>
                            <Image Source="{Binding image}" Stretch="Fill"></Image>
                        </DataTemplate>
                    </FlipView.ItemTemplate>
                </FlipView>
            </Grid>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Comment: solved it by adding gridview instead of flipview.. then copying template of a flipview in blend and changing its target type to gridview and all other flipview tags inside the template to gridview... then binding style of the gridview to this template
Answer: you have to apply a workaround here.

use gridview instead of flipview.
edit the template of the gridview(remove it and add (copy/paste) a flipview template instead)

next, the trick,

change the target type of pasted tempate to gridview
find/replace all other flipview tags inside the template with
gridview tags
last step,bind this new template to the gridview    (inside that
listview)
Answer: You can Add ItemsControl instead of ListView as ListView has some problems with inner controls that use horizontal gestures.
<ItemsControl>
<ItemsControl.ItemTemplate >
    <DataTemplate>
        <Grid>
            <FlipView ItemsSource="{Binding image}" ManipulationMode="All">
                <FlipView.ItemTemplate>
                    <DataTemplate>
                        <Image Source="{Binding image}" Stretch="Fill"></Image>
                    </DataTemplate>
                </FlipView.ItemTemplate>
            </FlipView>
        </Grid>
    </DataTemplate>
</ItemsControl.ItemTemplate>

You may need to add ScrollViewer manually as ItemsControl doesn't have one


Why is it required in some countries to sleeve uninsulated earth wire in junction boxes, but not required and not practiced in other countries?

Question: I don't know if the better question should be "why does, for example UK, require earth wires to be covered in a yellow sleeve in junction boxes", or should it be, "why does, for example USA, NOT require it and why don't electricians do it as a best practice?" ... but it seems like a fairly fundamental idea that is either an excellent and safe one, or an unnecessary one, and I would expect at some point in history there would be consistency.  What's behind this?
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/140139/discussion-on-question-by-jay613-why-is-it-required-in-some-countries-to-sleeve).
Comment: @MichaelKaras respectully, and with thanks for your moderation work, that was a bad move.  All the noisy comments, about 20, had already been *deleted*.  There were only 5 or 6 left and they were helping to better understand the question and had the potential to provoke answers.  Especially the last couple.  They were the reason comments exist.
Answer: On one hand it improves safety very marginally... on the other hand it escalates time and cost.   Simple as that.  In marginal-benefit cases like this, every country makes that call in their own way.
The builders have a very strong lobby within NFPA, which is why improvements are highly valued which let the builder work faster, like backstabs, wire nuts or plug-on-neutral breakers.  A proposal to amend NEC to require the sleeves would need to be supported by a body of evidence documenting fires which the bare grounds have started.  Since NFPA is, after all, the National Fire Protection Association* and gets fire reports from most fire chiefs, they have that data.
Note also that the UK line-ground voltage is twice North American voltage, since we actually do the center-grounding that the UK only does on construction sites.  As such, open-air arcing between a live terminal and a nearby bare ground may be more of a risk in the 5-continent system.
* Weirdly you'd expect them to be the National Fire Prevention Association.  The National Fire Protection Association should be teaching artillery crews how to deal with counter-battery fires, and the fine art of "shoot and scoot".
Comment: Makes sense.  I don't know specifics regarding UK electrical code but there is a stronger tendency in some countries (UK, Germany, Switzerland at least) for standards to be guided by lofty engineering ideals, without so many lobbies tying it back to their profit.  Hence for example the standard UK appliance plug, with more engineering in it than a Chevy Cruz.   Compare that to the standard USA single-insulated two-wire lamp cord with a two-prong plug that falls out of the socket if you look at it the wrong way.   I guess insurance data says that's not what's killing people so why fix it.
Comment: @JMac: I think the verbiage problem is that you should protect people from fires, not protect fires.
Comment: Is it that the reson why they invented the AFCI
Comment: I, generally, agree with your reasoning, @jay613. While plugs falling out of sockets is annoying, it's a reasonably simple fix to replace _one_ socket, rather than every. single. socket. in. the. country. with a highly engineered alternative that won't allow that to happen. It's also a reasonably _infrequent_ problem that _isn't_ killing lots of people.
Comment: You'd think by now that things like backstabs are well documented enough as a fire hazard that they'd be forced to stop using (or even making) them.  I think it's among the most frequently quoted no-no's on this site at least...
Comment: I think fire "protection" is a reasonable wording.  The best way to protect people from fires is to prevent them, but people are going to be people.  Theres only so much prevention you can do with building codes.  People will catch things on fire in spectacular ways, so having systems to protect people is the next safety step to take if you cant prevent them.
Comment: Harper what do you think of P2000 theory in Comment to Question ... that the prevalence of different earthing systems, or perhaps the history of those, in different countries creates different appetites for this practice?
Comment: Another thing about backstabs is that they only work with 14GAUGE  wire, so why bother if other gauges can't be backstabbed
Comment: Accepted answer on the theory that mandates for marginal or undemonstrated safety improvements are met with greater resistance in the USA than UK and some European countries if they increase cost or complexity of construction.
Comment: @jay613 But counterpoint, when safety improvements *are* demonstrated, we go kowabunga. Ask anyone who has paid for AFCIs, 5mA GFCIs (which must necessarily be per-circuit), outdoor disconnects, surge suppressor, 2 ground rods per structure (rather than hanging it on a supplied PEN), separate ground and neutral on all feeders (even from a "meter at a pole" where it seems stupid to me)... Europe still does none of that, I note. (though maybe localities do it, as our localities and states adopt NEC, or not).
Answer: Seems common sense to me to sleeve any bare wires jumbled about in a box along with live conductors and cables. Especially since you can't be 100% sure what's going on when you push the covers back.
I regularly see electrical boxes stuffed to the brim with 'added' cables after 'improvements' and you can barely force the cover back on. This blind pushing could in theory push a bare cable somewhere it's not supposed to be.
I often see bare earth wires here in Norway, but as I'm British, they always get a bit of sleeving from me before the cover goes back on. I also often see those wire nuts which I always find amazing, like something temporary a kid would do...
WAGO is the only way for me I'm afraid.


Finding root of $x^3-36x^2+405x-1458=0$

Question: How can I solve the following equation :
$$x^3-36x^2+405x-1458=0$$
I have tried as :
$$x^3-36x^2+405x-1458=0$$
$$\Rightarrow x^2(x-36)+405(x-3.6)=0$$
How is to proceed ?
Comment: Look up the closed form solution, replace coefficients, and simplify
Comment: @Coolwater by closed form solution do you mean the expression in the parenthesis ? How is to replace coefficients ?
Comment: I mean these formulas `http://www.wolframalpha.com/input/?i=+Solve[a+x^3+%2B+b+x^2+%2B+c+x+%2B+d+%3D%3D+0%2C+x]`
Answer: There are lots of powers of $3$ in there.  Try $x=3y$, then $$27y^3-324y^2+1215y-1458=0\\y^3-12y^2+45y-54=0$$
Can you find a solution to that, or change it again?
Comment: @ABC prime factorize each coefficient, the factorizations have many 3s in common, I dont why he didnt precede with x= 9y, which is better
Comment: I am not understanding why have you chosen $x=3y$?
Answer: Hint: Starting by looking for integer solutions. Every integer solution will necessarily be a divisor of $1458=2\cdot 3^6$.
Answer: Because $x=9$ is a solution, you can factor out $(x-9)$. Can you continue?
Answer: If we replace $x$ with $y+12$, then $y$ with $3z$, the original problem boils down to solving:
$$ z^3-3z-2=0,$$
whose solutions are obviously given by $z=-1$ and $z=2$, since $z^3-3z+2=(z+1)^2(z-2)$.

Finding root of $x^3-36x^2+405x-1458=0$


Cluster Autoscaling on AWS not scaling

Question: Stumped on this issue and hoping someone who knows more can help me.
Trying to follow a guide with a proof of concept for cluster autoscaling on AWS for Kubernetes (https://renzedevries.wordpress.com/2017/01/10/autoscaling-your-kubernetes-cluster-on-aws/). I built my cluster on AWS using kops following this guide (https://medium.com/containermind/how-to-create-a-kubernetes-cluster-on-aws-in-few-minutes-89dda10354f4).
The issue appears to be with the cluster autoscaling deployment. When I run:
kubectl logs cluster-autoscaler-
I get the following output:
I0706 13:26:36.338072       1 leaderelection.go:210] failed to renew
lease kube-system/cluster-autoscaler
I0706 13:26:38.776977       1 leaderelection.go:210] failed to renew
lease kube-system/cluster-autoscaler
I0706 13:26:43.119763       1 leaderelection.go:210] failed to renew
lease kube-system/cluster-autoscaler
I0706 13:26:47.116439       1 leaderelection.go:210] failed to renew

I've been looking into the error and it was to do with the namespace. When I  run the pod in a different namespace or the namespace recommended (kube-system - https://github.com/kubernetes/contrib/issues/2402) I still get the same error. Not sure what it causing it.
Thanks in advance for the help!
Comment: [The code says](https://github.com/kubernetes/client-go/blob/v8.0.0/tools/leaderelection/leaderelection.go#L18) it stores the current election state on the `Endpoints` object, so `kubectl get --all-namespaces=true --output=wide endpoints | grep -i autoscale` may help you find it, and then `kubectl --namespace=$the_ns get --output=yaml endpoints $endpoint_name` could surface who currently has the lease. It certainly smells like you have more than one cluster-autoscaler instance running, and you're looking at the logs for the "second" one
Answer: Follow this guide here to configure Cluster Autoscaler for Kubernetes running in AWS.
Configure Cluster Autoscaler in Kubernetes
It should do the work without any errors.
Comment: After trying five other methods for 8 hours were not working but this one working. Great work!!!
Comment: @samrat-priyadarshi
the link does not work.
also, your blog link in the profile redirects to a scam website claiming to infect the computer with a virus

Cluster Autoscaling on AWS not scaling