How can I test if a letter in a string is uppercase or lowercase using JavaScript?

Question: How can I test if a letter in a string is uppercase or lowercase using JavaScript?
Comment: `str == str.toUpperCase();` returns **true** or **false**
Comment: can i just clarify the question - you want to test if a particular letter in a string is upper or lower - or do you want to test if the whole string contains any letter that is uppercase or lowercase. if it is the latter then how do you propose getting the result without looping through the string and testing one letter at a time?
Comment: http://jsperf.com/isupper-comparison/5 A few ideas there, and you can test them for speed as well.
Comment: Idea #4 (`[:upper:]`) is fast and very cool except that it doesn't work, see [my comment](http://stackoverflow.com/a/1718290/237105) below and my corrected http://jsperf.com/isupper-comparison/7.
Comment: `str.toUpperCase() === str && str.toLowerCase() !== str`, if you really don't want to use regExp.
Answer: The answer by josh and maleki will return true on both upper and lower case if the character or the whole string is numeric. making the result a false result.
example using josh
var character = '5';
if (character == character.toUpperCase()) {
 alert ('upper case true');
}
if (character == character.toLowerCase()){
 alert ('lower case true');
}

another way is to test it first if it is numeric, else test it if upper or lower case
example
var strings = 'this iS a TeSt 523 Now!';
var i=0;
var character='';
while (i <= strings.length){
    character = strings.charAt(i);
    if (!isNaN(character * 1)){
        alert('character is numeric');
    }else{
        if (character == character.toUpperCase()) {
            alert ('upper case true');
        }
        if (character == character.toLowerCase()){
            alert ('lower case true');
        }
    }
    i++;
}

Comment: Won't you still have the same false result if the character is something neither numeric nor alpha, such as punctuation?
Comment: @LarsH see this: http://stackoverflow.com/questions/1027224/how-can-i-test-if-a-letter-in-a-string-is-uppercase-or-lowercase-using-javascrip/9728437#answer-9728437
Comment: This code will alert that punctuation characters like `!` are numeric.
Comment: Why not check both whether the char equals its own lowercase and uppercase, if both are true, then false.
Comment: Uncaught SyntaxError: Unexpected token ; at line 4
`while (i <= strings.length){` this line has some gibberish
Comment: P.S. Anything involving the ASCII table is inherently wrong as well. Because there are a lot of characters in Unicode that belong to the upper and lower case groups. There's lots of languages out there.
Comment: Anything implemented on this logic would treat non-alphanumeric characters as having both upper and lower case by returning true for either case. These other characters are actually without case.

The following code provides a more precise result. This allows a binary answer to be derived as the author requested with the additional advantage of distinguishing characters without case.  `var caseGroup = (character.toLowerCase() == character.toUpperCase() ? 0 : (character == character.toUpperCase() ? 1 : -1));`
Comment: correct detection of UpperCase for letters
`if (isNaN(char * 1) && char === char.toLowerCase() && char !== char.toUpperCase()) {
          alert('letter is UpperCase');
        }`
Comment: what could I do if I just want to validate the lowercase but also I want check if there are more than x number of lowercases?
Comment: `const isUpper = c => c !== c.toLowerCase();`
Comment: The specification mandates that the input be a letter: "How can I test if a letter in a string is uppercase or lowercase". Undefined behaviour in any other case is expected.
Comment: meanwhile for loop
Answer: The problem with the other answers is, that some characters like numbers or punctuation also return true when checked for lowercase/uppercase.
I found this to work very well for it, e.g. "3" will now return false ("3" is lowerCase by default) however consider to filter out numbers with isNaN() and make sure it's actually a string you're testing. Here the code:
function isLowerCase(str) {
    return str === str.toLowerCase() &&
           str !== str.toUpperCase();
}

This will work for punctuation, numbers and letters:
assert(isLowerCase("a"))
assert(!isLowerCase("Ü"))
assert(!isLowerCase("4"))
assert(!isLowerCase("_"))

To check one letter just call it using isLowerCase(str[charIndex])
Comment: Don't know why the other answers are voted.  This is the only solution I could think of as well - the logic being "does the character have upper && lower case variants?  If so then return whether it's upper or lower case"
Comment: @GaurangTandon yeah 2 years after answering I noticed that too, but I didn't notice before because it is wrapped in a for loop, logging something to console and in general not a reusable code snippet so I and (based on the votes on this answer) many other people naturally just skipped the answer. Therefore I think it's good to have this as quick copy-paste answer as opposed to the other answer.
Comment: Sorry but this seems to be a duplicate of another [three year old answer](https://stackoverflow.com/a/9728437).
Comment: Convert the entire string just in order to check the ASCII value of one character? Wasteful.
Comment: function isLowerCase(str) {
        return str == str.toLowerCase()
    }
Comment: I don't understand why you check for != upperCase, what you are checking LITERALLY Should be whether the character, once converted to lowercase remains the same, the character converted to uppercase being different is none of your business IMO.

if you ask me if '3' is lowercase I would say 'yes', and if you ask me if ';' is lowercase I would say yes
your function would fail on the second if clause '3'.toUpper != '3 ==> false
Comment: @E.Serra I would argue '3' and ';' are not lowercase, because there are no uppercase variants. This is also the same how other common APIs work. (Java's Character.isLowerCase for example) Unicode also has character categories like uppercase letters and lowercase letters, where non-letters are not included.
Comment: it depends on situation. If you e.g. analyse a FEN (chess position notation) and check for numbers first, then only characters will be input, where `str === str.toLowerCase()` is enough, but if you have numbers and punctuation in the string, `.toLowerCase()` or the upper version are maybe too early anyway and you should first make sure, you check for a character-only string. A good habit is to use `===` three equals to compare, to avoid JS surprises, or reading seven books about that topic ;) it's always active in my linter.
Comment: @E.Serra to answer your concern: The question is not specific enough to say other answers are wrong. a letter in a string (if containing only characters) can surely be compared by `str === str.toLowerCase()` nobody said anything about punctuation or numbers and special signs in the string ;) That's way it's always a great idea to put a sample or a anonymized equivalent when writing a question. While going for the bullet proof variation is great, what if you need the smallest code portion for your project, because you're e.g. on a TV box with limitations.. we just can assume here...
Answer: if (character == character.toLowerCase())
{
  // The character is lowercase
}
else
{
  // The character is uppercase
}

Answer: const isUpperCase = (string) => /^[A-Z]*$/.test(string)

then :
isUpperCase('A') // true
isUpperCase('a') // false

Comment: Not working with accented characters (á, Á), vowel mutations (öÖ, äÄ, üÜ) and graphemes (ß,ẞ) tho.
Comment: best answer by far, fast, not allocating any memory, or transforming data.
Comment: @latitov what do you mean? This is plain JavaScript.
Comment: Are you sure this is Go, and not JS?
Comment: @MartijnScheffer We actually do not know whether this answer is faster than converting to uppercase and comparing, nor do we even know that we do not allocate any memory. It's pretty much guaranteed that the regular expression will parse the string and allocate a bunch of nodes for the regular expression handling. I think it is also likely that creating the regex parser has more overhead that converting to uppercase, particularly in the one-character string case (but of course without testing we do not know).
Comment: when you convert the case, it will create a new string, yes we know when memory is allocated ! the regular expression will only be created once, how do i know ? i wrote JS compilers, i read most of Spidermoney, and V8, frankly your answer sounds a bit arbitrary, there is no testing needed if you understand how JS engines work allocating memory is a lot more costly than some maths, and regular expressions are highly optimised. if i really needed the best performance i would use a table (a Map in JS)
Comment: Don't use regex for such simple things, it is too slow.
Answer: This will log true if character is uppercase letter, and log false in every other case:
var letters = ['a', 'b', 'c', 'A', 'B', 'C', '(', ')', '+', '-', '~', '*'];

for (var i = 0; i<letters.length; i++) {
    if (letters[i] === letters[i].toUpperCase()
        && letters[i] !== letters[i].toLowerCase()) {
        console.log(letters[i] + ": " + true);
    } else {
        console.log(letters[i] + ": " + false);
    }
}

You may test it here: http://jsfiddle.net/Axfxz/ (use Firebug or sth).
for (var i = 0; i<letters.length; i++) {
    if (letters[i] !== letters[i].toUpperCase()
        && letters[i] === letters[i].toLowerCase()) {
        console.log(letters[i] + ": " + true);
    } else {
        console.log(letters[i] + ": " + false);
    }
}

and this is for lowercase:).
Comment: Unfortunately, there are lowercase letters that don't have an uppercase variant (and probably the other way around as well). The German 'ß' is a lowercase letter, but if you apply the second function on it, it will result in a false.
Comment: Okay, try this: `შეარჩიე კატეგორიების მიხედვით`
Comment: BTW, also works with accented characters like "É", "Ñ", and "ñ".
Answer: function isUpperCase(myString) {
  return (myString == myString.toUpperCase());
}
function isLowerCase(myString) {
  return (myString == myString.toLowerCase());
}

Comment: @zaczap - incorrect. These will transform (and then test) the entire string.
Comment: +1 to the comments - this answer is slightly off, in respect to the original question, which asked about a letter in a string (Not the whole string)
Comment: Let's not forget strict equality checking! === FTW!
Comment: i believe this solution only works if the string is one character long and that character is the character of interest...you'd need to get the character first before calling either of these methods
Comment: @all - correct it will only test against a whole string - you could loop through the letters within a string to test each one.
Comment: You could loop and check each - but that wasn't the question -- :)
Comment: This is the best solution because it supports non-English uppercase characters. For example, uppercase of Polish UTF-8 character "ą" is "Ą".
Comment: @belugabob As far as I know, javascript has no character type. So even `s.charAt(0)` returns a string (with 1 character).
Answer: You could utilize a regular expression test and the toUpperCase method:
String.prototype.charAtIsUpper = function (atpos){
      var chr = this.charAt(atpos);
      return /[A-Z]|[\u0080-\u024F]/.test(chr) && chr === chr.toUpperCase();
};
// usage (note: character position is zero based)
'hi There'.charAtIsUpper(3);      //=> true
'BLUE CURAÇAO'.charAtIsUpper(9);  //=> true
'Hello, World!'.charAtIsUpper(5); //=> false

[Edit jan. 2024] Very old and outdated answer. Here is a more modern approach, using a regular expression with a unicode character escape:

const isUpperCase = str => /\p{Lu}/u.test(str);
const strings2Test = [
  ["hi There", 3],
  ["BLUE CURAÇAO", 9],
  ["Hello, World!", 4],
  ["Hello, World!", 5],
  ["Hello, World!", 7],
];

strings2Test.forEach(s => {
  console.log(`${s[0]} at ${s[1]} (${s[0].at(s[1])}) is upper case? ${
    isUpperCase(s[0].at(s[1]))}`);
});
Comment: @Flame_Phoenix The range `\u0080-\u024F` may contain lower case diacriticals, so the test should also check the character itself.
Comment: @LarsH: I altered (and simplified) the prototype method. Now it includes diacriticals
Comment: Why the comparision `&& chr === chr.toUpperCase();`??
Answer: function isCapital(ch){
    return ch.charCodeAt() >= 65 && ch.charCodeAt() <= 90;
}

Comment: Or just `return (ch.charCodeAt() >= 65 && ch.charCodeAt() <= 90)`.
Answer: With modern browsers you can use regexp and unicode property tests e.g.
/\p{Lu}/u.test("A") // is true
/\p{Lu}/u.test("Å") // is true
/\p{Lu}/u.test("a1å") // is false

More info here:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes

List of general categories here:

https://unicode.org/reports/tr18/#General_Category_Property
Comment: For future me: `/\p{Lu}/u` is equivalent to `/\p{Uppercase_Letter}/u`.
Answer: More specifically to what is being asked. Pass in a String and a position to check. Very close to Josh's except that this one will compare a larger string. Would have added as a comment but I don't have that ability yet.
function isUpperCase(myString, pos) {
    return (myString.charAt(pos) == myString.charAt(pos).toUpperCase());
}

function isLowerCase(myString, pos) {
    return (myString.charAt(pos) == myString.charAt(pos).toLowerCase());
}

Comment: === for best practice
Answer: A good answer to this question should be succinct, handle unicode correctly, and deal with empty strings and nulls.
function isUpperCase(c) {
    return !!c && c != c.toLocaleLowerCase();
}

This approach deals with empty strings and nulls first, then ensures that converting the given string to lower case changes its equality. This ensures that the string contains at least one capital letter according to the current local's capitalisation rules (and won't return false positives for numbers and other glyphs that don't have capitalisation).
The original question asked specifically about testing the first character. In order to keep your code simple and clear I'd split the first character off the string separately from testing whether it's upper case.
Answer: You can also use a regular expression to explicitly detect uppercase roman alphabetical characters.
isUpperCase = function(char) {
  return !!/[A-Z]/.exec(char[0]);
};

EDIT: the above function is correct for ASCII/Basic Latin Unicode, which is probably all you'll ever care about. The following version also support Latin-1 Supplement and Greek and Coptic Unicode blocks... In case you needed that for some reason.
isUpperCase = function(char) {
  return !!/[A-ZÀ-ÖØ-ÞΆΈ-ΏΑ-ΫϢϤϦϨϪϬϮϴϷϹϺϽ-Ͽ]/.exec(char[0]);
};

This strategy starts to fall down if you need further support (is Ѭ uppercase?) since some blocks intermix upper and lowercase characters.
Comment: "Which is probably all you'll ever care about". No. Many people do, and many others should, care about languages other than contemporary English.

Hard-coding the few characters you happen to care about at the time you're writing the function is bad practice.

Also, yes, Ѭ is uppercase (ѭ being the lowercase variant).
Comment: Why the more expensive `exec` followed by double-negation to force to `true`/`false` when you could just use the cheaper `test` and get `true`/`false` directly? `return /[A-Z]/.test(char[0]);` Pretty sure support for `test` is just as old as `exec`, so it should work on any browser `exec` works on (which is basically every browser AFAICT).
Comment: @RobertReiz Really? This doesn't work for non-Roman characters.
Comment: This is missing tons of other locale characters, for example Polish. For this reason the solution that uses comparison against `.toLowerCase()` or `.toUpperCase()` are preferred, as they support most of the locales internally.
Answer: There's a really simple answer, which nobody else has mentioned:
function isLowerCase(str) {
    return str !== str.toUpperCase();
}

If str.toUpperCase() does not return the same str, it has to be lower case. To test for upper case you change it to str !== str.toLowererCase().
Unlike some other answers, it works correctly on non-alpha characters (returns false) and it works for other alphabets, accented characters etc.
Comment: I was about to brag about this discovery, but you were first. It's useful to detect if the first character is uppercase and a letter at once
Comment: Prefer Arthur van Acker's answer: there is no need to waste CPU by _converting_ the entire string to uppercase, just to _check_ whether _one character_ is upper case. You can simply do an ASCII range check on that character. Conversion works, sure, but it's lazy coding.
Comment: @Engineer, but Acker's answer is wrong `"É"` is not lower case.
Answer:
I believe this is the easiest solution.. You can use onchange handler in input field .. to do the validation

const isValid = e.target.value === e.target.value.toLowerCase()

if (isValid) {
  //Do something
} else {
  //Do something
}

Answer: This is straightforward, readable solution using a simple regex.
// Get specific char in string
const char = string.charAt(index);

const isLowerCaseLetter = (/[a-z]/.test(char));
const isUpperCaseLetter = (/[A-Z]/.test(char));

Answer: You can also use this, it will check the string for lower and uppercase
var s = "a"
if(/[a-z]/.test(s)){
  alert ('lower case true');
}

if(/[A-Z]/.test(s)) {
 alert ('upper case true');
}

Comment: Add some explanation with answer for how this answer help OP in fixing current issue
Answer: The best way is to use a regular expression, a ternary operator, and the built in .test() method for strings.
I leave you to Google the ins and outs of regular expressions and the test method for strings (they're easy to find), but here we'll use it to test your variable.
/[a-z]/i.test(your-character-here)

This will return TRUE of FALSE based on whether or not your character matches the character set in the regular expression. Our regular expression checks for all letters a-z /[a-z]/ regardless of their case thanks to the i flag.
So, a basic test would be:
var theAnswer = "";
if (/[a-z]/i.test(your-character-here)) {
  theAnswer = "It's a letter."
}

Now we need to determine if it's upper or lower case. So, if we remove the i flag from our regular expression, then our code above will test for lower case letters a-z. And if we stick another if statement in the else of our first if statement, we can test for upper case too by using A-Z. Like this:
var theAnswer = "";
if (/[a-z]/.test(your-character-here)) {
  theAnswer = "It's a lower case letter."
} else if (/[A-Z]/.test(your-character-here)) {
  theAnswer = "It's an upper case letter.";
}

And just in case it's not a letter, we can add a final else statement:
var theAnswer = "";
if (/[a-z]/.test(your-character-here)) {
  theAnswer = "It's a lower case letter."
} else if (/[A-Z]/.test(your-character-here)) {
  theAnswer = "It's an upper case letter.";
} else {
  theAnswer = "It's not a letter."
}

The above code would work. But it's kinda ugly. Instead, we can use a "ternary operator" to replace our if-else statements above. Ternary operators are just shorthand simple ways of coding an if-else. The syntax is easy:
(statement-to-be-evaluated) ? (code-if-true) : (code-if-false)

And these can be nested within each other, too. So a function might look like:
var theAnswer = "";
function whichCase(theLetter) {
  theAnswer = /[a-z]/.test(theLetter) ? "It's lower case." : "";
  theAnswer = /[A-Z]/.test(theLetter) ? "It's upper case." : "";
  return(theAnswer);
}

The above code looks good, but won't quite work, because if our character is lower case, theAnswer gets set to "" when it test for uppercase, so lets nest them:
var theAnswer = "";
function whichCase(theLetter) {
  theAnswer = /[a-z]/.test(theLetter) ? "It's lower case." : (/[A-Z]/.test(theLetter) ? "It's upper case." : "It's not a letter.");
  return(theAnswer);
}

That will work great! But there's no need to have two seperate lines for setting the variable theAnswer and then returning it. And we should be using let and const rather than var (look those up if you're not sure why). Once we make those changes:
function whichCase(theLetter) {
  return(/[A-Z]/.test(theLetter) ? "It's upper case." : (/[a-z]/.test(theLetter) ? "It's lower case." : "It's not a letter."));
}

And we end up with an elegant, concise piece of code. ;)
Answer: See my comment on the chosen answer. Other solutions that limit to the ASCII table or use the actual character literals completely ignore Unicode and the several hundred other characters there that have case.
This code will set the caseGroup variable to:

1 for Upper Case
-1 for Lower Case
0 for Without Case
var caseGroup = (character.toLowerCase() == character.toUpperCase() ? 0 : (character == character.toUpperCase() ? 1 : -1));

You could bake that into something like this...
    function determineCase(character) {
        return (character.toLowerCase() == character.toUpperCase() ? 0 : (character == character.toUpperCase() ? 1 : -1));
    }

    function isUpper(character) {
        return determineCase(character) == 1;
    }

    function isLower(character) {
        return determineCase(character) == -1;
    }

    function hasCase(character) {
        return determineCase(character) != 0;
    }

Answer: function solution(s) {
var c = s[0];

if (c == c.toUpperCase() && !(c >= '0' && c <= '9') &&(c >='A' && c <= 'Z')) {
    return 'upper';
} else if (c == c.toLowerCase() && !(c >= '0' && c <= '9') &&(c >='a' && c <= 'z')){
    return 'lower';
} else if (c >= '0' && c <= '9'){
   return 'digit'
} else {
  return 'other'
}
}

var str1= (solution('A')) // upper
var str2 = solution('b') // lower
var str3 = solution('1') // digit
var str4 = solution('_') // other
console.log(`${str1} ${str2} ${str3} ${str4}`)

Comment: Please update your answer with some comments about your code and how does it answers the question.
Comment: This code will check the first character of the string for uppercase, lowercase, digit, and other.
Answer: You can test if your array has an upper case or lower case string by using the match          method and regex, below is just a basic foundation to start your test
  var array = ['a', 'b', 'c', 'A', 'B', 'C', '(', ')', '+', '-', '~', '*'];
  var character = array.join('')
      console.log(character)

  var test = function(search){
      upperCase = search.match(/[A-Z]/g)
      console.log(upperCase)

      lowerCase = search.match(/[a-z]/g)
      console.log(lowerCase)
   }

   test(character)

Answer: This is how I did it recently:
1) Check that a char/string s is lowercase
s.toLowerCase() == s && s.toUpperCase() != s
2) Check s is uppercase
s.toUpperCase() == s && s.toLowerCase() != s
Covers cases where s contains non-alphabetic chars and diacritics.
Answer: function checkCharType (charToCheck) {
    // body...
    var returnValue = "O";
    var charCode = charToCheck.charCodeAt(0);

    if(charCode >= "A".charCodeAt(0) && charCode <= "Z".charCodeAt(0)){

        returnValue = "U";

    }else if (charCode >= "a".charCodeAt(0) &&
                charCode <= "z".charCodeAt(0) ){
        returnValue = "L";
    }else if (charCode >= "0".charCodeAt(0) &&
            charCode <= "9".charCodeAt(0)  ) {
        returnValue = "N";
    }
    return returnValue;
}

var myString = prompt("Enter Some text: ", "Hello world !");

switch (checkCharType(myString)) {
    case "U":
        // statements_1
        document.write("First character was upper case");
        break;

    case "L":
        document.write("First character was a lower case");
        break;
    case "N":
        document.write("First character was a number");
        break
    default:
        // statements_def
        document.write("First character was not a character or a number");
        break;
}

Define a Function checkCharType().By declaring the variable returnValue and initialising it to the Character "O" to indicate it's Some other value.
U for uppercase; L for Lowercase ; N for number
Use the charCodeAt() method to get the character code of the first character.
Using if Statement , which check within what range of values the character code falls.
If it falls between the character codes for A and Z, Its Uppercase,
character code between a and z ,Its Lowercase. and so on.
"A".charCode(0)
var myChar = new String("A");
 myChar.charCodeAt(0);
"A" : number code "65"
Check the String
Answer: This checks the ENTIRE string, not just the first letter.  I thought I'd share it with everyone here.
Here is a function that uses a regular expression to test against the letters of a string; it returns true if the letter is uppercase (A-Z).  We then reduce the true/false array to a single value.  If it is equal to the length of the string, that means all the letters passed the regex test, which means the string is uppercase.  If not, the string is lowercase.
const isUpperCase = (str) => {
  let result = str
    .split('')
    .map(letter => /[A-Z]/.test(letter))
    .reduce((a, b) => a + b);

  return result === str.length;
}

console.log(isUpperCase('123')); // false
console.log('123' === '123'.toUpperCase()); // true

Answer: This question has clearly been answered a number of times, but i thought i'd share my solution as I haven't seen it in the given answers.
var lower_case = function(letter){
    lowers = "abcdefghijklmnopqrstuvwxyz";
    return letter === letter.toLowerCase() && lowers.indexOf(letter) >= 0
};

var upper_case = function(letter){
    uppers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    return letter === letter.toUpperCase() && uppers.indexOf(letter) >= 0
};

2¢
Comment: Like that you put in your 2¢
Answer: function checkCase(c){
    var u = c.toUpperCase();
    return (c.toLowerCase() === u ? -1 : (c === u ? 1 : 0));
};

Based on Sonic Beard comment to the main answer. I changed the logic in the result:

0: Lowercase
1: Uppercase
-1: neither
Answer: Assuming that a string is only considered to not be all uppercase if at least one lowercase letter is present, this works fine. I understand it's not concise and succinct like everybody else tried to do, but does it works =)
function isUpperCase(str) {
    for (var i = 0, len = str.length; i < len; i++) {
        var letter = str.charAt(i);
        var keyCode = letter.charCodeAt(i);
        if (keyCode > 96 && keyCode < 123) {
            return false;
        }
    }

    return true;
}

Answer: I need to test against a string of any character (including white space, marks, numbers, unicode characters...). Because white space, numbers, marks... will be the same in both upper case and lower case, and I want to find real upper case letters, I do this:
let countUpperCase = 0;
let i = 0;
while (i <= string.length) {
  const character = string.charAt(i);
  if (character === character.toUpperCase() && character !== character.toLowerCase()) {
    countUpperCase++;
  }
  i++;
}

Answer: Another way is to compare the character with an empty object, i don't really know's why it works, but it works :
for (let i = 1; i <= 26; i++) {
   const letter = (i + 9).toString(36).toUpperCase();
   console.log('letter', letter, 'is upper', letter<{}); // returns true
}
for (let i = 1; i <= 26; i++) {
   const letter = (i + 9).toString(36);
   console.log('letter', letter, 'is upper', letter<{}); // returns false
}

so in a function :
function charIsUpper(character) {
   return character<{};
}

EDIT: it doesn't work with accents and diacritics, so it's possible to remove it
function charIsUpper(character) {
   return character
           .normalize('NFD')
           .replace(/[\u0300-\u036f]/g, '')<{};
}

Comment: It works because the string representation of an object is `[object Object]`. You're basically checking if the character code of the letter comes before `[`. Since the character codes for `Z, [, a` are `90, 91, 97` respectively, the comparison is truthy for uppercase letters and falsy for lowercase letters. In other words, it's an equally hacky way of doing it as using base-36 numbers to get the letters of the alphabet.
Comment: @radulfr Interessting thing, i thought it was something like that but i did not have the exact answer, effectively this method doesn't work with upper case accents but it's possible to unaccent it with something like that : `character.normalize("NFD").replace(/[\u0300-\u036f]/g`
Answer: Simply check the ASCII value
// IsLower verify that a string does not contains upper char
func IsLower(str string) bool {
    for i := range str {
        ascii := int(str[i])
        if ascii < 91 && ascii > 64 {
            return false
        }
    }
    return true
}

Answer: One I use (notice this doesnt make "TestString" as "T est String" or " Test String").
function seperateCapitalised(capitalisedString) {
    if (typeof capitalisedString !== "string" || capitalisedString.length === 0)
        return capitalisedString;

    var newStr = capitalisedString[0];
    for (var i = 1; i < capitalisedString.length; i++) {
        var char = capitalisedString[i];

        if (char === char.toUpperCase() && isNaN(char)) {
            newStr += ' ' + char;
        }
        else {
            newStr += char;
        }
    }
    return newStr;
}

Answer: It can be done in a simpler way.
'a'.charCodeAt(0).toString(2)
=> '1100001'
'A'.charCodeAt(0).toString(2)
=> '1000001'

'A'.charCodeAt(0) & 32
=> 0
'a'.charCodeAt(0) & 32
=> 1

therefore
function isUpperCase(char) {
  return !(char.charCodeAt(0) & (1<<5))
}

// and "tests"
console.assert(isUpperCase('A') === true)
console.assert(isUpperCase('a') === false)

Answer: Stephen Nelsons' function converted to a prototype with lots of test examples.
I've also added whole strings to the function for completeness.
See code for additional comments.

/* Please note, there's no requirement to trim any leading or trailing white
spaces. This will remove any digits in the whole string example returning the
correct result. */

String.prototype.isUpperCase = function(arg) {
var re = new RegExp('\\s*\\d+\\s*', 'g');
if (arg.wholeString) {return this.replace(re, '') == this.replace(re, '').toUpperCase()} else
return !!this && this != this.toLocaleLowerCase();
}

console.log('\r\nString.prototype.isUpperCase, whole string examples');
console.log(' DDD is ' + ' DDD'.isUpperCase( { wholeString:true } ));
console.log('9 is ' + '9'.isUpperCase( { wholeString:true } ));
console.log('Aa is ' + 'Aa'.isUpperCase( { wholeString:true } ));
console.log('DDD 9 is ' + 'DDD 9'.isUpperCase( { wholeString:true } ));
console.log('DDD is ' + 'DDD'.isUpperCase( { wholeString:true } ));
console.log('Dll is ' + 'Dll'.isUpperCase( { wholeString:true } ));
console.log('ll is ' + 'll'.isUpperCase( { wholeString:true } ));

console.log('\r\nString.prototype.isUpperCase, non-whole string examples, will only string on a .charAt(n) basis. Defaults to the first character');
console.log(' DDD is ' + ' DDD'.isUpperCase( { wholeString:false } ));
console.log('9 is ' + '9'.isUpperCase( { wholeString:false } ));
console.log('Aa is ' + 'Aa'.isUpperCase( { wholeString:false } ));
console.log('DDD 9 is ' + 'DDD 9'.isUpperCase( { wholeString:false } ));
console.log('DDD is ' + 'DDD'.isUpperCase( { wholeString:false } ));
console.log('Dll is ' + 'Dll'.isUpperCase( { wholeString:false } ));
console.log('ll is ' + 'll'.isUpperCase( { wholeString:false } ));

console.log('\r\nString.prototype.isUpperCase, single character examples');
console.log('BLUE CURAÇAO'.charAt(9) + ' is ' + 'BLUE CURAÇAO'.charAt(9).isUpperCase( { wholeString:false } ));
console.log('9 is ' + '9'.isUpperCase( { wholeString:false } ));
console.log('_ is ' + '_'.isUpperCase( { wholeString:false } ));
console.log('A is ' + 'A'.isUpperCase( { wholeString:false } ));
console.log('d is ' + 'd'.isUpperCase( { wholeString:false } ));
console.log('E is ' + 'E'.isUpperCase( { wholeString:false } ));
console.log('À is ' + 'À'.isUpperCase( { wholeString:false } ));
console.log('É is ' + 'É'.isUpperCase( { wholeString:false } ));
console.log('Ñ is ' + 'Ñ'.isUpperCase( { wholeString:false } ));
console.log('ñ is ' + 'ñ'.isUpperCase( { wholeString:false } ));
console.log('Þ is ' + 'Þ'.isUpperCase( { wholeString:false } ));
console.log('Ͻ is ' + 'Ͻ'.isUpperCase( { wholeString:false } ));
console.log('Ͽ is ' + 'Ͽ'.isUpperCase( { wholeString:false } ));
console.log('Ά is ' + 'Ά'.isUpperCase( { wholeString:false } ));
console.log('Έ is ' + 'Έ'.isUpperCase( { wholeString:false } ));
console.log('ϴ is ' + 'ϴ'.isUpperCase( { wholeString:false } ));
console.log('Ϋ is ' + 'Ϋ'.isUpperCase( { wholeString:false } ));
console.log('Ϣ is ' + 'Ϣ'.isUpperCase( { wholeString:false } ));
console.log('Ϥ is ' + 'Ϥ'.isUpperCase( { wholeString:false } ));
console.log('Ϧ is ' + 'Ϧ'.isUpperCase( { wholeString:false } ));
console.log('Ϩ is ' + 'Ϩ'.isUpperCase( { wholeString:false } ));
console.log('Ϫ is ' + 'Ϫ'.isUpperCase( { wholeString:false } ));
console.log('Ϭ is ' + 'Ϭ'.isUpperCase( { wholeString:false } ));
console.log('Ϯ is ' + 'Ϯ'.isUpperCase( { wholeString:false } ));
console.log('Ϲ is ' + 'Ϲ'.isUpperCase( { wholeString:false } ));
console.log('Ϸ is ' + 'Ϸ'.isUpperCase( { wholeString:false } ));
console.log('Ϻ is ' + 'Ϻ'.isUpperCase( { wholeString:false } ));


Exact solution of two coupled transport equations

Question: I want to solve the following system
$$\eqalign{
  & y_t = -y_x + z\text{ in }(0,\text{T}) \times (0,1) \cr
  & z_t = z_x + y\text{ in }(0,\text{T}) \times (0,1) \cr
  & y(0,x) = y_0,\,\,z(0,x) = z_0, \cr} $$
I have tried to solve explcitly the fisrt and the second, but the problem is in the coupling, if the coupling is just on one of them there will be no problems. I have tried also to compute the associated semigroup to the system but I didn't get a result. Do you know any method to deal with such a system? Thank you.
Comment: Boundary conditions ought to make an appearance somewhere ...
Answer: Define the vector $X=(y,z)$ and matrices $\sigma_1={{0 1}\choose{1 0}}$, $\sigma_3={{1\; 0}\choose{0\, -1}}$, then the differential equations read
$$X_t = -\sigma_3 X_x + \sigma_1 X.$$
No boundary conditions were specified at $x=0$ and $x=1$, depending on the boundary conditions you could now write the $x$-dependence as a Fourier sine or cosine series. Let me here consider an infinite range for $x$, so no boundary condition is needed. Fourier transformation $X(k,t)=\int e^{ikx} X(x,t)\,dx$ with respect to $x$ gives
$$X_t = (ik\sigma_3+ \sigma_1)X\Rightarrow X(k,t)=e^{(ik\sigma_3+ \sigma_1)t}X(k,0).$$
In components this becomes
$$\begin{pmatrix}y(k,t)\\ z(k,t)\end{pmatrix}=\left(
\begin{array}{cc}
 \cosh \left(q t\right)+(ik/q)\sinh \left(q t\right)& (1/q)\sinh \left(q t\right)\\
 (1/q)\sinh \left(q t\right) & \cosh \left(q t\right)-(ik/q) \sinh \left(q t\right) \\
\end{array}\right)\begin{pmatrix}y(k,0)\\ z(k,0)\end{pmatrix},$$
where I abbreviated $q=\sqrt{1-k^2}$. Notice that the matrix is even in $q$, so there is no ambiguity in the sign of the square root.
Comment: no, I don't see how the method of characteristics can be applied to your system of equations.
Comment: it's the only method I know of.
Comment: Thank you sir. Can I use the method of characterestics on a bounded interval let say (0,1)? If it works, can you give me just a hint. Thank you.
Comment: So the only method is by using Fourier representation ?


Prove that the language $\{a^ib^i | i\geq 0\}$ is not regular? (Do we just consider $a^nb^n$, where $n$ is the pumping length?

Question: I think to prove that $\{a^ib^i | i\geq 0\}$ is not regular, we just have to consider the string $a^nb^n$ (which is in the language) and apply the pumping lemma. But I'm not sure how to proceed using the pumping lemma (even though I know it applies with our choice of string, since the string is at least $n$ long).
Answer: To apply the pumping lemma for regular languages:

You assume some pumping length $p > 0$: Suppose a pumping length $p$.
You pick a string $s$ such that $|s| \geq n$: Indeed, $a^pb^p$ is a good one since $|a^pb^p| = 2p \geq p$.
Now, you have to consider all the partitions of $s$ as $xyz$, such that

$|y|>0$ and
$|xy| \leq p$.

In this case, the 2nd inequality restricts $y$ to contain only $a$'s. Therefore, all the possible partitions are of the form $y = a^k$, $x = a^{p-k-r}$ and $z = a^rb^p$ for $k$ and $r$ such that $k > 0$ and $p \geq k + r$.

For every possible partition of the previous step, you have to show that there is some $i\in\mathbb{N}$ such that $xy^iz$ is not in the language.

Here, consider $i = 0$. Then $xy^0z = xz = a^{p-k-r}a^rb^p = a^{p-k}b^p$.
It is now a matter of showing that $p-k\neq p$, or, equivalently, that $k > 0$ which is already true.
Comment: Apologies for the late response, I just wanted to say thank you! Your response helped my understanding a lot!
Answer: In this particular case, you can use the pumping lemma with any word of length at least $p$ (the pumping length). Indeed, consider any word $w = a^nb^n$, and suppose that we are given some decomposition $w = xyz$ where $y$ is non-empty and $xy^tz \in \{ a^ib^i \mid i \geq 0 \}$ for all $t$ (we don't even need the bound on $|xy|$). If $y$ consists only of $a$'s, then $xy^2z$ will have more $a$'s than $b$'s; if it consists only of $b$'s, then $xy^2z$ will have more $b$'s than $a$'s; and if it consists of both, then $xy^2z \notin a^*b^*$.
If instead of your language we consider the language of all words with equally many $a$'s and $b$'s (but not necessarily in the format $a^*b^*$) then the above argument would fail, and you would have tobe more careful when choosing your word; however, $a^pb^p$ would still work.


Does there exist a maxim which is rooted in morally permissible principles that cannot be universalized?

Question: I'm wondering if there's a maxim that is morally permissible that cannot be universalized, or at least done so consistently under Kantian ethics and his formula of universal law. In Examples of universalizable maxims in Kantian ethics the maxims remain valid when applied universally to everyone.
Comment: According to Kant's categorical imperative, it is morally permissible to "*act only according to that maxim through which you can at the same time will that it become a universal law*". So, by postulation, morally permissible maxims that cannot be universalized do not exist.
Comment: @Bumble If so, it is not obvious from the post. Or according to whom a maxim is supposed to be morally permissible, yet not universalizable "consistently under Kantian ethics". If it is about reconsideration of universalizability by modern Kantians it is up to the OP to clarify that. And they are not so much into finding exceptions as into resolving ambiguity in what is or is not universalizable under different redescriptions so that there are no exceptions after all.
Comment: @Conifold But isn't the question asking whether there are exceptions to Kant's principle?
Comment: How about: Give as much money to charity as your two nearest neighbours put together. This seems 'morally permissible' to me, and would be a splendidly generous thing if some people did it, but it could not be universalised. Or maybe more simply: Whenever somebody does you a favour, do two favours for others.
Comment: From inside the Kantian perspective, as conifold says there can be no exception to Kantian principles. From outside, there are plenty obviously, because those perspective are not bound by Kantian principles. What exactly do you mean by "morally permissible" ? According to who? Nazis thought it was morally permissible to exterminate or enslave "lesser races", which is obviously not universalizable.
Answer: "Act only according to that maxim by which you can at the same time will that it should become a universal law."  The ambiguity is in what you wish to call a "universal law."  Is it simply any universally quantified rule consistent with the specific case, like ∀x ∀y ~Steal(x, y) ?  Or are there more specific conditions?
If it's simply any universally quantified rule, then what prevents ∀x ∀y DaveHaskins(x) ∨  ~Steal(x, y) ?  This seems like a universalization attractive to a career thief named Dave Haskins, and consistent with the maxim he lives by.  In what way is ∀x ∀y DaveHaskins(x) ∨  ~Steal(x, y) less "universal" than ∀x ∀y ~Steal(x, y) ?
"Oh no, but it names a person!" you might object.  Well, it turns out Dave Haskins happens to drive a car with license plate 25306.  So, what prevents him from universalizing in the following way:  ∀x ∀y CarLicensePlate(x, 25306) ∨  ~Steal(x, y).  Perhaps there are others with the same license plate in other states, so it doesn't name only him, but Dave would still be happy with this universal law.
"But you're adding extra conditions!" you might object.  Well, what is this predicate Steal(x, y) but a whole box of conditions saying when an act is stealing or when it is not?  It is only possible to steal what is someone else's property, that they do not give willingly or in trade.  So to give the same meaning as ∀x ∀y ~Steal(x, y), we may say, ∀x ∀y ∀z ~ (OwnsProperty(z, y) ∧ Takes(x, y) ∧ ~GaveWillingly(z, x, y) ∧ ~TradedAway(z, x, y) ).  And really this is not a complete picture; to fully specify the meaning of the word "Steal" we would have to add many more conditions.
So, if adding extra conditions is not a valid objection to Dave's selfish universalization, and neither is the fact that Dave names himself, on what grounds can you object to it?
I'd like to further note that examples like Dave's are common in real life; people invent ostensibly "universal" morality to justify whatever they happen to benefit from.  Social Darwinism comes to mind, or "manifest destiny," or the mandate of Heaven for Chinese emperors, or the justifications for keeping slaves made up by slaveowners.
Answer: Peter Singer's idea that moral progress involves expanding the circle of moral concern, involves development. And suggests other species can become, are becoming moral agents. Such a developing ethic cannot be universalised prescriptively for all times and places, I think. It is an ethic that changes.
Religious ethics often involve a higher standard that can be achieved, such as by saints (or monks or anchorites), bodhisattvas (or the sangha), or the Sikh kalsa. They represent aspirational moral codes. Like the demands on volunteer soldiers, or secret service agents, there are demands on behaviour which cannot be demanded of everyone. We hold police & politicians 'to a higher standard', implicitly making it non-universalisable - we can note that preventing people who's businesses have ever failed from starting new ones, is a massive economic drag, to understand why. Sometimes it's appropriate to demand not a single failure. But also we should not make people' s pasts entirely define them.


Block Adult app recommendations on play store

Question: I always get adult app recommendations (under "Recommended for you") on play store though I have never used one. I find it quite embarrassing. Is there any sort of content filtering possible.
Comment: App recommendation are not only listed based on your app usage. It also depends on your friends/followers on G+ circle. So one of your member in your google plus circle is the culprit here.
Answer: Yes. You can use the "Content Filtering" option in the Play Store settings. Set the maturity level to restrict the apps that you don't want to view.

Screenshot - (Click to enlarge image)
Comment: what about the web interface?
Comment: I could not find any settings from the web interface. Perhaps the settings from mobile device should do the work.


Hardware audio keyboard keys stopped working

Question: I have hardware "volume up" and "volume down" on my Lenovo Thinkpad W530. They used to work to increase and decrease volume. A day or two ago, they stopped working. xev sees them, in settings>keyboard>shortcuts, they are correctly assigned, I can assign other key combinations to change volume and that works, I can also assign the hardware keys to different actions and that does not work. It works for a guest account. Reboot does not help. I am at a loss what might be causing it. Any ideas where to look for causes? This is on 14.04.
Comment: Oddly enough, they work in mpv (but only change the internal mpv volume setting). And they also work in vlc.
Answer: I had exactly the same symptoms with 14.04.
I imagined that VLC had 'grabbed' the media keys so I removed VLC. The problem persisted ...
I followed a reset suggestion that I found on the web:
Open a terminal and enter,
<code> gsettings reset org.gnome.settings-daemon.plugins.media-keys volume-up
 gsettings reset org.gnome.settings-daemon.plugins.media-keys volume-mute
 gsettings reset org.gnome.settings-daemon.plugins.media-keys volume-down
</code>
This didn't seem to have any effect (which is why I closed the page and lost the link!). So I reinstalled VLC. But the next time I used an audio application I discovered that the media keys were working.
Maybe it was just luck and the keys will stop working again, but for now I'm a happy bunny :-)
Comment: Can you add the source to those commands please?
Comment: 'Fraid that I lost the link when it didn't seem to fix the problem straight away.
Comment: Well, the commands can be found in the bug I linked in my answer. It indeed fixes the problem.
Comment: Yeah, this is what happens. Expect it to randomly not work after rebooting.
Answer: Turns out this is a known bug.
Answer: Go to
<code>keyboard>shortcuts>sound and media>
</code>
Then, redefine volume shortcuts (using those volume keys of your keyboard)


Kummer Coverings

Question: Let $L_1$, $\cdots$, $L_k$ be homogenous linear forms in three variables $z_0$, $z_1$, $z_2$ defining $k$ lines in $\mathbb{P}_{2}$. Consider the abelian extension $K
((L_2/L_1)^{1/n}, \cdots, (L_k/L_1)^{1/n}) \supset K:= \mathbb{C}(z_{1}/z_{0}, z_{2}/z_{0})$ with group $G:= (\mathbb{Z}/n\mathbb{Z})^{k-1}$. According to the book Barth-Hulek-Peters-Vandeven (Compact Complex Surfaces, page 240-42), such extension corresponds to a covering $f: X \rightarrow \tilde{\mathbb{P}_{2}}$. Let $P$ be one of the points where at least three lines in $\mathbb{P}_{2}$ meet. Then the lines through point $P$ defines a fibration. I hope to understand the fibration structure. What are the singular fibers and what is the genus of this fibration? If it is any helpful, you may consider the configurations $A_{1}(6)$ (complete quadrangle). Any reference on this is greatly appreciated.
Answer: The answer depends on the integer $n$, on the number $k$ of lines and on the configuration of lines. In section  2.5 of this paper
M. Mendes Lopes, R. Pardini, The geography of irregular surfaces, Current developments in algebraic geometry,  Math. Sci. Res. Inst. Publ. 59, Cambridge Univ. Press (2012), 349–378.  arXiv:0909.5195
you can find a computation for $n=5$ and $A_1(6)$.

Kummer Coverings


How can I change the product that was reviewed?

Question: The customer left a review but it is linked to a different product than the item they reviewed. How can I change it to link to the correct product? v126.96.36.199
Answer: if you go to catalog > reviews and ratings > customer reviews > all reviews ,   you should be able to change the product reviewed.
Comment: No, the product can't be changed by this method. The review can but not the product. I'll have to do it in the database.
Comment: You can alter the product ID related to the review, but that will not update the product's average rating. These are saved separately and would both need to be adjusted.
Comment: The review_entity_summary table keeps the general scores of a product. The ones you see in the list of products.
They are calculated and stored in this table when a review is approved (I think).
The link between the reviews and the scores are kept in the table ratin_option_vote. You have 4 important columns entity_pk_value (that's basically the product id), rating_id (you can have multiple rating criteria) and review_id (this is what you are looking for) and percent (the review score).
the values from this table are displayed in the list of reviews for a product.
Comment: Above comment from here   https://magento.stackexchange.com/questions/61977/how-does-the-magento-database-structure-connect-review-summaries-to-review-detai


Can a batsman be run out after the ball is dead?

Question: Can a batsman be run out after an umpire signals over?
My friend was batting outside the crease, and the ball went to a fielder. He was not taking a run.
The umpire called "Over", and my friend went to talk to the non-striker at his end. Then the bails came off.
Is this Out, or Dead Ball, or something else?
Answer: The meaning of the dead ball is no further actions can be performed after the ball is declared as dead. That means neither batsmen can run nor fielders can run-out them.
See Dead ball - Wikipedia

In cricket, a dead ball is a particular state of play in which the players may not perform any of the active aspects of the game. In other words, batsmen may not score runs and fielders may not attempt to get batsmen out.
Answer: I don't think you can get run out after the umpire signals over. When the umpire signals over, the six deliveries are all finished, and there is no further play.
Answer: Law 22.4 call of over states that

When 6 valid balls have been bowled and when the ball becomes dead, the umpire shall call Over before leaving the wicket.

and Law 23.3 states

Neither the call of Over, nor the call of Time is to be made until the ball is dead.

As umpire already signaled over that means ball is dead and he can't be run out.


Looking for Bipolar Disorder treatment method

Question: My brother and me are ill with Bipolar Affective disorder. My brother's illness is in the severe stage, and we have no idea what to do, medications do not provide improvement. I hope that audio-psycho-phonology should help, I have felt its effects on myself and I trust in it. Also I understand in detail  how it works. We have tried several Tomatis audio courses (playlists) in Russia, but the result is not so good. Now I want to find the best place in the world for Tomatis listening. What Tomatis center do you recommend, where are the the best experts and the most high-tech equipment? As far as I know, the last Tomatis technology is based on 3-channels heaphones, not on 2, and also can provide a real-time voice processing. And what else Tomatis-based (audio-psycho-phonology) methods can you recommend?
Answer: Since Bipolar disorder is a medical condition you and your brother should find a psychiatrist who can manage your pathology optimally.
Even if you trust in this audio-psycho-phonology it is not supported by any scientific evidence so I would advice against using it.
Medical therapy (lithium etc) is essential and could be eventually supported by phycotherapy.
As a side note I would add that Tomatis method has only been indagated in a case-control study on autism and has been proven of none efficacy.
Comment: 1. No one psychiatrist can manage our pathology optimally. 2. Alfred Tomatis was a physician and a scientist. 3. Medical therapy (lithium etc) has almost no influence for my brother. Also we both have little influence of mood stabilizers (which usually is the basis of treatment of bipolar disorder). 4. **The Tomatis method is absolutely the best treatment method for autism.** 5. But our illness is not autism, and now we unfortunately really have not good treatment options
Comment: 1. How can you be sure? 2. Right he graduated in Medicine, but he is not allowed to practice anymore since his methods are not recognized by science. 3. Sad to hear that. 4. This is absolutely not true. Please provide link to evidence. 5. Both autism and bipolar disorder have good treatment options, Tomatis method is not one of them.
Comment: what can you suggest?
Comment: I would find a good psychiatrist.
Comment: +1 especially for the first paragraph, *find a psychiatrist*


What influenced the story and setting of Jean-Luc Godard's Alphaville?

Question: Alphaville is one of my favorite movies. The plot, characters, and narration have always seemed very unique to me. I am wondering what influenced them, particularly the idea of a galactic capital city where a philosophizing computer resides.
Answer: The closest reference to any type of influences on this movie come from the wiki article on this film describing:

Jean Cocteau was one of the artists who exerted significant influences on Godard's films, and parallels between Alphaville and Cocteau's 1950 film Orpheus are evident. For example, Orphée's search for Cégeste and Caution's for Harry Dickson, between the poems Orphée hears on the radio and the aphoristic questions given by Alpha 60, between Orphée's victory over Death through the recovery of his poetic powers and Caution's use of poetry to destroy Alpha 60.  Moreover, Godard openly acknowledges his debt to Cocteau on several occasions. When Alpha 60 is destroyed, for instance, people stagger down labyrinthine corridors or cling blindly to the walls like the inhabitants of Cocteau's "Zone de la mort", and, at the end of the film, Caution tells Natasha not to look back, like Orphée did to Eurydice.

Essentially the style of the film was influenced by an artist that had a similar tone to the movie that helped Godard come up with the tone of the film.
For further reading, there is a book that these references come from that you can get on Amazon.  Most likely an interesting read if you are a huge Godard fan.


egit pull with uncommitted changes

Question: I'm working on a project in Eclipse that was cloned from a GIT remote repository. The Eclipse eGit plug-in allows you to get going without really understanding anything about GIT, which is where I was. I've eventually realized that when I do a "compare with HEAD revision" I'm not as I first thought comparing with the remote repository, but with my local repository. I understand now that I need to pull updates from the remote repository, but it's not clear what will happen to my local changes. I've not committed these changes, partly because I thought I might be updating the remote repository (I realize now that I won't) but partly because I find the Package Explorer file decoration (">") is useful in identifying the files I've modified. If I commit then I assume these indications will disappear.
My questions:

How do I update my local repository without losing my changes?
Can I do this without losing my modified file indicators?

Update: I thought I understood how some of this worked, but I'm really lost now, particularly by the relationship between workspace and (local) repository.
I used Team->Pull to update my repository. Since I've not committed any changes, I expected this to work without conflict, but it flagged up all the changes between the workspace and repo as conflicts (confusion #1).
I assumed I needed to use Team->Synchronize to bring changes into the workspace, as I would with other VCSs. When I do, I see the changes, but not even the non-conflict updates have been applied to the workspace and there is no "Update" operation to do this, so I don't know how to apply them (confusion #2).
For the conflicting updates, I manually merged the changes into the workspace copy and used "Mark as merged", but this seems to do nothing. The conflict is not cleared. I would expect at this point the change would just be an uncommitted change in the workspace (confusion #3).
I read elsewhere that to remove conflicts I should use Team->Add and Team->Commit, but I don't want to commit my changes as I explained originally (confusion #4).
You can see I'm confused! Any help will be much appreciated.
Answer: If git pull does not work, you can use this:
<code>git stash
git pull
git stash apply
</code>
not sure eclipse supports stash, so you may have to use the command line.

egit pull with uncommitted changes


Install in a series - Electric heating thermostats, wireless communicating, 3000W for an Manufactured home/RV

Question: The instructions on the Sinopé GT125-K2 Starter states, "the thermostat must be installed in series". A series meaning the "L1" (hot line in) connects to another outlet on a circuit line? What risks are assumed if the unit isn't installed on a series? Is there a best practice for a non series approach? The unit seems to work well on a dedicated line, no issues so far.
Answer: They mean the switch must always be wired in series with the load. Otherwise, If the switch were in parallel, turning it on would produce a short circuit. The short circuit would be a very bad thing which will (hopefully) trip the circuit breaker and damage the contacts of the thermostat from the large fault current.
The only thing to remember is systems with 240V heat must have double pole thermostats. The reason is here in North America (USA, Mexico, Canada), both hot leads for 240V are live with respect to ground. The thermostat must disconnect both lines when off so the heater is not live when off.


shading issue with bevel modifier

Question: I created this object which has a bevel modifier and a mirror one(x and z axis). The top faces are of the same height so they should shade even but they shade some bumping out as showing in the picture. I tried selecting faces which have not equal to 4 sides and turned out none, so there was no Ngons. Also I checked these was no vertex that unintentionally created and overlaid. So what actually causes this issue?
top view

side view from a certain angle

turn on showing wireframe
Comment: hello could you please share your file? https://blend-exchange.giantcowfilms.com/
Comment: Sure, I uploaded the file https://blend-exchange.giantcowfilms.com/b/92ElDrN1
Answer: It has to do with your Bevel modifier and your Shade Smooth. If you apply the Bevel, you have this topology:

The small face I highlight is slightly tilted compared to the top flat face. As you have shade smoothed the object, Blender tries to smoothly transition from the big face to the slightly tilted small face. As each face is actually made of 2 triangles in a 3D object, and as the top face is rather big and elongated, the transition between these triangles is pretty noticeable, it creates some sort of artifacts.
You can easily fix the problem if you select the top faces:

Then press i to inset, and B to keep the borders stick to the mirror axis:

This time, as the next faces of the top face are flat as well, there is no more noticeable shading problem:
Comment: Your answer is so comprehensive and easy to understand, my huge thanks!

shading issue with bevel modifier


Getting started with interior point methods

Question: I want to learn about the interior point methods. I started with the wiki http://en.wikipedia.org/wiki/Interior_point_method. However, I am having difficulty grasping the idea behind it. Can anyone provide me good links, video tutorials or pointers that can help me understand it?
Answer: Stephen Boyd's lecture notes on convex optimization are a great starting point:
(Lecture 12 here: http://www.stanford.edu/class/ee364a/lectures.html)
Combine that with the textbook (free available here: http://www.stanford.edu/~boyd/cvxbook/) and the corresponding video lectures (http://www.stanford.edu/class/ee364a/videos.html) and you should be good to go.


Has the Doctor appeared in Torchwood or The Sarah Jane Adventures?

Question: I'm wondering if the Doctor has appeared in any episodes of Torchwood or The Sarah Jane Adventures.
I know that I could look through the IMDB episode list or the Wikipedia pages, but those contain a lot of spoilers that I would prefer to avoid, so please also avoid spoilers in your answers.
Comment: Torchwood,season 2, Episode 10, Capaldi plays an underhanded politician... So, not yet Doctor 12 but pretty close...
Answer: Yes, there have been appearances of the Doctor in The Sarah Jane Adventures:

The 10th Doctor appears in the two-part The Wedding of Sarah Jane Smith.
The 11th Doctor appears in the two-part Death of the Doctor.

The Doctor has not (so far) made any appearance in Torchwood, although characters from Torchwood have appeared in Doctor Who:

Captain Jack Harkness appeared first in Doctor Who.
The Torchwood team appear in The Stolen Earth / Journey's End two part story.
The Captain Jack's Monster Files webcast featured Captain Jack profiling Doctor Who monsters/aliens, but at the Torchwood Hub.

The 10th Doctor's companion, Martha Jones, has appeared in Torchwood in Reset, Dead Man Walking, and A Day in the Death. The TARDIS also appeared in End of Days, and the Doctor may have been inside (but he never appeared on screen).
The Doctor's severed hand (from The Christmas Invasion) was found by Captain Jack and appeared in several Torchwood episodes, from the first (Everything Changes) until it was taken by the Master in Utopia.
Comment: Actually, the tenth doctor's hand appears in several episodes of Torchwood. It's Jack's "Doctor Detector", the hand in a jar.
Comment: The Doctor has never appeared in Torchwood, and probably never will. Steven Moffat has specifically said that he and Russell Davies do not want children wanting to watch Torchwood because of The Doctor appearing in it.
Comment: Presumably there will be no more episodes of *The Sarah Jane Adventures* (since Elisabeth Sladen has passed away), so there will be no more crossovers there.  *Torchwood* was created by Russell T Davies, who is no longer executive producer for *Doctor Who*, so it's likely that there won't be more crossovers in the near future there, either.
Comment: I don't think the fact that RTD is no longer involved in Doctor Who necessarily means there will never be crossovers with Torchwood - after all, they're still both made by BBC Wales. However, the fact that the two universes seem to be diverging may well mean that.
Comment: One note: You could say The Doctor technically appeared once in Torchwood at the end of the episode "End of Days". He wasn't seen but in the episode you could hear the TARDIS landing and Jack runs off to find the doctor.
Comment: @AlanBarber the TARDIS appeared.  The Doctor did not.
Comment: @BenjaminFranz  I had heard the same thing, and feel that is a definitive answer to the 'Torchwood' side of the question..  Dr Who has never and *will never* appear in Torchwood.
Comment: The Doctor's Tardis sound has appeared in Torchwood as well.
Comment: It's worth noting that several Torchwood episodes also referred to the Doctor, even though he didn't appear.  There were several references by Jack in early episodes to "finding the right doctor" to fix his immortality.  In the first episode with Martha, they allude to the assumption that the Doctor must have influenced UNIT to hurry through her medical doctorate.  And in Children of the Earth, Gwen posits that the times the Doctor *doesn't* come save the planet, it must be because he's ashamed of humanity.
Answer: I recall seeing him in The wedding of Sarah Jane and The death of the Doctor
Comment: This was already mentioned in the accepted answer.


fit funtion to the Sun electron fluxes data

Question: I'd like to fit a function to the Sun's electrons flux data (blue dots), please note that x,y axis are in the log scale. The green dots are the "best" fit from the gnuplot program. I have taken the a/x as a test function, but in the log scale that is a linear function. Could anyone give me advice which test function should I take? Great thanks for any advice:)
Comment: BTW---$ax^b$ is a line when plotted log--log and collectively these are called "power laws".
Answer: You probably have too few points to get a physically significant fit. To get the curvature on the log scale you might try
$$\ln(y)=a\left(\ln(x)\right)^2+b\ln(x)+c,$$
i.e. fitting a parabola to those points, but it's unclear that that will give you anything of value (it gives the model $y=Cx^{b+a\ln(x)}$ which is pretty ugly).
I would say you're doing this the wrong way round: start with physical considerations to derive some kind of model and then do a fit to see if it works. The problem is that there is probably a large number of different curves that will fit those points well enough, and more so if you allow more than three or four parameters. The only way out (and even then I'd say it's a feeble one) is to get a large amount of data with large precision. Then, if a model with only a few parameters fits all your points within their uncertainty, you're on to something that theory has to account for.
It also depends on what you want your fit to do. Do you expect some kind of theoretical insight? then look to theory. Do you want to interpolate your data? then there are ready-made interpolation algorithms (some, but not all, of which include a polynomial fit to the data, though they are not usually least-squares fits to all the data but rather exact fits to part of the data). Do you want some kind of derivative or integral from that curve? then evaluate it numerically. And so on.
Comment: This it the way to approach the problem as pure mathematics, but fitting without a physics motivation is very rarely a good idea.
Comment: Thank You for a good advices. The best scenario is to get the function describing the data. But I think I have to take polynomials into consideration.
Comment: +1 to dmckee. You won't get a physically meaningful "function describing the data" without some physical insight about what your data is describing.
Answer: In general you don't want to be thinking "How do I fit to this data set?", but rather "What physics do I suspect here and how should I parameterize it?" so that your fit is physically meaningful.
Answer: It would be helpful to include what the x/y axes represent -- the physics of the problem may suggest an answer.
For a generic approach you could just (explicitly) construct $y'=\ln y$, $x'=\ln x$
and then do polynomial fits to this data $x',y'$.
A functional form that might be worth considering is $y = c x^{a +b x}$ which could
give you the curvature you're seeing in the log-log plot, but I'd only go
there if there was some physical motivation for the $x^{bx}$ behaviour.
Comment: the x axis is an energy [MeV] of electrons; y axis is a flux e- cm^-2 s^-1.


Choosing iPhone SDK in latest Xcode: Only 3.0 SDKs are available, but I have 2.0 on disk

Question: After I downloaded the latest Xcode with the 3.1.2 SDK, I can't build and test for 2.2.1 anymore.  I have the 2.2.1 SDK in the proper directory of my Developer folder.
Is there a setting I have to change?
Answer: Yes, to choose an older SDK in the Active SDK popup you have to set either the Base SDK or the Deployment Target build setting of your target to a value equal to or less than 2.2.1.
The Base SDK expresses your intention of what API your code is written for.
The Deployment Target expresses your intention of the earliest iPhone OS you want your app to run on.
The Active SDK is your build-time choice of SDK to use, usually Device vs. Simulator.  But you will fail if you try to build against an SDK that is older than what your code is written for.  If you code is indeed written to compile against older SDKs and/or run on older OS versions, you must express this by setting the appropriate build settings in the Target.  Otherwise the Active SDK popup will limit you to what it knows will work with your code.
Answer: Where are you trying to select it?  As the base SDK?
You should always be linking against the newest SDK version (this is what an Apple engineer told me directly at an iphone dev event) and then set your Deployment Target back as far as you want.  You should be able to set you iPhone OS Deployment Target back to the older SDK version.
This is because Xcode uses weak linking so it will leave out things from the newer SDK on older versions, you do need to do some conditional checking for specific API's/functions using things like respondsToSelector if you are using functionality that has changed across versions.


Local apt mirror just for a single release

Question: With the instructions at https://www.raspbian.org/RaspbianMirrors one can create an apt mirror of raspbian.
This clones the whole repo of packages belonging to all the releases of Raspbian i.e. Wheezy & Jessie.
I am interested in mirroring just the main repo of Jessie.

How should I do that ?
Answer: Fast way (dirty)
Create a file (let's name it exclude.txt) in wich you will list pathes to be ignored by rsync (ex: raspbian/dists/wheezy/), then add the parameter --exclude-from=exclude.txt
It is not clean because it will save disk space, but won't correct the indexes of the DB.
Clean way (slower)
Install and configure apt-mirror. It will maintain a local DB, based on the real content that you had choosen. But it's configuration is out of scope, here.
Answer: Install apt-mirror and configure the archive /etc/apt/mirror.list
Add this lines with just main:
deb-armhf http_mirror_address jessie main

add this line in cleaning section
clean http_mirror_address

And that's it


How to avoid leveling up while training

Question: I'm a late gamer of Fallout Shelter, but I've already read tons of threads around about most of the game aspects. I know that before leveling up a dweller is better to train his/her endurance to the max to further improve their HPs.
My question is: how to prevent them from gaining exp from random events like radroach infestation or fire? I have 3-4 level 1 dwellers training, and it's already occurred a couple of times that a fire bursted out in a room where I didn't have any dwellers to take care of it. It spread out. I managed to move 2 of these fresh dwellers to another room and when the fire has been extinguished they didn't earn any XPs. You do understand I can't move them around every time it happens.
And I know the dweller won't level up until you tap on the arrow, but how do you deal with the training arrow meanwhile? It doesn't show up if you don't let him/her level up first. I thought the respective arrows would've appeared together, that you you could've tapped only the one you needed. But it's not. I just experienced it with one dweller who had to go level 2, and she was training strength. Above her head there was the "ready" text, but only the level arrow was bumping. Once I tapped it, I was able to tap the training arrow to make her proceed with the training.
You got any workaround for this? I don't know if this question has been already posted, I couldn't find anything related. And I hope I made myself clear.
Thank you in advance.
Answer: You must tap the appropriate "level up" arrows in the order that you received them. As noted, a vault dweller will only display one "level up" arrow at a time.
In this case, if your vault dweller levels up their character before leveling up their SPECIAL skills then that is the order that you must advance the character. Vice versa, if you lock your character in a training room and they never encounter a situation which awards them XP then they can safely level up all of their skills before leveling up their character.
Since being awarded XP is what levels up your characters you'll need to do your best to limit situations which could give them XP:

Don't send the vault dwellers you wish to train out into the wasteland, and don't make them guard the door to your vault - both situations they'll risk encountering enemies which provide XP when killed.
Avoid placing them in rooms which are adjacent to dirt. Pests like Mole Rats and Radroaches can only attack rooms that are next to dirt. This means a training room surrounded by other rooms from all four sides cannot be the first target from a creature attack. Pests in adjacent rooms can spread to a fully-surrounded room if allowed to spread unchecked
Avoid "Rushing" production rooms. When a "rush" is failed a crisis occurs. This can mean a fire spreads or a pest attack occurs, both of which award XP to dwellers who resolved the crisis.

Unfortunately, there isn't a way to completely prevent your vault dwellers from encountering a situation that can award XP as a fire can start in any room, and awards XP when extinguished. You'll just have to move the vault dwellers you wish to train to another room for the duration of the emergency.
Since it can't be mitigated entirely, I'd recommend only training one our two vault dwellers at a time as "pure" endurance dwellers. The rest would be have endurance-focused training in which they resolve crises as needed but train the rest of the time. While it isn't 100% optimal, it's a lot less of a headache to move the two "pure" endurance dwellers to another room to avoid an XP-awarding situation than to move ten dwellers.
Comment: Thanks man.

How does it work with power/food/water bars? Here's my vault, I have built two power generators, both 3x and fully improved.

https://i.postimg.cc/NMBQHYmN/IMG-20200210-163047.jpg

Why the power bar notch is more far right compared to food and water? And how can I compensate? Sometimes when I close the game and restart it after some hours, I find most of the rooms on blackout, 'cause power bar has gone red. Should I build another power room?
Comment: That's a whole different question and should be posted using the "Ask a question button". Something like that shouldn't be relegated to the comments. Additionally, don't forget to accept the answer to this post using the gray/green checkmark so other Fallout Shelter players can find it more easily

How to avoid leveling up while training


How do i select a row in a dataGridView? (properly with keyboard)

Question: I have the following code. When i refresh my datagrid the row select is still select (note i only have one select row at a time which is why selectIndex is one value and not a list).
The problem is when i move my arrowkey up or down it starts from the beginning of the datagridview and not the row selected.
<code>            var ret = dataGridView1.Rows.Add(r.orderNo, r.link, r.status);
            dataGridView1.Rows[ret].Tag = r;
            if (r.id == selectIndex)
            {
                dataGridView1.Rows[ret].Selected = true;
            }
</code>
Answer: This seems to solve your problem:
<code>    void SelectGridRow( int rowIndex )
    {
        _grid.Rows[ rowIndex ].Cells[ 0 ].Selected = true;
    }
</code>


Appropriate use of tag wikis

Question: I wrote some text for the tag "design" which discusses some basic concepts about the design process.  I was active on another stackexchange site and know that people added general knowledge and resources to the site tags back then (not sure if that has changed).   I started writing to address a badge requirement and chose design since I have experience in it. After writing it I thought it would make a good answer to a question nobody has asked yet and not be appropriate for a tag.  I'm not sure. However, I do think that if the tag is a wiki it might be appropriate to hold some generic knowledge, especially a bibliography and links to resources pertaining to a subject.
Answer: My understanding about that information is that it should be about the tag and it's use.  Not about the word/process/item itself.
Now that doesn't mean we can't accept that here if there is enough support for it.
It was an excellent 'answer' and in all honesty you could ask a the question and post that answer to it.  Making sure your question is in scope.
Comment: What about reference links.  When I find a good book or reference on a subject I be happy to share that info as a general resource rather have to search for it from scratch when answering a question.  I think questions asking "Where can I find more info on..." could be answered by pointing the asker to the tag wiki. Does this seem out of scope for a tag?
Comment: I'm not sure.  in general the SE sites don't want answers where the bulk of the answer is sending someone away from the site, however, these would be for reference in a less obvious spot.  I could be convinced, but I think we would need more peoples opinions on this.

Appropriate use of tag wikis


Get list of web parts on the client-side

Question: Is it possible to use the Client Object Model or jQuery to get a list of the SharePoint 2010 web parts on a certain part of the page, say those in the DIV #main-content? To be more specific, I'd like to get a handle to the container for each web part in that DIV. Thanks.
Answer: I didn't see the #main-content div in a SharePoint 2010 web part page.  If this is a custom master page and you have it, you could use a jQuery selector like this:
//Set the background color to grey of all web parts in the zone
$('#main-content .s4-wpcell-plain').css('background-color', '#f0f0f0');

It would return a collection of td elements that define the web parts in the zone.

To loop through each td element that was selected:
$('#main-content .s4-wpcell-plain').each(function(){

    //update the header color
    $(this).find('.ms-WPHeader').css('color', 'red');

});

Alternatively, to iterate through all web parts on the page, you could remove #main-content from the selector:
//Set the background color to grey of all web parts on the page
$('.s4-wpcell-plain').css('background-color', '#f0f0f0');

Comment: Thanks, Panter. This is exactly what I needed! How did you know to use the `.s4-wpcell-plain` in the maze of different containers around a web part?
Comment: I had some help from the IE Developer Toolbar.  In the html snippet above, it was the  value of the *id* attribute that made it a good choice.  Glad it helped.
Answer: I have a Codeplex project that does just that:
http://spell.codeplex.com/documentation
It's only version 0.0.1, but works quite well. Of course, it's an overkill in your case, but it could be useful if you need to do other stuff with the Web Parts in the future. As you can see from the documentation, it retrieves for each Web Part the header, body and container.


How to connect remotely to airserv-ng server?

Question: I found a new utils called airserv-ng a have tested him and I have a problem :
I want to use airserv-ng on one computer and airodump-ng on another.
I test that but the problem is when I want to run airserv-ng it is an error that told me to run it in monitor mode.
But when I run it in monitor mode I can't access to this by using ip address (tcp).
Here is the command I tipe on the first computer:
sudo airserv-ng -d wlan0
:(error)(run 'airmon-ng start wlan0')
sudo airmon-ng start wlan0
sudo airserv-ng -d mon0

on the second computer :
sudo airplay-ng -9 (ip):666
(666) it's the default port

the problem is the (ip) because in the first computer the wireless card was set in monitor mode so it haven;t a ip address specified.
There someone can help me to solve this problem please.
Answer: Your airserv-ng machine will need one connection in monitor mode and a second adapter (Ethernet, Bluetooth, or wireless, doesn't matter) for connecting to a network.


My website is being forwarded to another url after 15 seconds

Question: I'm not sure if I was hacked, but my website gets forwarded to a blogger website after 15 seconds.  Here is the URL
https://www.blogger.com/blogin.g?blogspotURL=http://get-yourfree-giftnow.blogspot.com/2016/05/get-your-free-gift-now.html
I certainly didn't insert that in the code and ipage my server host said they have nothing to do with it.  Please help.  Thank you in advance.
-John
Answer: Heres a few ideas to start with:
If you haven't already used https://www.magereport.com to scan for known vulnerabilites it'd be a great place to start with advice on how to fix the issue(s) and will quickly scan them for you.
If that doesnt find it then I'd recommend a tool like http://www.telerik.com/fiddler to see exactly what happens at the http request-response level to see where the issue might be coming from. Either code or DNS. It may give you some url or unique identifier that is the redirect target to search for in your code as well.
Answer: Check the .htaccess file in the root folder of your Magento installation. Could be something in there, or look for any unusual php files in the root folder of your Magento site. Probably something in one of those two items.


Is there any way to run the service in every 15 min in the background for the life time?

Question: We have to schedule the process in which we have to call the API(send user location to server) in every 15 min in all the modes like(In foreground, background, and in kill mode).
We have tried so many solution like:
1.Broadcast Receiver
2.Job Scheduler
3.Work Manager
4.Alarm Manage
But After 1-2 hours our service is stop automatically.
Its behaving differently in different android devices(with different OS also).
We need to run the background process for the life time and call the API in every 15 min.
Please Suggest
Comment: There is not such thing as life time . Your best shot is Work manager one time Job and set subsequent job after its completed. This is also because there is a need of a Network Constraint in your case. On other hand Foreground  service is a bad idea in this case .
Answer: For location update, you can use fused location provider to get location.
In this codelab, task 4.2: https://codelabs.developers.google.com/codelabs/advanced-android-training-device-location/index.html?index=..%2F..advanced-android-training#5. \You will see create location request, you can set interval for it. And for run in background use JobIntentService or Work Manager will solve it. I need more info about your code, i understand why it not work.


Isolated power supply: Protective earth connected to secondary ground

Question: We are developing a device that contains an isolated AC/DC power supply, from mains voltage to 3.3V. A colleague wants to connect the protective earth (chassis ground) to the secondary 3.3V side ground via the screw holes in the pcb, allegedly for EMI reasons. The 3.3V is used for the internal electronics, but we will also have a terminal block type I/O connector connected to the secondary side, that people will be able to connect cables to. The chassis itself will be made out of plastic. I have very limited experience with isolated AC/DC power design, but this grounding scheeme makes me a bit nervous. I have never encountered an isolated AC/DC power supply where the primary and secondary have the same earth reference. Are there any potential problems in terms of performance or in terms of safety or other compliance testing that we will need to go through that is overlooked with this grounding scheme?
Comment: It's used all the time.
Comment: Some power supplies (SMPS types) could have issues with regulation if the output ground is connected to earth, with certain settings. Make sure the power supply is intended for this or in case of doubt, that it works perfectly in all situation.
Answer: Your standard desktop PCs do it and have done for some 40 years now, among many other devices.
Just be sure what you really say or need when you say you need to have an isolated supply.
Sure, it provides safety and isolation from live, but it does not have a floating output.
So be sure if you just want a supply and it can be non-floating isolated supply, or do you require a floating isolated supply.
Power supplies you buy come with data sheets and manuals how to install and use them. If this power supply even allows to connect mains input earth and 3.3V output ground together with screw holes, it may even be the intended mandatory operation of the power supply.
Some supplies require mains earth and some don't.
The ones that don't require it may still need EMI filtering circuits and referencing the output to mains side, one way or another.
So any safety and compliance issues won't happen if power supply is connected and wired according to manufacturer instructions.
In itself, connecting mains earth to power supply output ground is not a safety or compliance issue, it may even help with safety and compliance.
It's just that connecting mains earth to supply output ground may be annoying depending on situation, especially if you want to avoid ground loops, as then the supply does not float as it has a reference to earth.
Answer:
I have never encountered an isolated AC/DC power supply where the primary and secondary have the same earth reference.

You must have encountered a tower or a mini-style PC, or a point-of-sale (POS) system. They all have it set up this way.
OTOH, it's not only unnecessary but sometimes impossible in double-insulated systems. There, there's only a capacitive coupling between the primary and the secondary.


What database should I use?

Question: I am a high-school students who is learning about data science in his free time. I have gotten a neural network to work which is able to solve xor problems. My neural network uses sigmoid as the activation function for both the hidden and output layers. It also has only one hidden layer. I am wondering about what would be the best simple problem which I could solve with my neural net. I would like a database in which there is a probability output or something similar since I've had problems converting sigmoided output to normal values. I have looked on the UCI machine learning repository but have found nothing witch has caught my eye. I would appreciate any help! :)
Comment: No dataset i heard of has probability output in the sense you are asking? Can you clarify what is it you need?'
Answer: Search "dataset" instead of "database".
see these:

A Neural Network from Scratch in just a few Lines of Python code
Multi Layer Neural Networks with Sigmoid Function Deep Learning for Rookies
Answer: Try working with MNIST dataset if you are new to neural networks. Also, converting sigmoid function outputs probabilities which you can convert to class labels using argmax function. For ex: If you have 2 classes to classify then your network will output probability for true class using sigmoid which you can convert to labels as 0/1 using argmax. Hope it helps!

What database should I use?


Multilevel modelling, repeated measure with SPSS

Question: I am trying to fit a multilevel model for a longitudinal repeated measure design with two levels: I have 50 participants with a continuous dependent variable that was measured at three time points. When I add "time" as a predictor in the model, its fixed effect is not significant (which means there is no change over time) but when I add both time and time squared (quadratic), both are significant. By plotting the data it is quite clear that the growth curve is u-shaped and I can see reduction at the second timepoint and then increase in the dependent variable which returns to the baseline values. I wanted to know whether it is correct to add "time squared" to the model even when "time" is not significant, and then to report that there is no change over time but there is a significant reduction at the second time point?
Answer: First: "its fixed effect is not significant (which means there is no change over time)" - this is not correct. It is a common misinterpretation of non-significance.
Second, there's nothing special about multilevel models when it comes to non-linear effects. The way that you should consider them is the same way as you should in least squares regression. So yes, it's correct to add time squared, even though time is not statistically significant.
Comment: Thanks for your reply. One more question. If I add time squared to the model, is it a necessity to add it to all interaction terms, too? I need to add a cross-level interaction to my model (between time and group (coded 0 and 1)) but I am not sure if I must also add interaction between group and time squared term.
Comment: You don't have to add the non-linear interaction.
Comment: The linear interaction says "Does the slope change", the non-linear says "Does the rate of change of the slope change."


Does calling a read function with input leave any trace?

Question: I want to call a read function which does a calculation and returns a result. It is important that the input will not be saved on the blockchain.
If I were to use a write function then even if there isn't a state change (i.e., I don't save a variable) the transaction will forever be present on the blockchain with the secret input.
How does it work with read a call? I'm confident that it isn't a transaction and does not propagate and thus does not remains on the blockchain. Is it running by the node I communicate with and leaves no trace then? and if so is it stored in some node caching mechanism for a while (e.g., in commonly used software like Geth) and can it be accessed by someone?
Answer: You can do calculations, read global variables (not edit), make local variables in a function to be called without showing any trace in blockchain.
When you call read function below, it will not be saved in the blockchain:
<code>//SPDX-License-Identifier: MIT
pragma solidity >0.7.0 <0.9.0;
contract calculate{
    int something=10;
    function read(int a) view public returns(int){
        int square=a*a;
        int cube=square*a;
        return cube*something/10; // round off to integer
    }
}
</code>
<code>// web3JS
var MyContract = new web3.eth.Contract(abi, address);
MyContract.methods.read(1234).call()
.then(console.log);
</code>
Also, Float is not allowed in solidity, so if u will use PI(3.14), or want decimal output, then you will get round off integer.
Provide codes in question for detailed answer.


Reduce diameter of a dowel (preferably efficiently)?

Question: I've got some dowels whose diameters are slightly bigger than what I need, and I don't want to purchase some smaller ones since I'm on a tight budget. Does anyone know how to reduce the diameter throughout the length of the dowel, preferably efficiently? I only need to reduce the diameter throughout the dowel by 0.25~0.5 cm.I was thinking maybe I can sand it down either with sanding paper, file, electric sander or a electric belt sander, but am not sure whether it will work or will be time efficient (the project is slightly in a rush). Many thanks.
Comment: I haven't tried this, so your mileage (kilometerage?) will undoubtedly vary... there are commercial dowel plates ( http://www.leevalley.com/us/wood/page.aspx?p=70555&cat=1,42524 ) that you could probably mimic by drilling a hole through reasonably thick (~4mm) steel plate.
Comment: While this is not the question you asked most of the answers still apply here.
Comment: @Matt, I agree that some of the answers to that other question apply here, but I don't think it's a duplicate.  This question assumes you have a dowel already, but it's just a bit too big.
Comment: @grfrazee True. But several of the answers work for making a smaller dowel out of a larger. Pencil shaver and dowel plate for example. Seems like a good dupe to me. The questions dont have to match for a good dupe target.
Answer: While you can sand dowels to reduce their diameter it's not the most efficient method even to take off just a millimetre or two, and it's difficult to ensure consistency along the length. Especially since you want to remove as much as 5mm I think you'd be much better of using a cutting rather than a sanding operation, following the rule shavings > dust where possible.
So I think your best option here would be to rig up a simple dowel-cutting tool, which at its most basic requires one piece of wood, a sharp edge of some kind and two clamps to hold everything in place.
Here are a few different iterations of the concept:

And a few links for more details:
Tim Manney's site
Lumberjocks
Woodgears
Comment: dont think i've come across this tool many times before, will check it out.
Answer: Chuck the dowel in a drill and make a jig. Two pieces of wood 90 degrees. Glue sandpaper to them and then turn on the drill. Depending on how much you want to take off and it doesn't sound like much I would use a lighter grit. Good luck.
Comment: that sounds quite creative, I'll try it
Comment: The only drawback to gluing the sandpaper to the wood is that you're going to wear out the sandpaper pretty quickly (especially with hardwood dowels), and replacing glued down sandpaper will be a pain.
Answer: As you suggested, the simplest way is sanding. I would start with a coarse grain sand paper (60 or lower) to get the bulk of the material removal, since 2.5 to 5 mm is quite a bit to sand away. The best way to reduce the diameter evenly is to put the dowel in a drill, then spin the drill while at the same time holding the sand paper to the dowel.
A few suggestions:

Don't hold the sand paper with your hand - it will get very hot very fast. Use a thick glove, or better yet, a concave piece of wood to hold the sand paper. Going slower with the drill will help with this.
If the dowel is thicker than what can fit in the chuck of the drill, shave off at the tip of the dowel until it does. This will cost you a few CM off of the length of the dowel.
If the dowel is fairly long, you should brace it on the other end. The simplest way would be putting the end of the dowel through a round hole in a piece of wood.
Comment: Yes, you are right. I always got the two confused. Corrected.


PHP Twitter Oauth for just retrieving feeds

Question: So I've been using Twitter PHP LIB for pulling user tweets & followers tweets. OpenAuth seems like overkill for this as I need to get the site itself to register for authentication.
Is there a simple library that I can use? Perhaps a basic Oath if you don't need authentication by the user at all?
Should I simply pull the RSS?=
Answer: I made my own Twitter OAuth library. It still uses OAuth but the library is very small.
Also, you still need to register an app for it and get the access token.
If you want to check it out, here is it: I Just Want to Call Twitter's API With My Own Account!
Basically you need the consumer key, the consumer secret, the access token and the access token secret, so you have to register your application at [dev.twitter.com] (http://dev.twitter.com/) using the user you want to authenticate, then you will get the first 2. On the same page, click on "My Access Token" and you will get the last 2.
Then you can:
$api = new OAuthDamnit(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
echo $api->get('http://api.twitter.com/1/statuses/home_timeline.json', array());

There are other alternatives such as using PHP's OAuth Extension which I think might be faster, but is is also very simple to use.
$oauth = new OAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauth->setToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$oauth->fetch('http://api.twitter.com/1/statuses/home_timeline.json');
echo $oauth->getLastResponse();

Or if you don't want to use OAuth at all, you have Simple Auth Twitter which can act like a basic auth gateway.
You just have to sign it there and it will give you an API key. You use that as your Twitter password and use http://simpleauthtwitter.heroku.com/api/ as the API endpoint.
Comment: You will need to request the url:
http://api.twitter.com/1.1/statuses/home_timeline.json

The API version is now 1.1


What size of plant pot should I be using for young chili plants?

Question: I have 4 small chili plants (sorry not sure what variety they are), they have 3 sets of leaves. I re-potted them from a seed tray about 2 weeks ago. I'm a bit concerned the plant pot is too big? When growing from seeds how many times should I re-pot and into what sizes?
Answer: That would be the smallest pot I would use for those plants. I only re-pot once (from the seed tray). Of course re-potting disturbs them and sets them back a bit. Also the roots can get tangled (hence the disturbance).
Over the last 2-3 years, I've come to the realization that peppers do much better in raised beds or normal beds, rather than pots. I have had reasonable size adult plants in pots that size or larger (pepperocini come to mind, although this year's are slow growing), but they tend to be the exception.
Ornamental peppers seem to do fine in pots as well, but ornamentals are generally smaller plants to start with.
Of course pots might be the only option, in which case I think you have to live with smaller plants and less fruit.
Comment: Yes I think so: more room for the roots. Also it seems the water is more uniform - plants are not as susceptible to drying out.
Comment: Why do raised beds or beds matter - more room?
Comment: You I have too many plants in one pot?
Comment: Probably? There is a certain amount of subjectiveness. I have five pepperoncini plants in each of my 16in pots on the deck. The largest two are of course the two which have grown together (ie. the seeds must have been almost touching, so I transplanted them together). Also the ornamental 'poinsettia' pepper (rectangular pot but many more plants / less root space) are giving them a run for the money in the height stakes.
Answer: To me that pot looks about big enough for 1 plant. And only with daily watering care if it is hot. Even if that many plants "work", you won't get more peppers from them than from 1 big healthy plant.
I usually repot once directly to my main growing locations. I may put left overs into medium sized joghurt cups to give away or repot again eventually, but there seems to be no difference in which plants do better.
Answer: I think the pot is big enough.  I am growing about 6 or 7 plants in a pot smaller than that.  I get about 3-4 chillies every month from each pot( i have 3 pots) . Its my first time planting chillies and I don't know how much they grow.  They have stopped growing now and they are about 1.5 feet high.  I think your pot is big enough.