text:
Q: Android getsupportedvideosizes returns null on emulator I have tried to get the supported video size as below in an emulator but it always return null.Why it is so?I have tried in 4.03.Thanks in advance
 Camera camera=Camera.open();
    android.hardware.Camera.Parameters params = camera.getParameters();
    supportedPicSizes = params.getSupportedVideoSizes();
    if (supportedPicSizes==null){
        Log.i("*****supportedVideoSize*****", "*****Null****");
    }

A: This is a known Android bug.
This still hasn't been fixed yet but the fact that it is on the bug tracking system probably means that Google has plans to see it through.

A: Here is the one of the option by which you can get Camera Preview Size of the devices.
Camera camera=Camera.open();
android.hardware.Camera.Parameters params = camera.getParameters();
Size supportedPicSizes = params.getPreviewSize();
if (supportedPicSizes==null){
      Log.i("*****supportedVideoSize*****", "*****Null****");
}
else{
      Log.i("*****supportedVideoSize*****", "*****"+supportedPicSizes.height);
      Log.i("*****supportedVideoSize*****", "*****"+supportedPicSizes.width);
}

Hope it helps you.
Thanks.

A: It's clearly stated here that a null return from this method means the device doesn't support different outputs for preview and video. In case of emulator, this situation must be prominent because an emulator doesn't have a physical camera and is generally not used for testing camera-related modules.
I would like to add that even though documentations have pointed this to be a normal case scenario, I'm still unable to find a proper alternative for devices suffering from this sickness. For instance, a Verizon variant of S3 return null for both "getSupportedVideoSizes()" and "getPreferredPreviewSizeForVideo()". Has anyone gone through a way around this issue?? A help would be highly appreciated.

A: answered also here
Sample code:
public List<Size> getSupportedVideoSizes(Camera camera) {
    if (camera.getParameters().getSupportedVideoSizes() != null) {
        return camera.getParameters().getSupportedVideoSizes();
    } else {
        // Video sizes may be null, which indicates that all the supported
        // preview sizes are supported for video recording.
        return camera.getParameters().getSupportedPreviewSizes();
    }
}


text:
Q: Compress variable css-selectors Is there any way to compress this css-selector?
form#fiche-node-form.node-form input#edit-field-address-und-0-name.form-text,
form#fiche-node-form.node-form input#edit-field-address-und-1-name.form-text,
form#fiche-node-form.node-form input#edit-field-address-und-2-name.form-text,
form#fiche-node-form.node-form input#edit-field-address-und-3-name.form-text,
form#fiche-node-form.node-form input#edit-field-address-und-4-name.form-text,
form#fiche-node-form.node-form input#edit-field-address-und-5-name.form-text,
form#fiche-node-form.node-form input#edit-field-address-und-6-name.form-text,
form#fiche-node-form.node-form input#edit-field-address-und-7-name.form-text, {
    width: 493px;
}

I would save me a BUNCH of code!
EDIT
Here is the complete CSS I need to be compressed in as less code as possible:
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-0-naam.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-0-naam.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-1-naam.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-1-naam.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-2-naam.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-2-naam.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-3-naam.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-3-naam.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-4-naam.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-4-naam.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-5-naam.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-5-naam.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-6-naam.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-6-naam.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-7-naam.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-7-naam.form-text {
    width: 493px;
}

form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-0-straat.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-0-straat.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-1-straat.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-1-straat.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-2-straat.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-2-straat.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-3-straat.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-3-straat.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-4-straat.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-4-straat.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-5-straat.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-5-straat.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-6-straat.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-6-straat.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-7-straat.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-7-straat.form-text {
    width: 352px;
}
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-0-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-0-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-1-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-1-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-2-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-2-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-3-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-3-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-4-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-4-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-5-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-5-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-6-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-6-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-7-gemeente.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-7-gemeente.form-text {
    width: 362px;
}

form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-0-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-0-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-1-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-1-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-2-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-2-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-3-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-3-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-4-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-4-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-5-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-5-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-6-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-6-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-bevoegde-adressen-und-7-postcode.form-text,
form#fiche-node-form.node-form input#edit-field-afl-dienst-adressen-und-7-postcode.form-text {
    width: 100px;
}

form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-0-straat,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-0-nr,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-0-postcode,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-0-telefoon,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-1-straat,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-1-nr,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-1-postcode,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-1-telefoon,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-2-straat,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-2-nr,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-2-postcode,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-2-telefoon,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-3-straat,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-3-nr,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-3-postcode,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-3-telefoon,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-4-straat,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-4-nr,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-4-postcode,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-4-telefoon,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-5-straat,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-5-nr,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-5-postcode,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-5-telefoon,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-6-straat,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-6-nr,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-6-postcode,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-6-telefoon,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-7-straat,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-7-nr,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-7-postcode,
form#fiche-node-form.node-form div.form-item-field-afl-dienst-adressen-und-7-telefoon,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-0-straat,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-0-nr,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-0-postcode,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-0-telefoon,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-1-straat,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-1-nr,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-1-postcode,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-1-telefoon,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-2-straat,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-2-nr,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-2-postcode,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-2-telefoon,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-3-straat,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-3-nr,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-3-postcode,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-3-telefoon,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-4-straat,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-4-nr,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-4-postcode,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-4-telefoon,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-5-straat,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-5-nr,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-5-postcode,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-5-telefoon,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-6-straat,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-6-nr,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-6-postcode,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-6-telefoon,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-7-straat,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-7-nr,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-7-postcode,
form#fiche-node-form.node-form div.form-item-field-bevoegde-adressen-und-7-telefoon {
    float: left;
    margin-right: 20px;
}

A: The answer depends entirely on your markup. First of all, if you're already using ID, you don't need to qualify that with an element name or a class name, since only one element may have that ID. So form#finche-node-form is the same thing as #fince-node-form, given that there will never be an element of that ID that is not a form.
#finche-node-form.node-form makes sense if you only want to apply the styles when the form has that class, and perhaps another style when it has another class. However, if your form will always have that class, or if you always want to apply that style to the form, regardless of whether it has that class, you can do with only #finche-node-form.
The rest of your code selects 8 different input fields. The same thing can be said about them. #input#edit-field-address-und-6-name.form-text can probably safely be reduced to #edit-field-address-und-6-name.
Now, the real space saver would be if you could find a way to target all 8 fields, without writing a separate selector for each, which is what you have here. That depends entirely on what your markup looks like. If these 8 fields happen to be your only input fields in the form, perhaps you can do with #finche-node-form input. Or else, if there are other elements, but only these 8 have the form-text class, then you could do with #finche-node-form .form-text.
If what you want to do is actually to apply this style to all  instances of .form-text then you could simply write
.form-text { width: 493px; }

So it all comes down to what your actual requirements are. There is not a single piece of that great long selector you've pasted that we can know to be safe to remove. There's a great deal we can assume will be safe, but only you can know what parts of the markup will be able to vary, and how you want your style to behave when it does.
Your selectors should express your intent. Your current selector makes the reader think that you want to target only a specific subset of elements, only within a specific form, and that the style should not always be applied but only in the perhaps rare condition where the form has a certain class, and the inputs have another certain class. If that actually is your intent, then perhaps the current selector isn't that bad. You should probably stop and think over things when your CSS selector makes the code more verbose than adding the style inline (although still easier to change, so hey).
If what you want to convey to the reader of your code (another developer or a browser) was really just "hey, I only want to make sure that all inputs in this form have this width", then that's what your selector should express.
Update
OK, now that we've seen your complete CSS code, we can verify that there are several different instances of .form-text that have different styles, so applying a single style to all elements of that class is obviously out of the question.
Some other questions:

*

*Is #finch-node-form ever anything other than a form? Otherwise you may remove the initial form part of the selector from every selector.

*Does it ever happen that #finch-node-form does not have the class node-form? If not, you may remove .node-form from all selectors.

*Are there any <div> elements in the form that should ever not have the float and margin? If not, you may reduce that entire last selector to form#finche-node-form.node-form div or perhaps #finche-node-form div.

*

*If yes, is there anything else that is unique to the div fields where you do want to apply this style? For instance, if there are many divs, but the ones targeted in the above selector are only the ones that are immediate children of that form, and there are no other divs that are, you would be able to write #finche-node-form > div { ... }

*Is there anything that combines all 493px-textfields, and at the same time differentiates them from all 100px, 362px or 352px fields? Anything at all? If so, we may be able to target that #finche-node-form > div:first-child > .form-text { ... } (for instance).

Most important of all: is editing the HTML out of the question? Otherwise, you may simply introduce new classes, and apply your styles to them
#finche-node-form .width100-text-fields { width: 100px; }

(That's a terrible class name, but you get the idea)

A: You could use the attribute starts with selector:
form#fiche-node-form.node-form input[id^="edit-field-address-und"].form-text {
    width: 493px;
}

I'm assuming that you don't have any other elements that also have an ID starting with edit-field-address-und.

A: Using a CSS pre-processor, such as LESS:
form#fiche-node-form.node-form input {
    &#edit-field-address-und-1-name,
    &#edit-field-address-und-2-name,
    &#edit-field-address-und-3-name,
    &#edit-field-address-und-4-name,
    &#edit-field-address-und-5-name,
    &#edit-field-address-und-6-name,
    &#edit-field-address-und-7-name {
        &.form-text { width: 493px; }
    }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Transfer file from AWS S3 to Jira How to transfer file from AWS S3 to Jira?
I use Node.JS AWS-SDK and library 'jira-client' (https://www.npmjs.com/package/jira-client)
This code not working:
const
  s3Object = AWSS3.getObject({
    Bucket: 'thisisbucket',
    Key: 'thisiskey'
  }),
  S3Stream = s3Object.createReadStream();
  jiraClient.addAttachmentOnIssue(jiraId, S3Stream)
    .then(() => {
      console.log('Ok');
    })
    .catch(err => {
      console.error(err);
    });


text:
Q: writing a variable to a text file and encrypting it? i know how to save a users input to a text file but how do i encrypt it? here is what i have for saving a users input to text file. i tried f.encrypt("Passwords_log.txt" but had no results
import time
password1 = input("Please type a password: ")
print("Your password has passed the verification!")
time.sleep(1)
print("Saving and encrypting password...")
time.sleep(2)
f=open("Passwords_log.txt",'a')
f.write(password)
f.write('\n')
f.close()
print("Done!")

A: There are some Python packages worth checking out that deal with cryptography.
Cryptography
PyCrypto
A simple example from cryptography would be the following:
from cryptography.fernet import Fernet
key = Fernet.generate_key()
cipher_suite = Fernet(key)
cipher_text = cipher_suite.encrypt(b"A really secret message. Not for prying eyes.")
plain_text = cipher_suite.decrypt(cipher_text)

A: I guess you want to get some sort of a hash for the password, but file objects have nothing to do with that. You may try to use base64 encoding (like here), or any other other algorithm of the kind.
Your code:
import time
import base64
password1 = raw_input("Please type a password: ")
print("Your password has passed the verification!")
time.sleep(1)
print("Saving and encrypting password...")
time.sleep(2)
f=open("Passwords_log.txt",'a')
password = base64.b64encode(password)
f.write(password)
f.write('\n')
f.close()
print("Done!")

A: check out password hashing.
then i'd suggest you use https://pythonhosted.org/passlib/ or pycrypto; depending on what alorithm you choose.
this is just to store the encrypted password. to then encrypt data have a look at https://pypi.python.org/pypi/pycrypto/2.6.1.

A: You said, you tried base64 but it didn't work. Here is how you can make it work:
import base64
import time
password1 = input("Please type a password: ")
print("Your password has passed the verification!")
time.sleep(1)
print("Saving and encrypting password...")
time.sleep(2)
f=open("Passwords_log.txt",'a')
cr = base64.encodestring(password1)
f.write(cr)
f.write('\n')
f.close()
print("Done!")

This is not real encryption, I wouldn't recommend it for passwords, but since you said in your comment that you tried to use base64 and it didn't work, I thought I should show you how to use base64 in your code.


text:
Q: Out Of Office - Do not automatically reply to mail addressed to groups There used to be an option when setting Out Of Office to prevent automatic replies for mail addressed to groups. It no longer appears to be available in Notes 10/11 Does anyone know how to achieve this functionality, it seems quite a basic requirement so I feel I am missing something?
Many thanks.
As it was in Notes 7.


text:
Q: Need help in completing the proof of Fundamental Theorem of Algebra using Fundamental Groups I am reading a proof of Fundamental Theorem of Algebra.My proof boils down to show that if $p(z)=z^n+a_{n-1}z^{n-1}+...+a_0$( where $a_i$ is non zero for atleast one $i$) is non vanishing monic complex polynomial of degree $n$ then the maps

$f_1:S^1 \to S^1$ defined as $f_1(z)=z^n$ and $f_2(z):S^1 \to S^1$ defined as $ f_2(z)=\frac {p(z)}{\vert p(z)\vert}$ then $f_1$ and $f_2$ are not homotopic.

I am unable to prove that $f_1$ and $f_2$ are not homotpic .Any ideas?

A: Since this is a proof by contradiction, the main assumption needed is that $p$ is nowhere vanishing. (This is necessary for $f_2$ to be well defined, and it implies that at least one $a_i$ is non-zero). What you have to know is that $f_1$ is not homotopic to a constant, since in the standard identification of $\pi_1(S^1)$ with $\mathbb Z$ the class $[f_1]$ corresponds to $n\in\mathbb Z$. But $f_2$ is evidently homotopic to the constant map $\frac{p(0)}{\|p(0)\|}$ via $H(z,t):=\frac{p(tz)}{\|p(tz)\|}$.


text:
Q: jQuery done() seems to fire before request is sent I'm trying to hide an ajax loader after a request is done, but the done() callback is firing immediately after the blur() event, before the request is made. I made my controller action sleep for 5 seconds to be sure this was the case, and it is. I would think it should fire only after the result comes back from the server, or 5 seconds later. What's going on?
  $('#order_billing_post_code').on 'blur', ->
    field = $(this)
    post_code = field.val()
    type = field.data 'address-type'

    if post_code.length is 8
      xhr = $.ajax
        url: "/address_lookups/new"
        data:
          post_code: post_code
        beforeSend: ->
          field.siblings('i.address-ajax-loader').show()
        success: (data) ->
          parse data, type
        dataType: "json"

      xhr.done(
        alert "done"
      )

A: I'm not familiar with this syntax (Coffeescript?) but it looks like you're passing the result of calling alert "done" immediately to xhr.done(), instead of passing a reference to a function that calls alert.
Try:
xhr.done ->
  alert "done"

In vanilla JS, it's as if you had written:
xhr.done(alert("done"))

instead of:
xhr.done(function() {
    alert("done");
});

The alert call happens immediately, and the result is passed to xhr.done, which then does nothing useful at all.


text:
Q: .htaccess 301 redirect wildcard magento I am working on migrating a Magento site which is currently a multi store setup. I will be changing it from 4 different domains into 1 domain:
company.pl
company.de
company.us
company.com

all to:
company.com/uk
company.com/de
company.com/us
company.com/pl

This is not an issue, magento is all capable of this quite simply, however, when I start the project this weekend we will be doing US and UK, this means that the shop in magento will become company.com/uk/shop instead of company.com/shop
I need to know how I can possibly use a 301 redirect maybe like a wildcard to do the following:
If the user visits: company.com/shop/product.html redirect to company.com/uk/shop/product.html using some kind of wildcard so I do not need to set up a 301 for every product in the website.
Thank you,

A:
If the user visits: company.com/shop/product.html redirect to company.com/uk/shop/product.html

You can use this rule as your first rule in magento root .htaccess:
RewriteEngine On

RewriteRule ^shop(/|$) /uk%{REQUEST_URI} [L,R=301,NC]


text:
Q: how to define a file as a module in node.js instead of requireing code relatively, ie starting with ./ or .., i'd like to define a module "globally". For example, take the following package structure:
/src
  /index.js
  /a.js
  /b.js
/lib
  /index.js
  ...

When in src/a.js or src/b.js, to require lib, I would have to do require('../lib') each time. This gets annoying when you start nesting more as you would have to manually resolve ../lib or ../../lib or ../../../lib.
I want to be able to do require('lib'). Can I do this? Or should I just use globals?

A: placing your module in node_modules dont require you to include a path or relative path
EDIT:
if you place a file named package.json inside the module directory, Node will try to parse that file and look for and use the main attribute as a relative path for the entry point. For instance, if your

./myModuleDir/package.json

file looks something like the following, Node will try to load the file with the path

./myModuleDir/lib/myModule.js

:
{
"name" : "myModule",
"main" : "./lib/myModule.js"
}

If that folder does not contain a package definition file named package.json, the package entry point will assume the default value of index.js, and Node will look, in this case, for a file under the path ./myModuleDir/index.js.

A: Using a non relative path to require your source files is not how node's require is intended to work! Don't try to work around this restriction by placing arbitrary code file in node_modules directory or workaround by changing the NODE_PATH environment variable.
If you want to use require without a path you should extract the required code as a node module and depend on this node module. This leads to better structured code, less complex modules, encapsulated functionality, better testability and easier code reuse.
You can include package dependencies from http or git so there is no requirement to publish node modules you use in npm. Take a look at npm dependencies for more detail.

A: use  module.exports in the index.js file . and place it inside the node_modules folder

A: if relative path annoy you and you want to use lib always in your application, you can use global variable like this.
var lib = require('./lib');
global.lib = lib;

you can set lib to global variable in your entry point. after then you can access just lib.
but it's pollute global scope. so you have to use carefully.


text:
Q: Recalling and conditional At the end of a phone conversation about specific topic I have feeling that I didn't say everything. What should I say?
"If I recall something, I'll send it in e-mail"
or
"If I recalled something, I would write it in e-mail"
or maybe there is a better sentence?

A: Not

If I recalled something, I would write it in e-mail.

because recalled is past tense. You haven't recalled it yet.
This is OK

If I recall something, I'll send it in an e-mail.

I would say

If I think of anything else, I'll send you an e-mail.

A: I'll add a bit to user3169's answer.  I believe I understand your reason for asking this question: since sending the email is conditional upon your recalling something, you would like to use a specifically conditional tense, and you're having trouble finding one for future conditional situations.
We have two sorts of future conditional:

If I go to the opera tonight, I will take a taxi.
  If I were going to the opera tonight, I would take a taxi.

In the first sentence, I might be going and I might not.  But if I do, I will take a taxi.  In the second sentence, I'm not going; that decision has already been made.  But if I were, I would take a taxi.
The second sentence is often used as a polite way of giving advice.  In this case, perhaps someone is going to the opera, and you are suggesting that he take a taxi by saying that that is what you would do if you were in his place.  It makes the suggestion while avoiding telling the person what to do.  "You should take a taxi" is a more direct way of making the suggestion.


text:
Q: Generic function with switch I'm trying to convert numbers(Double, Float, CGFloat, Int32) to String.
protocol DirectionStringConvertible {
    var direction: String { get }
}

extension Double: DirectionStringConvertible {
    var direction: String {
        switch self {
        case 0...11.24: return "N"
        case 11.25...33.74: return "NNE"
            ...
        default: return ""
        }
    }
}

extension CGFloat: DirectionStringConvertible { var direction: String { return Double(self).direction } }
extension Float: DirectionStringConvertible { var direction: String { return Double(self).direction } }
extension Int32: DirectionStringConvertible { var direction: String { return Double(self).direction } }

So I can use like below:
CGFloat(12).direction
Double(190).direction

However I want to know any better way with generic type. Something like
extension String {
    static func direction<T>(_ value: T) -> String {
        switch value {
        case 0...11.24: return "N"
        case 11.25...33.74: return "NNE"
          ...
        default: return ""
        }
    }
}

A: Before I went to generic pattern, I'd wonder if you couldn't just use existing FloatingPoint protocol, to which all floating point types already conform:
extension FloatingPoint {
    var direction: String {
        let value = ((self - 32 / 360) * 16 / 360).rounded()
        switch value {
        case 0: return "N"
        case 1: return "NNE"
        case 2: return "NE"
        case 3: return "ENE"
        case 4: return "E"
        case 5: return "ESE"
        case 6: return "SE"
        case 7: return "SSE"
        case 8: return "S"
        case 9: return "SSW"
        case 10: return "SW"
        case 11: return "WSW"
        case 12: return "W"
        case 13: return "WNW"
        case 14: return "NW"
        case 15: return "NNW"
        case 16: return "N"
        default: return "???"
        }
    }
}

This obviously only works on floating point types, but perhaps this is sufficient for your purposes. If you want, as rmaddy pointed out, you can write a BinaryInteger extension, that casts integer types to floating point types, and it can then use the above:
extension BinaryInteger {
    var direction: String {
        return Double(Int(self)).direction
    }
}

Or you can do a Numeric extension, where they are Comparable, multiplying by some factor so that the threshold values are integers:
extension Numeric where Self: Comparable {
    var direction: String {
        switch self * 4 {
        case 0    ..< 45:   return "N"
        case 45   ..< 135:  return "NNE"
        case 135  ..< 225:  return "NE"
        case 225  ..< 315:  return "ENE"
        case 315  ..< 405:  return "E"
        case 405  ..< 495:  return "ESE"
        case 495  ..< 585:  return "SE"
        case 585  ..< 675:  return "SSE"
        case 675  ..< 765:  return "S"
        case 765  ..< 855:  return "SSW"
        case 855  ..< 945:  return "SW"
        case 945  ..< 1035: return "WSW"
        case 1035 ..< 1125: return "W"
        case 1125 ..< 1215: return "WNW"
        case 1215 ..< 1305: return "NW"
        case 1305 ..< 1395: return "NNW"
        case 1395 ... 1440: return "N"
        default: return "???"
        }
    }
}

Or Alain's approach of multiplying by 100 makes the ranges a little less cryptic.

A: You could also try using the Numeric Protocol.
For example:
func direction<T:Numeric>(_ a:T)-> String where T:Comparable
{
   let dirNames = ["NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N"]
                  .reduce([(1125 as T,"N")]){ $0 + [($0.last!.0+2250,$1)]}
   return a < 0 ? direction(a + 360) : dirNames.first{ a * 100 < $0.0}?.1 ?? direction(a - 360)
}

By using integer comparison values (multiplied by 100 for 2 digit precision), the function will work for integer parameters without having to define two separate sets of values.
Using an extension and a switch statement, it could look like this:
extension Numeric where Self:Comparable
{
    var direction:String
    {
       switch self * 100
       {
         case 0..<1125         : return "N"
         case 1125..<3375      : return "NNE"
         case 3375..<5625      : return "NE"
         // ...
         case 33750..<36000    : return "N"

         case _ where self < 0 : return (self + 360).direction
         default               : return (self - 360).direction
       }
    }
}


text:
Q: Xamarin.Forms Background Thread I'm trying to get a really simple application running listing google Task.
I have a SQLite local db I'd like to sync / try syncing at regular interval with Google's server.
I was thinking of simply running a simple background thread so it'd work easily on all devices.
Problem comes down creating that background thread in a PCL project (Xamarin.Forms)
I can't seem to find a proper way of making one.
Currently I just have a second thread running as such:
    private bool Sync() { //Does stuffs }

    private void SynchronizeData()
    {
        // Repeats sync process every 35s
        Device.StartTimer (new TimeSpan (0, 0, 35), Sync);
    }

    // Is called pretty much when app starts.
    private void StartSynchronizationThread()
    {
        Task.Factory.StartNew(SynchronizeData,
            CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
    }

While it should anyway not be much of a problem considering operation count is really low (worst case for testing purpose it'd be less than a sec blocking) i experience a massive freeze of my application around when thread should be ran first. (Timer expiring for the first time)
The freeze last for a good minute...
Once it hapenned, i can stay on the app mostly forever without a single issue. I noticed the following appears quite later though:

[art]
  Thread[2,tid=2532,WaitingInMainSignalCatcherLoop,Thread*=0xee170800,peer=0x12c00080,"Signal
  Catcher"]: reacting to signal 3 [art] Wrote stack traces to
  '/data/anr/traces.txt' [art] Wrote stack traces to
  '/data/anr/traces.txt' [art]
  Thread[2,tid=2532,WaitingInMainSignalCatcherLoop,Thread*=0xee170800,peer=0x12c00080,"Signal
  Catcher"]: reacting to signal 3 [art] Wrote stack traces to
  '/data/anr/traces.txt'

Traces aren't really giving me much more informations though...
But it probably have to do with it.
As anyone a hint regarding this matter ? Package, code example or anything ?
Hopefully I missed out on something big e;
Thanks.

A: Working like a charm on an actual device, the issue was linked to the emulator. (Haven't found a fix for it though)

A: In Xamarin forms you have to go native for a proper background task, as described here:
Backgrounding with Xamarin Forms
To go native you need to use the Xamarin MessagingCenter to send messages back and forth to an appropriate background task (depending on what you're trying to achieve). For example, defining a service in Android:
[Service]
class YourService : Service
{
    public override IBinder OnBind(Intent intent)
    {
        return null;
    }

    public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
    {
        // Do your thang!
    }
}


text:
Q: Sync or cache data from a web app with an iphone app I have a web application already in place, and I'm working on an iPhone app. I have a fundamental question about caching/syncing data between the two.
So probably 80% of the iPhone app is more-or-less reading (GETing) data from the webapp (it's heavy on stats, so it gives you access to your stats and such). Should I be reloading this data every time a screen is loaded? If so, no syncing/caching would be required, since it would be "fresh" every time. However, it seems like I'd be sending unnecessary requests back to the web server for no reason in most cases, since often the data would not have changed.
I was thinking of caching this data locally on the phone somehow, but I don't know what the "best practices" are for this. Or if I should just sync up a sqlite DB on the iPhone with data from the web app, and provide "refresh" buttons in the nav controller title bar to manually request an update.
I'm not necessarily looking for code, just more-or-less putting a plan together.
Suggestions? Thanks!

A: It really just depends on how often the data on your web server will be updated.  If it's updated infrequently, then I would suggest caching the data on the iPhone.  But if there is a flurry of activity on your web server and having access to the most up to date information is considered critical to the success of your project, then you'll need to send GET requests.
I don't know if the iPhone can utilize Comet, but that could be an option to "push" updates to your phone if it's supported.
You could also have the phone periodically check the server for updates.  The server could return status code 304 Not Modified if the data hasn't changed.  This is less data intensive than pulling the actual data in each GET request.  In this case, you would only pull fresh data if 304 was not returned.


text:
Q: If conjugation by a matrix preserves the matrix norm then the matrix must be conformal? Let $A$ be an $n \times n$ real invertible matrix, and suppose that $\| X\|^2=\| AXA^{-1}\|^2$ for every $n \times n$ real matrix $X$.
Is it true that $A$ must be conformal?
(It is easy to see that conformal matrices $A$ satisfy this).


text:
Q: Rejected from iOS App Store for dyld_stub_binding_helper... what calls this? Our iPad app has been rejected from the app store for private/restricted calls-to/use-of dyld_stub_binding_helper. The most explicit info I can find on this function is here.
Our code does not directly reference this, and other than playing 20 questions with Apple, we do not know how to proceed. Has anybody encountered this problem before?

A: I just faced a problem exactly as you describe. (Rejection due to dyld_stub_binding_helper)
In our case, what happened was a .m file had someone wound up in the "Copy Bundle Resources" section of our xcode project.  This led to the compiled bundle having a .o file included in it, which I think is what triggered the rejection.  Simply removing the .m from the build phase and re-uploading seems to have fixed it.

A: Changing the deployment target from 3.0 to higher (iOS 7.0) for example will help.

A: In our case building with Xcode 5.0 Beta and iOS 7 results in

symbol dyld_stub_binding_helper not found
linker command failed with exit code 1 (use -v to see invocation)

Problem: Deployment Target was 3.0. Changing it to 4.3 fixed it.

A: Seems like it could relate to weak linking a library (which is not just valid, but suggested for providing multi-release support).  What libraries do you link?  How do you link them?

Edit:
go to where your .o files are built:
fs5h:armv7 bshirley$ pwd
/Users/bshirley/Library/Developer/Xcode/DerivedData/Chuck-cmwxmjfrimatygfvsnqmcieylbaw/Build/Intermediates/Chuck.build/Debug-iphoneos/PointWorks.build/Objects-normal/armv7
fs5h:armv7 bshirley$ find . -name '*.o' -print -exec  nm '{}' \; -print | grep RectZero
    U _CGRectZero

in this example, i apparently have one file that uses CGRectZero,
my find/grep/exec foo has grown weak, i couldn't manage the pipe internal to the find command
this will confirm you're linking to the symbol they say,
then remove the end part, get a boatload of output and search for the culprit


text:
Q: Cannot change region (locale) on MBP running OS X 10.9.2 I'm running OS X 10.9.2 on a MacBook Pro (Mid-2012) and cannot change its region (locale) via System Preferences -> Language & Region:
Changing it ostensibly works, but revisiting the preferences pane later shows the region reverted to its previous value.
In terms of what tools and apps report, the story is inconsistent:

*

*defaults read -g AppleLocale does show the NEW locale

*locale, by contrast, shows the PREVIOUS locale

*Similarly, Calendar.app shows holidays from the PREVIOUS locale

Thus, for the most part, the system behaves as if the region changes was ineffective - which is at least consistent with the preferences pane reverting to the previous value.
Here's what I've tried:

*

*Reset the NVRAM

*Repaired the disk with Disk Utility

*Booted into single-user mode and ran fsck -yf

*Cleared most caches with OnyX

*Checked the syslog for telltale entries

All to no avail.
Any help is appreciated.

A: Is there maybe an AppleLocale key in ~/Library/Preferences/ByHost/.GlobalPreferences.*.plist? That would override the key in ~/Library/Preferences/.GlobalPreferences.plist.


text:
Q: Chroot equivalent utility for running program on offline windows installation Chroot is often assimiled to be a kind sandbox. But in Unix, it also allow use of programs on certain non-bootable installation.
When I search chroot for windows: I see things like sandbox. I don't want security, I want a way to rescue the system. By example, if I disabled syskey with ntpasswd, running C:\windows\system32\syskey.exe with a such utility would modify the registry entries of the of the offline installation, not the current one.
It could be called runon similar as runas for alternative users.
What chroot would means here for windows? Well, there is winre which allow having the same drive letters of your windows installation. There is an example: compact.exe is not present on winre installs. if you cd to \%Windir%\system32 (the directory of the offline install) and run compact, it won't work(except if you use it with /?). If you run
X:\sources\>path C:\Windows\System32\

You now use the files present in your offline windows. Base dlls such as ntdll.dll or eventually gdi.dll are those from C:\Windows\System32 instead of X:\%windir%\system32 and running compact will work.
But Programs runned by this way will use the current registry. The main keys (HKLM; HKCC; HKCR; HKCU; HKU; HKEY_PERFORMANCE_DATA) with their contents, are those of the current winre/pe installation, not those you have when you booted in your windows. So, if a program want to modify some registry entries, it will modify the Hives of X:\windows\system32\config not those of located in the C:\ systemdrive.
It is possible to mount the Hives of your offline windows under HKLM and edit them, but the programs which have their informations in HKLM\Software would still look at HKLM\Software and not at the name you mounted it.
The utility I am looking for would (partially?) hide the registry of winpe/re in favour of the one present in the offline install. The expected effect is that if you launch the registry editor with the utility, you will see the keys as if you would have booted into windows. (Maybe with some exceptions?)
The application would still use the Microsoft services of the current windows. I'd like launching services installed on the offline windows that are not installed on the current one. It would be nice to do this even for kernel ones. By this way, you would have the same behaviour when you launch sysv daemons in unix. Except here some mechanism for avoiding dual instances could be necessary, because the problems would be more critical on windows
The user access rights are an important part in the Microsoft systems. Specifying a user name and password in the parameters of the command line could be necessary. Some problems occurs with a bad User database configuration and prevent windows to boot. If want to enable syskey again, It would need to have the authentication informations which couldn't be used. But in some case like syskey problems, it make windows in endless reboots. I think one possibility would be to find a way to mount the user Hives by providing their path instead of login informations. Or if it is impossible, try to keep the user keys/informations of the current booted windows.
I don't know if a utility like this exist. I'd like help for programming it with mingw from linux (I can't have Visual Studio) . It would be good if it don't need to be installed. I would like it don't use .NET or the full windows API, because I would like to see it working under winre. I write for C/C++ under linux, but I never done it for windows. The only experience I have is provided by the fact I managed to build 7-Zip with winebuilder. I just know that the main function is called "main" for console programs and "WinMain" for windows ones. I am not familiar with WINAPI nor nt API. I just know there are not real equivalent to the chroot() of the Unix API.
I hope this is possible, thanks in advance.

A: The answer, after some review, is No.  You can't do that.  There are too many embedded references to HKEY_LOCAL_MACHINE in the various system DLLs; at the very best, you would end up with a very buggy system (since different parts of the system would be seeing different views of the machine configuration.)


text:
Q: How to merge two .a files which is built for armv7 and i386? I have 2 static library(.a) files. These 2 files are basically same library.
one is built for architecture armv7, another one is built for architecture i386.
Is it possible to merge these 2 libraries into 1 file?
Unfortunately, I don't have any source code to re-build them.
Thank you in advance :D

A: You need to get to know what can be done with the lipo and libtool command line tools, both of which come with Xcode.
Here's a tutorial that might get you started on the process.
The steps include something like:

*

*lipo -info libFirst.a libSecond.a find out what architectures are in the .a files

*lipo -extract armv7s libFirst.a -o libFirst_armv7s.a extract the architectures you want

*libtool -static libFirst_armv7.a libSecond_armv7.a -o libCombined_armv7.a combine the architecture specific .a files into one

*lipo -create libCombined_armv7.a libCombined_armv7s.a -o libCombined.a and this gives you the final .a library.

And here's some older documentation from Apple which describes how to use the tools to create combined static libraries.


text:
Q: Spring Batch multiple DataSourcees In Spring Batch, I can inject a DataSource in
@Configuration
public class DbConfiguration {
    ....
    @Autowired
    public DataSource dataSource;

With a bunch of properties in my Application.properties
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/learning_spring_batch
spring.datasource.username=root
spring.datasource.password=waterside
spring.datasource.platform=mysql
spring.datasource.continueOnError=false

What happens if I want multiple Datasources?
For example, 1 for my source, 1 for my target and 1 for my Spring batch tables, is that possible? Also, if I want to specify specific schemas for any of the Datasources how do I do that? Thanks


text:
Q: DataGridView databinding I give a simple example to explain what I want:
I defined a class called Student, it has two properties: Name and Subjects.
public class Student()
{
     public string Name;
     public List<string> Subjects;
}

I created two instances of Student class, for example:
List<string> jackSubjects = new List<string>();
jackSubjects.Add("Math");
jackSubjects.Add("Physics");
Student Jack = new Student("Jack", jackSubjects);
List<string> alanSubjects = new List<string>();
alanSubjects.Add("Accounting");
alanSubjects.Add("Science");
Student Alan = new Student("Alan", alanSubjects);

Then I create a List studentList:
List<Student> studentList = new List<Student>();
studentList.Add(Jack);
studentList.Add(Alan);

My question is, is there any way I can databind this studentList with a DataGridView, something like the following:
dataGridView.DataSource = studentList;

The first column is the student name and the second column is a combobox which shows all the subjects for the student.
Thank you for your time in advance.

A: Something like this will work:

*

*Add a RowDataBound event to your grid and create a template column to hold the dropdownlist for the subjects:
<asp:GridView ID="dataGridView" runat="server" AutoGenerateColumns="false" OnRowDataBound="dataGridView_RowDataBound">
   <Columns>
       <asp:BoundField DataField="Name" />
       <asp:TemplateField>
           <ItemTemplate>
               <asp:DropDownList ID="subjects" runat="server" ></asp:DropDownList>
           </ItemTemplate>
       </asp:TemplateField>
   </Columns>

*Then on code behind handle the RowDataBound event as so:
protected void dataGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
  if (e.Row.RowType == DataControlRowType.DataRow)
  {
    var ddl = (e.Row.FindControl("subjects") as DropDownList);
    ddl.DataSource = (e.Row.DataItem as Student).Subjects;
    ddl.DataBind();
  }
}

Renders:

BTW, your Student class should look like this:
public class Student
{
     public string Name {get;set;}
     public List<string> Subjects {get;set;}

     public Student(string name, List<string> subjects)
     {
         Name = name;
         Subjects = subjects;
     }
}


text:
Q: Where define new global variable in Prestashop The file defines.inc.php contains multiple globals variables but if I want to define new variable which file is the best ?
If I update Prestashop the file defines.inc.php is reset and I loose my global variable.
Maybe in settings.inc.php but this file is not versioned.

A: You can create a file config/defines_custom.inc.php next to config/defines.inc.php. At startup Prestashop checks if this file exists. If it exists then it is included before the default one.
You can find the related code in config/config.inc.php :
$currentDir = dirname(__FILE__);

/* Custom defines made by users */
if (is_file($currentDir.'/defines_custom.inc.php')) {
    include_once($currentDir.'/defines_custom.inc.php');
}
require_once($currentDir.'/defines.inc.php');

This way you can for example set mode dev on without touching the default file:
define('_PS_MODE_DEV_', true);

And in the default file, this define will not occur:
if (!defined('_PS_MODE_DEV_')) {
    define('_PS_MODE_DEV_', false);
}

A: I suggest to create your own module (maybe a 'dummy' module :)), and declare there your global variables.
For example create a module called 'mymodule', the main file mymodule.php should be:
// Here you can define your global vars
define('MY_CUSTOM_VAR', 100);

class MyModule extends MyModule
{
    public function __construct()
    {
         // See documentation
    }

    public function install(){ return parent::install(); }
}

So you can update your PrestaShop version without problems losing your global vars ;)


text:
Q: Replace theme header image with featured image in wordpress i'm using the Casper theme on Wordpress. It displays a header image across the whole site, however i'd like it to display the featured image when viewing a post.
I've found the code below in header.php
<header id="masthead" role="banner" class="site-head site-header" <?php if(get_header_image() ) : ?>style="background-image: url(<?php header_image(); ?>);"<?php endif ?>>

Any help would be much appreciated.
Thanks

A: you can try something like this
<?php
    if ( is_singular() && has_post_thumbnail( $post->ID ) &&  ($image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) && $image[1] >= HEADER_IMAGE_WIDTH ) :
       echo get_the_post_thumbnail( $post->ID );
   elseif ( get_header_image() ) : ?>
       <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
<?php endif; ?>


text:
Q: How to properly insert date into MYSQL database using php? I want to store and display date in this format "1.1.1990", (d.m.Y)
I've got a date column in my database with these settings

TYPE: DATE
Browser display transformation: Date Format(text/plain: Dateformat)
Browser display transformation options: 0,'%j.%n.%Y','local'

My query goes as :

INSERT INTO table VALUES(STR_TO_DATE('1.1.1990', '%e.%c.%Y'))

So far the query is accepted but a blank field is displayed in database
Only other thing i could get is without using STR_TO_DATE to add a default date as 1.1.1970

A: *

*You have to set the column in date type

*You can ensure the date is wellformed: select STR_TO_DATE('1.1.1990', '%e.%c.%Y');


text:
Q: Why i don't have common default gateway and dns of 192.168.1.1 I cannot open some websites(example speedtest.net) it takes me to the address http://1xx.1xx.2xx.4x/AirtelDSL. where Airtel is my service provider(ISP)
while i can open succesfully http://speedof.me/
my router summary shows different ip than what is shown on my PC

while my router summary has this :

Can some one explain why these two are difernet?
I was thinking there should be only one default route  and dns even on router summary i.e 192.168.1.1
I wan to do port forwarding on a non standard port to access my PC through internet over ssh  but i am failing to do so

A: The "WAN" configuration of your Internet box is on the ISP's side, the Internet side of the box. Your computer however is on the "LAN" side, aka the home side of the box.
Now, the default Gateway and DNS settings are two things completely different.

Default Gateway (also called router): the device a computer will ask when it tries to reach a computer on another network. Think of it as a door in a wall. The rooms are the networks, the door is the router. It has two labels, one on each side (one IP address per network it is connected to).
On your side, the box has an IP of 192.168.1.1 and on your ISP's side, it has the "WAN IP Address" in your WAN status screen . Note that IPs on your side of the box are local, as such, they can't be seen from the outside.
The gateway in WAN status is the door that allows your box to see outside of your ISP's network.

DNS (short for Domain Name Services): The system that allows your computer to translate a human readable name (like superuser.com) into a machine-understandable IP address (like 151.101.1.69). Now, in most home network configurations, the DNS server used is the ISP's DNS server. On most recent boxes, the box itself acts as a DNS intermediate, which is why it sets itself as your DNS.
The fact that you can't access Speedtest is most likely a DNS problem. Contact your ISP or use another DNS.

As for your port forwarding issue, here's what you have to do:

*

*Set up the port forwarding: any outside port to port 22 on your PC's local IP

*From the outside, connect to your box's WAN IP (as seen in WAN status screen) on the "outside port" you choose when setting up port forwarding. Don't use the computer's local IP.

A: It is possible your ISP simply blocks the website speedtest.net. When doing a speedtest, it will download and upload lots of data as fast as it possibly can. This generates bandwidth. They may want to prevent you from doing so and redirect speedtest.net to their own site.
It may also be that they do this because they know they cannot guarantee fast speeds and thus try to prevent their users from finding out how bad it really is. Yes, I know this is bad practice, but it has happened before.


text:
Q: how to properly use recursive function to go through multiple nested objects In my Angular app, I'm using AngularTree directive (http://wix.github.io/angular-tree-control) to render a tree view of the following data structure, as shown in https://jsfiddle.net/eugene_goldberg/Lvwxx629/17/:
$scope.subjectAreas = [
        {
            name:   "Area-1",
            link:   "dashboards.dashboard_1",
            entities: [
                {
                    name: "entity 1"
                },
                {
                    name: "entity 2"
                }
            ],
            offerings: [
                {
                    name: "offering 1"
                },
                {
                    name: "offering 2"
                }
            ]
        },
        {
            name:   "Area-2",
            link:   "dashboards.dashboard_1",
            entities: [
                {
                    name: "entity 3"
                }
            ],
            offerings: [
                {
                    name: "offering 3"
                }
            ]
        },
        {
            name:   "Area-3",
            link:   "dashboards.dashboard_1",
            entities: [
                {
                    name: "entity 4"
                },
                {
                    name: "entity 5"
                },
                {
                    name: "entity 6"
                }
            ],
            offerings: [
                {
                    name: "offering 4"
                },
                {
                    name: "offering 5"
                }
            ]
        }
    ];

This treeView directive provides the "createSubTree" function, which I'm using as follows:
function createSubTree(ary) {
        var res = [];
        if (ary) {
            res = ary.map(function(v, k) {
                var id = k + 1;
                return {
                    i: id,
                    id: 'id' + id,
                    label: v.name,
                    children: createSubTree(v.entities)
                }
            });

        }
        return res;
    }

    $scope.treedata = createSubTree($scope.subjectAreas);

The output looks like this:
Area-1
   entity-1
   entity-2
Area-2
   entity-3
Area-3
   entity-4
   entity-5
   entity-6

As my data structure contains two nested arrays for each SubjectArea (entities, and offerings), I need to have a sub-folder for entities, and a sub-folder for offerings as children of each SubjectArea, so the output should look like this:
Area-1
   entities
       entity-1
       entity-2
   offerings
       offering-1
       offering-2
Area-2
   entities
       entity-3
   offerings
       offering-3
Area-3
   entities
       entity-4
       entity-5
       entity-6
   offerings
       offering-4
       offering-5

How can I modify the current code to have the recursive function create sub-groups for both entities and offerings?

A: Change your data to this:
$scope.subjectAreas = [{
    name: "Area-1",
    link: "dashboards.dashboard_1",
    entities: [{
        name: 'entities',
        entities: [{
            name: "entity 1"
        }, {
            name: "entity 2"
        }]
    }, {
        name: 'offerings',
        entities: [{
            name: "offering 1"
        }, {
            name: "offering 2"
        }]
    }]
}, {
    name: "Area-2",
    link: "dashboards.dashboard_1",
    entities: [{
        name: "entity 3"
    }],
    offerings: [{
        name: "offering 3"
    }]
}, {
    name: "Area-3",
    link: "dashboards.dashboard_1",
    entities: [{
        name: "entity 4"
    }, {
        name: "entity 5"
    }, {
        name: "entity 6"
    }],
    offerings: [{
        name: "offering 4"
    }, {
        name: "offering 5"
    }]
}];

I've only done the first part, but you can complete the rest.


text:
Q: Are there other examples for the subdivision with definite articles [i] Use 'at' with points of time in the day: at dawn
[ii] Use 'in' with parts of the day: in the morning (Longman)
They are saying that prepositions, at and in, are selected by their complements' meaning: that is, exactly when or a period of time. So it has 'at' in [i], while 'in' in [ii]. And in the same line, it needs not to be a definite article in [i], it seems. Then, do we have to have the article in [ii] for subdividing a period of time, like as subdividing cake into pieces? If it's the reason why 'the' is used, are there any other examples for the subdivision with definite articles?

A: The rules when the definite article should be used, and when not, are very fuzzy and often derived from tradition. Note,

at dawn
at the break of dawn.
at noon
at high noon
tomorrow [no article nor preposition!]
the day after tomorrow [article but no preposition!]
in the evening [period, with 'in']
at night [period, with 'at']
during the day [neither 'at' nor 'on' work here]
on July, the 4th
in July
on day five (of our journey)

If a rule exists, it's surely very complex and full of exceptions. I think it's best to learn these 'by ear'.


text:
Q: Relative div hovering with css The problem isn't so simple (as you would probably imagine), take the following example:
The HTML:
Text text text

 special content More text text text text...

How I would like the output to look like:

As you can see the #special-image is "hovering" over the content without touching it.
I know the first thing that comes to mind is position:absolute;
But as you can see in the example image, I want those divs to be position:relative to the area where they are setted (in the html). And the x,y positions can vary from page to page (they are not consistent).
The text in the page should stay "anchored" in the page, I can't give it absolute positions. The main point is that I don't want the #special-image div to move any of the text and just hover there.
What would you suggest I should do in-order to achieve this kind of behavior?
Thanks in advance.

Edit:
This is one step closer (thanks to @Ross McLellan),
But the newly created divs are pushing the content:
http://jsbin.com/isepow/1/
 And I need an image instead of the orange background.

A: I suppose it can be achieved with some negative margin if you know the width of the image/image holder
Not working in IE7...

Text text text

 special content More text text text text...

Not Working in Chrome...

Text text text

 special content More text text text text...

Alternative solution if an extra wrapper is allowed:

Text text text

 special content More text text text text...

Outer wrapper holds the position absolute style. Which allows special-image to move relatively without impacting the rest of the page
EDIT
Possibly fixed the IE7 isssues with using margins. Not sure why but it was the fact they were on a
, using a span instead and it looks happy (without moving any of the other text as far as I can see on my test)
Text text text  special content More text text text text...

A: For me it is not clear what defines the position of the two images. If the images shall be close to the special content text put this text together with the images in a seperate div. Then you can position the images relative to their parent div.

A: Like this ?
div#special-image{position:absolute;top:-5px; display:inline-block;}

See this as proof of concept ;-)


text:
Q: Using clustering for unsupervised classification (visualizing k-means cluster centers) I know that the cluster centroid is the middle of a cluster. It's a vector containing one number for each variable, where each number is the mean of a variable for the observations in that cluster.
I cluster my dataset (MNIST handwritten digits) using K-Means into 3,5 and 10 clusters. My question is: which characteristic of the data is captured by the centroids?
Plotting the centroids as images, I can see that with 3 clusters centroids are not well defined. For example, the 3 and 7 digits overlap, as you can see in the image. The same thing happens with 4 and 5 digits.
While with 10 clusters, centroids are better defined (as you can see in the image), but there are some repetitions for certain values (eg 2 centroids for 3 and 4). Why is this happening?

A: As Anony-Mousse pointed out, unsupervised clustering is not directly used for classification; although it can be used to predict classification output up to a permutation of class indices.
The objective function in unsupervised clustering is often non-convex (because of symmetry, among other things) and the quality of the result depends directly and heavily on the features that represent the data points. The reason why you see combined letters in one cluster is probably a mixture of both non-convexity (which leads to multiple local minima in the clustering objective function) and limitations of the representation that you use (probably pixel values?). Better optimization/initialization techniques (like K-Means++ or Generalized Majorization Minimization) will likely improve the result.
You may have noticed that with 10 clusters when some cluster centers represent multiple overlapping digits (which is most often the case) most likely some clusters are starving (cluster starvation happens when a cluster does not get any samples assigned to it). This also happens because K-Means converges to bad local minima.
To see for yourself exactly how/why this happens I recommend visualizing the cluster centers as K-Means is running and see how cluster centers evolve. Visualize the cluster centers after every few iterations of K-Means until it converges.

A: Clustering is not classification.
It does not know what you are looking for, and if the "overlapping" solution minimizes variance, then it is the better solution.
Don't expect magic from k-means. It is known to be sensitive to outliers in the data, for example.


text:
Q: Multi Layer Perceptron and multiclass classification in Python problem i have a problem regarding MLP in Python, when i am making multiclassification i only take as an output one of the possible 4 classes. I tried a solution of instead using "predict", using "predict.proba" in a way to enforce Softmax activation function (which in the documentation is appropriate for multiclass) but it didn't even work.
Also by using "Softmax" as activation function in the MLP parameters directly i get this so i stopped using it:
The activation 'Softmax' is not supported. Supported activations are ('identity', 'logistic', 'tanh', 'relu').
My code is the following:
print('Scaling data for NN..')
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
# Fit only to the training data
scaler.fit(X_train)
scaler.fit(X_validation)

# Now apply the transformations to the data:
X_train = scaler.transform(X_train)

print('data scaled.')
#############################
#training model:
print("start training NN model..")

from sklearn.neural_network import MLPClassifier

model = MLPClassifier(
    hidden_layer_sizes=(70,70,70),
    activation='relu', alpha=1e-05, batch_size='auto',
    beta_1=0.9, beta_2=0.999, early_stopping=False,
    epsilon=1e-08,
    learning_rate='constant', learning_rate_init=0.001,
    max_iter=200, momentum=0.9, #n_iter_no_change=10,
    nesterovs_momentum=True, power_t=0.5,  random_state=1,
    shuffle=True, solver='lbfgs', tol=0.0001,
    validation_fraction=0.1, verbose=False, warm_start=False
  )

model.fit(X_train, y_train)
print ("Trained model :: ", model)
#############################

#predict:
predicted_variable = pd.DataFrame()

#OPTION 1:
#predicted_variable['variable_name'] = model.predict(test)
#this gives me one class only

#OPTION 2:
#predict by using Softmax for multiclass by using this:
predicted_variable['variable_name'] = model.predict_proba(test)
#this gives me the error: "data should be 1-dimensional" and stops execution

}
this code when i use "predict" i get only one class out of 4. RandomForest, XGB and Catboost give me all 4 classes as prediction, with different levels of accuracy of course.
Is it something with the scaling? MLP is supposed to be sensitive in scaling afaik.
Thank you


text:
Q: Appending an onload to an image causes the onload event to be fired multiple times on Android devices I was trying to count the amount of images loaded on the page, because I needed to wait until all images were loaded in order to calculate the correct height of the parent element. I ended finding a much better way of doing this, but I ran into weird behaviour on android devices.
When you append an image with a onload function with jQuery, the event gets fired multiple times on Android:
$('#element').append('<img src="/interesting/path" onload="doSomethingWeird()" />' );

All other browsers I was working with were not doing this weird behaviour. I've had this on Android's 4.0.4 browser.
Does anybody why this is happening?


text:
Q: how to send a variable to another page using ajax and mootools? i am trying to send a variable to another page with a post request and i use this:
var x="hello";

var sender=new Request({
          url:"page.html",
          method:"post",
          data:x
       });
sender.send();

but how do i colected x after it gets sent to page.html? i tried reading everything i could find and work it out myself but i get strange results, so if anyone could give me a simple example i would appreciate it very much.

A: Here's a jsfiddle example (using the echo service to simulate a response)
http://www.jsfiddle.net/BVgNt/1/
var x = "bar";
new Request.HTML({
    url: '/echo/html/',
    data: {
        x: "bar",
        html: "x was '" + x + "'",
        delay: 0
    },
    method: 'post',
    onComplete: function() {
        console.log(this.response.text);
        document.id("target").set("html", this.response.text);
    }
}).send();

the idea in the request class is that it fires an onComplete (onSuccess and onError too) events when done, with this.response containing various collections of responses, check that in the firebug console to see what you can extract or consult the mootools Request.HTML manual.


text:
Q: IModelBinder not firing on MVC 3 I have this Controller:
[HttpPost]
public JsonResult Execute(PaymentModel paymentModel){...}

this is the model
public class PaymentModel
{
[Required]
[DisplayName("Full name")]
public string FullName { get; set; }
...
}

this is the binding action
 protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
            ModelBinders.Binders.Add(typeof(PaymentModel), new PaymentModelsBinding());
        }

this is the binding inplementation
public class PaymentModelsBinding : IModelBinder
    {
        public  object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
//Cant get to here with the debugger
}

I dont know if that is relevant or not, but I am injecting using Ninject to the controller constructor.
Update
This is how the form is submitted:
            $.ajax({
                type: 'POST',
                url: $("#form").attr("action"),
                data: $("#form").serialize(),
                success: function (json) {
                    ...

                },
                dataType: "Json"
            });

I want that to be restful, meaning I will to call it in every possible WEB way.
Browser Ajax, Browser Classic form submission, WebClient... and more.
Update
This is my ninject code:
kernel.Components.Add<IInjectionHeuristic, CustomInjectionHeuristic>();

            kernel.Bind<IPaymentMethodFactory>().ToProvider<PaymentMethodFactoryProvider>().InSingletonScope();
            kernel.Bind<IDefaultBll>().To<DefaultBll>().InSingletonScope();

            kernel
                .Bind<IDalSession>()
                .ToProvider<HttpDalSessionProvider>()
                .InRequestScope();

Thanks

A: Sorry, I can't see anything wrong with your code. This should work. And as a proof of concept, here's what you could try:

*

*Create a new ASP.NET MVC 3 application using the Internet Template

*Define a view model:
    public class PaymentModel
    {
        [Required]
        [DisplayName("Full name")]
        public string FullName { get; set; }
    }

*A custom model binder:
public class PaymentModelsBinding : IModelBinder
{
    public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
    {
        return new PaymentModel();
    }
}

*HomeController:
public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View(new PaymentModel());
    }

    [HttpPost]
    public ActionResult Index(PaymentModel model)
    {
        return Json(new { success = true });
    }
}

*A corresponding view (~/Views/Home/Index.cshtml):
@model PaymentModel

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "form" }))
{
    @Html.EditorFor(x => x.FullName)
    <button type="submit">OK</button>
}

<script type="text/javascript">
    $('#form').submit(function () {
        $.ajax({
            type: this.method,
            url: this.action,
            data: $(this).serialize(),
            success: function (json) {

            }
        });
        return false;
    });
</script>

*And finally register the model binder in Application_Start:
ModelBinders.Binders.Add(typeof(PaymentModel), new PaymentModelsBinding());

*Run the application in Debug mode, submit the form and the custom model binder gets hit.
So the question now becomes: what did you do differently?


text:
Q: Setting Sublime Text 3 to run specific Java version I have Java 11 and 7 installed since I am maintaining a website that uses Java 7. Some IDE now only support Java 11 onward, so I was figuring out how to set Sublime Text 3 to specifically run Java 7, without changing the default Java 11 on my system. I manage to figure it out by putting multiple pieces together, so I am documenting the answer here for other's reference.

A: *

*On Sublime Text 3, go to "Tools" > "Build System" > "New Build System..."

*Paste the following piece of code. Edit the path setting accordingly. I'm using Zulu JDK.

{
    "cmd": ["javac", "$file_name", "&&", "java", "$file_base_name"],
    "selector": "source.java",
    "file_regex": "^\\s*File \"(...*)\", line ([0-9]*)",
    "path": "C:\\Program Files\\JDK-Zulu\\zulu-7\\bin",
    "shell": true
}

*Save the setting with extension .sublime-build. I named mine Java7 Run.sublime-build.

*After saving, it should appear in your Build System list. Select that and now when you Build, it will use Java 7 (or whatever Java version you set it to be).

To validate, you can use System.out.println(System.getProperty("java.version"));

A: On the  Mac Os, thats my path: "path": "/Users/<your-home-dir>/.sdkman/candidates/java/11.0.2-open/bin".
I use sdkman for various jdk flavors.
{
    "cmd": ["javac '$realpath$file' && java $file_base_name && rm *.class"],
    "selector": "source.java",
    "shell": true,
    "variants": [

      {
        "name": "JavaDoc",
        "cmd": ["mkdir documentation && javadoc -d documentation *.java"]
       },

       {
        "name": "JAR",
        "cmd": ["javac '$realpath$file' && echo \"Main-Class: $file_base_name\" > Manifest.txt && jar cfm $file_base_name.jar Manifest.txt *.class && rm *.class && java -jar $file_base_name.jar"]
        },

       {
        "name": "List Files",
        "cmd": ["ls"],
        },

       {
        "name": "Word Count",
        "cmd": ["wc", "$file"]
       }
    ],

    "path": "/Users/<your-home-dir>/.sdkman/candidates/java/11.0.2-open/bin"
}


text:
Q: Parse attribute table value to export filename using data driven pages and arcpy.mapping I'm trying to customize a data driven page looping statement workflow and want to set a better filename to the final export.  Currently the file name uses the page index (pgIndex), but I would like it to use a specific field in the attribute table.
Here is my file naming looping statement:
for pgIndex in range(1, tempDDP.pageCount + 1, 1):

  # Create a name for pdf file
  temp_filename = r"C:\Desktop\Test\temp_pdfs\MB_" + \
                            str(pgIndex) + ".pdf"
  if os.path.exists(temp_filename):
    os.remove(temp_filename)

Any idea how I can get the result I want?  I know this is possible if you use the built in export tool for arc 10, but I need more functionality, and therefore a customized script.

A: Okay, I finally figured out a method using pageRow.FIELDNAME
for i in range(1, tempDDP.pageCount + 1, 1):

  # Create a name for each pdf file
  tempMap.dataDrivenPages.currentPageID = i
  pageName = tempMap.dataDrivenPages.pageRow.Name
  temp_filename = r"C:\Desktop\Test\temp_pdfs\MB_" + \
                            str(i) + pageName + ".pdf"


text:
Q: Increase bit depth of an image in c# Are there any possible way(s) to increase an image's bit-depth and save extra information of that image  into that increased bits without affacting original pixel values?

*

*ie: Original image = 24 bits RGB

*Needed : 32 bits (Extra 8 bits to
store some other information)

A: you can try to use alpha channel

*

*convert to RGBA

*but different fileformats process it differently

*so it could change the visual appearance while previewing

*try: TGA,PNG,BMP

*formats like: JPG,PCX,.. does not support alpha channels

*also some formats/viewers can choose background color which changes appearance too

*you can partially use lower bit count of alpha to avoid too much noisy previews

*for example 00XXh,80XXh or FFXXh depends on the blending function

*but if you really need 8 bit per pixel then use format that ignores Alpha channel in your used viewers

you can add the new information after image

*

*some formats like GIF use end of file markers

*so you can add your data after that mark ...

*but you need to handle the image load/save your self

*some formats use offset table or starting address of image data inside header information

*you can put your data inside or even in between image data

*and offset the start addresses accordingly

*also for that you need to handle load/save yourself

*booth of this ways will not show additional information in previews

*but viewers and antivirus apps can detect the wrong size

*and poorly written loaders can even crash ...

you can put the info into auxiliary data/channels of image

*

*format like GIF have additional data chunks used for subtitles,animation commands, synchronizations and more

*you can encode your data into it

*this way is clean but there are not many file format capable of this

*advanced tools for such files can see the added information but you need to look for it ...


text:
Q: Using animate parameters with shorthand jQuery effects? If I want to do a simple slideDown() in jQuery, such as:
$(".zip").delay(1000).slideDown();

But I wanted to use the useTranslate3d parameter (for the jQuery.Animate-Enhanced plugin), can I simply apply the parameter to the slideDown() function, or do I need to also call the animate() function like so:
$(".zip").delay(1000).slideDown().animate({
    useTranslate3d: true,
});

Or could I simply do:
$(".zip").delay(1000).slideDown({
    useTranslate3d: true,
});


text: Q: Stuck on Classical intro to Modern Number Theory page 157? Could anyone who also owns the book explain why points of degree d, raised to powers of q are in the algebraic set V and why they are distinct? (Lines 7 to 11 on page 157). I've looked at chapter 7 on finite fields for the reasoning like the authors advised but can't see why it's true. Any help would be hugely appreciated.


text:
Q: Solve the initial value problem $ (x+1)^2 dx+(2xy+x^2-1)dy =0 , \ y(0)=1 \ $ Solve the initial value problem $$ (x+1)^2 dx+(2xy+x^2-1)dy =0 \ , \  \ y(0)=1 $$
Answer:
Consider the above equation with $ \ M(x,y)dx+N(x,y)dy=0 \ $ , then we get
$ M(x,y)=(x+1)^2, \ N(x,y)=2xy+x^2-1 \ $
Since $ \ \frac{\partial M}{\partial {y}}=0 \neq 2y+2x=\frac{\partial N}{\partial {x}} \ $ , the equation is not exact.
Let $ \ \mu =x^a y^b \ $ is an integrating factor.
Multiplying the differential equation by $ \ \mu=x^a y^b \ $ , we get
$$ (x^{a+2}y^b+2x^{a+1}y^b+x^ay^b)dx+(2x^{a+1} y^{b+1}+x^{a+2} y^b-x^ay^b)dy=0 \ $$ Consider it with $ M'dx+N'dy=0 \ $ , we gte
$ M'= x^{a+2}y^b+2x^{a+1}y^b+x^ay^b , \ N'=2x^{a+1} y^{b+1}+x^{a+2} y^b-x^ay^b \ $
Since the new equation is exact , we have
$ \frac{\partial M'}{\partial {y}}=\frac{\partial N'}{\partial {x}} \\ \Rightarrow bx^{a+2}y^{b-1}+2bx^{a+1} y^{b-1}+bx^a y^{b-1}=(a+1)2x^{a} y^{b+1}+(a+2)x^{a+1} y^{b}-ax^{a-1} y^{b} $
From this I have to find out the values $ \ a, \ b \ $.
But I can not find $ a,b \ $
Help me

A: $$ (x+1)^2 dx+(2xy+x^2-1)dy =0 \ , \  \ y(0)=1$$
Yes, the integrating factor is $\mu=x^ay^b$. There's a formula for this case
$$\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}=a\frac{N(x,y)}{x}-b\frac{M(x,y)}{y}\\ -2x-2y=a\left(\frac{x^2+2xy-1}{x}\right)-b\left(\frac{x^2+2x+1}{y}\right)\\ -2x-2y=ax+2ay-ax^{-1}-b(x^2+2x+1)y^{-1}$$Here everything its right except for $a$ because can't have two values$\ a=-2\ \&\ a=0$. Then the ODE isn't exact.
Try using Maclaurin Series to aproximate the solution $\ y(x)=\sum_{n=0}^\infty \frac{y^{(n)}(0)}{n!}x^n$
$$ (x+1)^2 dx+(2xy+x^2-1)dy =0 \ , \  \ y(0)=1\\ y'(x)=-\frac{(x+1)^2}{x^2+2xy-1}$$
We have $y(0)=1$ that means $x=0$ and $y=1$ substitute to find $y'(0)$. I'll expand the solution to four terms so do the same for $y''(0)$ and $y'''(0)$
$$y''(x)=-\frac{(x^2+2xy-1)(2x+2)-(x+1)^2[2x+2y+2xy'(x)]}{(x^2+2xy-1)^2}$$
$$y''(x)=2\left[\frac{(x+1)^2[x+y+xy'(x)]}{(x^2+2xy-1)^2}-\frac{x+1}{x^2+2xy-1}\right]$$
$y'''(x)=2\left\{\frac{4(x+1)[x+y+xy'(x)]}{(x^2+2xy-1)^2}+\frac{(x+1)^2[1+2y'(x)+xy''(x)]}{(x^2+2xy-1)^2}-\frac{4(x+1)^2[x+y+xy'(x)]^2}{(x^2+2xy-1)^3}-\frac{1}{x^2+2xy-1}\right\}$
Then $\quad y'(0)=1$,$\quad y''(0)=4$,$\quad y'''(0)=24$
$$y(x)\approx1+x+2x^2+4x^3+\ldots$$

A: Hint:
$(x+1)^2~dx+(2xy+x^2-1)~dy=0$
$(2xy+x^2-1)\dfrac{dy}{dx}=-x^2-2x-1$
$\left(y+\dfrac{x}{2}-\dfrac{1}{2x}\right)\dfrac{dy}{dx}=-\dfrac{x}{2}-\dfrac{1}{2}-\dfrac{1}{2x}$ with $y(0)=1$
This belongs to an Abel equation of the second kind.
Let $u=y+\dfrac{x}{2}-\dfrac{1}{2x}$ ,
Then $y=u-\dfrac{x}{2}+\dfrac{1}{2x}$
$\dfrac{dy}{dx}=\dfrac{du}{dx}-\dfrac{1}{2}-\dfrac{1}{2x^2}$
$\therefore u\left(\dfrac{du}{dx}-\dfrac{1}{2}-\dfrac{1}{2x^2}\right)=-\dfrac{x}{2}-\dfrac{1}{2}-\dfrac{1}{2x}$
$u\dfrac{du}{dx}=\left(\dfrac{1}{2}+\dfrac{1}{2x^2}\right)u-\dfrac{x}{2}-\dfrac{1}{2}-\dfrac{1}{2x}$


text:
Q: Transition Functions and Complex Structure For a complex manifold $M$, the transition functions of the tangent bundle $T(M)$ come from the Jacobian of the change-of-coordinate maps. Does there exist a related description of the transition functions of $T^{(0,1)}$ and $T^{(1,0)}$? An example would also be nice, maybe $\mathbb{CP}^1$.

A: For a real manifold $M$ the transition functions of the tangent bundle $T(M)$ come from the Jacobian of the change-of-coordinate maps.
When $M$ is complex, it has a complex tangent bundle $T_{\mathbb{C}}M$, which can be identified with the holomorphic vector bundle $T^{(1,0)} \subset TM \otimes \mathbb{C}$. The transition functions on $T_{\mathbb{C}}M$ are given by the (complex) Jacobian of the change-of-coordinate maps, so the same is true for $T^{(1,0)}$.
Since $T^{(0,1)}$ is the complex conjugate bundle, its transition functions are the complex conjugate of the same Jacobian.


text:
Q: Reverse iteration through ArrayList gives IndexOutOfBoundsException When I reverse iterate over an ArrayList I am getting a IndexOutOfBoundsException. I tried doing forward iteration and there is no problem. I expect and know that there are five elements in the list. The code is below:
Collection rtns = absRtnMap.values();
List list = new ArrayList(rtns);
Collections.sort(list);

for(int j=list.size();j>0;j=j-1){
  System.out.println(list.get(j));
}

Forward iteration - which is working fine, but not useful for me:
for(int j=0;j<list.size();j++){
    System.out.println(list.isEmpty());
    System.out.println(list.get(j));
} // this worked fine

The error:
Exception in thread "Timer-0" java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
    at java.util.ArrayList.RangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at model.Return.getReturnMap(Return.java:61)
    at controller.Poller$1.run(Poller.java:29)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)

Also if anyone knows of a better idiom for reverse iteration I would be happy to try that out.

A: Avoid indexes altogether? How about:
for (ListIterator iterator = list.listIterator(list.size()); iterator.hasPrevious();) {
  final Object listElement = iterator.previous();
}

A: Start the iteration at list.size() - 1 because array (or ArrayList) elements are numbered from 0 up through 1 less than the size of the list. This is a fairly standard idiom:
for (int j = list.size() - 1; j >= 0; j--) {
    // whatever
}

Note that your forward iteration works because it stops before reaching list.size().

A: Java arrays are zero-indexed.
You will have to set j = list.size() - 1 and continue until j = 0.

A: If the lists are fairly small so that performance is not a real issue, one can use the reverse-metod of the Lists-class in Google Guava. Yields pretty for-each-code, and the original list stays the same. Also, the reversed list is backed by the original list, so any change to the original list will be reflected in the reversed one.
import com.google.common.collect.Lists;

[...]

final List<String> myList = Lists.newArrayList("one", "two", "three");
final List<String> myReverseList = Lists.reverse(myList);

System.out.println(myList);
System.out.println(myReverseList);

myList.add("four");

System.out.println(myList);
System.out.println(myReverseList);

Yields the following result:
[one, two, three]
[three, two, one]
[one, two, three, four]
[four, three, two, one]

Which means that reverse iteration of myList can be written as:
for (final String someString : Lists.reverse(myList) {
    //do something
}

A: I know this is an old question, but Java contains a Collections.reverse( List<T> ) method. Why wouldn't you just reverse it and do forward iteration?

A: The list.size() is past the last allowable index.
for(int j = list.size() - 1; j >= 0; j--) {
  System.out.println(list.get(j));
}

A: The most elegant way is to reverse the array and then use a direct (or even implicit) iterator :
Collections.reverse(arrayList);
for (Object item : arrayList) {
    ...
}

A: You can do this if you are comfortable with foreach loop.
List<String> list = new ArrayList<String>();
list.add("ABC");
list.add("DEF");
list.add("GHI");

ListIterator<String> listIterator = list.listIterator(list.size());

while(listIterator.hasPrevious()){
  System.out.println(listIterator.previous());
}

A: You can reverse by one line that is
Collections.reverse(list);
ArrayList arrayList = new ArrayList();

arrayList.add("A");
arrayList.add("B");

System.out.println("Before Reverse Order : " + arrayList);

Collections.reverse(arrayList);

System.out.println("After Reverse : " + arrayList);

Output
Before Reverse Order : [A, B]
After Reverse : [B, A]


text:
Q: XSL : how to obtain the result of two different match I'm willing to create an XSL Document that modifies the attribute of a root nodes, but that is also capable of changing the content of the XML document.
Here is my XSL Document :
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:ns="some:ns">
<xsl:output indent="yes" method="xml" encoding="UTF-8" />
<xsl:strip-space elements="*"/>

<ns:WhiteList>
    <name>HEADER</name>
    <name>ROOTNODE</name>
    <name>foo</name>
    <name>bar</name>
    <name>toto</name>
</ns:WhiteList>

<xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="ROOTNODE[@xsi:id = 'myXSDFile.xsd'] ">
    <xsl:copy>
        <xsl:attribute name="xsi:id ">myXSDFCleansedFile.xsd</xsl:attribute>
        <xsl:apply-templates select="ROOTNODE[@xsi:id = 'myXSDFile.xsd']"/>
    </xsl:copy>
</xsl:template>
<xsl:template match="*[not(descendant-or-self::*[name()=document('')/*/ns:WhiteList/*])]"/>

</xsl:stylesheet>

And my input XML document is the following one :
<?xml version="1.0" encoding="UTF-8"?>
<ROOTNODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:id="myXSDFile.xsd">
    <HEADER>
        ....
    </HEADER>
    <foo>blabla</foo>
    <bar>blabla</bar>
    <tab>dada</tab>
    <toto>blabla</toto>
    <titi>blabla</titi>
</ELIX>

The output I obtained is either :
<?xml version="1.0" encoding="UTF-8"?>
<ROOTNODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:id="myXSDFileCleansed.xsd">

Or :
<?xml version="1.0" encoding="UTF-8"?>
<ROOTNODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:id="myXSDFile.xsd">
    <HEADER>
        ....
    </HEADER>
    <foo>blabla</foo>
    <bar>blabla</bar>
    <toto>blabla</toto>
</ROOTNODE>

But the problem is that I want the second output, but with the xsd file name changed ! And I didn't succeed in merging the two different match paths. Do you have any idea how to merge the two match paths ?

A: I didn't get what you exactly tried. But first, if you wan't children processed when you apply your xsl, try to replace:
<xsl:apply-templates select="ROOTNODE[@xsi:id = 'myXSDFile.xsd']"/>

with
<xsl:apply-templates/>

When you are in the template, the context is ROOTNODE and when you try to apply template to "ROOTNODE[...]", the processor is looking for children of the context named ROOTNODE.


text:
Q: mgo regular expression doesn't work Now I have some documents, each of which has a key path and value like \A\, \B\, \A\C\, \A\C\D\, \A\E\, \A\E\F\.
I want to find the ones which have only 1 segment. It means the result should be \A\ and \B\. I use Regular Expression /^\\[^\\]*\\$/, which works fine in MongoDB terminal. But when I tried to apply it to Go programs it doesn't work.
Go codes:
var nodeList []NodeEntry // NodeEntry would match every field of one document
err = c.Find(bson.M{"path": bson.M{"$regex": bson.RegEx{"^\\[^\\]*\\$", ""}}}).All(&nodeList)
fmt.Println(nodeList)

Output:
[]

It's so strange, and then I found out that any Regex with \\ would produce an empty result.
So is it a bug of mgo?
(I don't know if it's inappropriate, but I've also posted this question on the mgo.users mailing list.)

A: In Go, the backslash (\) is the escape character of an interpreted string literal (using "..." as enclosures). In your case, you´d rather want to use a raw string literal (using  `...` as enclosures).
Let's look at this piece of code:
package main

import "fmt"

func main() {
    fmt.Println("^\\[^\\]*\\$")
    fmt.Println(`^\\[^\\]*\\$`)
}

Result:
^\[^\]*\$
^\\[^\\]*\\$

You can see that it is the second option that is the regex string you desire. So, to solve your problem, just enclose your regex string in backticks instead of quotes:
err = c.Find(bson.M{"path": bson.M{"$regex": bson.RegEx{`^\\[^\\]*\\$`, ""}}}).All(&nodeList)

Go spec reference: http://golang.org/ref/spec#String_literals

A: To add to @sandun-priyanka solution, if you want to make it case insensitive:
selector:= bson.M{"title": bson.M{"$regex": `(?i)`+wordOffset}}

A: Simply use this
   wordOffset := anyregular expression OR text to filter

   selector:= bson.M{"title": bson.M{"$regex": wordOffset}}


text:
Q: How to recreate android folder in flutter project I deleted the android folder of my flutter project (Thought I could get rid of the errors that appear while running old projects).
How can I create that android folder?
any commands?

A: Inside your project root, run:
flutter create .

This will generate/repair any missing files or folders (like /android)
Reference

A: The first command will recreate all folders like ios, android, windows, web, linux, and macos.
flutter create .

The second command will recreate android folder.
flutter create --platforms android .

The third command will recreate android and iOS folders.
flutter create --platforms android,ios .

A: Navigated to the root of my project and ran flutter create
Basically telling flutter to try and repair all the damaged and / or missing files in you project.


text:
Q: Can a vortex be self-sustaining? Can vortices be self-sustaining?
I suppose vortices in water are not self sustaining, since they need constant supply of water at speed i.e. kinetic energy. But is the same case applicable to space time vortices? like wormholes?? or do they need some energy source for sustenance?
Please try to give a intuitive explanation.

A: Self-sustaining vortices without dissipation (energy loss) are possible in superfluids (like, e.g., liquid helium) because there is no internal friction (viscosity) for the superfluid component. Rotation goes on by inertia. This is as close a I can imagine to a "self-sustaining vortex" although admittedly has little to do with space-time.


text:
Q: Infinite loop when trying 301 redirect with htaccess I've searched a lot, but couldn't find a solution. I'm trying to redirect php based urls with parameters to SEO friendly urls.
For example I want to redirect static.php?content_id=27 to /presentation/, but I get infinite loop error.
Here is my code:
RewriteEngine On
RewriteBase /

RewriteRule ^presentation/$ static.php?content_id=27
RewriteCond %{QUERY_STRING} content_id=27
RewriteRule ^static\.php$ /presentation/? [L,R=301]

The old urls are indexed by google so I need this redirect.
Thanks

A: Try this  :
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /static\.php\?content_id=27 [NC]
RewriteRule ^ /presentation/? [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /static.php?content_id=27 [NC,QSA,L]


text:
Q: VirtualBox doesn't display menu bar after login When I boot Ubuntu 12.04 in VirtualBox, I see VirtualBox's menu bar at the bottom of the screen.  After I log in, the menu bar disappears.  Why?  I really want it back.

A: Yes, it appears to be a bug in VirtualBox; it only occurs when you're using Unity hardware accelerated. If on the login screen you choose "Ubuntu 2D", the menu will be visible again.
The menu appears to be drawn under the 3D accelerated window - if you have multimonitor on a Windows host, you'll see that the Windows Taskbar also doesn't show if you change focus to another window while leaving VirtualBox in fullscreen mode on the main monitor.
I'm not sure if the bug is in VirtualBox or the host's display drivers.

A: Is it in scale mode?
Host + C is the toggle for scale mode (where Host is Right Control by default)

A: You might have accepted to not get notified again about scaled view before installing guest addition which will allow you later to change window size whilst OS append scale to it.
Reset the machine or press HOST or STRG (right side) + C
Good luck!


text:
Q: vague error message when exploring the contents of an S3 bucket I've created a linked service to S3 which connects without any problems, however when I create a data set and attempt to explore the contents of the bucket, I get the following error message:
The file operation is failed.. Activity ID:dee933af-54f6-4146-87f9-4158d98a09b9
is there anyway I can obtain information that might help be troubleshoot what the problem is.

A: from the backend logs, we can see that the error is complaining about : The remote name could not be resolved: "adf-.10..112.**". Could you double check whether the bucket name is valid, and it can be accessed from your self-hosted IR?
If the bucket name is correct. You can try using Azure IR to do the browse. If it works, it means the failure is caused by a connectivity issue from your self-hosted IR to the S3 account (e.g. firewall setting, proxy)


text:
Q: How to change files extension via MATLAB? I would like to change the extension of several files.
I mean that in one directory a I have many files in type file1.out, file2.out, ..., file600.out.
I would like to rename these files to *.txt (I mean file1.txt, file2.txt, ..., file600.txt) in this directory with one command via MATLAB?
I mean I would like to change the extension of some files from *.out to *.txt files.

A: This code from here can be helpful:
% Get all text files in the current folder
files = dir('*.out');
% Loop through each file
for id = 1:length(files)
    % Get the file name
    [~, f,ext] = fileparts(files(id).name);
    % change the extension
    rename = strcat(f,'.txt') ;
    movefile(files(id).name, rename);
end


text:
Q: Getting EOF Error while giving inputs to code I tried a problem from SPOJ called The next palindrome. The problem statement is given as

A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without leading zeros.

Here is my code
def palindrome(n):
    return True if n[::-1] == n else False

t = int(input())
for i in range(t):
    li = []
    n = input()
    for j in range(int(n) + 1, 1000000 + 1):
        if palindrome(str(j)) == True:
            li.append(j)
    print(li[0])

I tried giving an input like this
1
1000000

I am getting an error like this
Traceback (most recent call last):
  File "./prog.py", line 7, in <module>
EOFError: EOF when reading a line

A: The error is caused because your input "n" makes both arguments same in the range function in this line "for j in range(int(n) + 1, 1000000 + 1)". It looks like this range(1000001, 1000001) which return nothing. Use input of "n" smaller than 1000000. It will work.
It return empty list when I use this code.
n = 1000000
print(list(range(int(n) +1, 1000000+1)))

That why there is no data in it. EOF error is caused when python doesn't read any data.