Replacing a string parameter with a List for a recursive method

Question: I was struggeling with a probably simple problem for the last 3 hours. I rewrote a class and replaced 2 String parameters with Lists.
The problem is, that when calling the rekursive method you add 1 character to the first string parameter. And when the length of the parameter hits the length of 7 it prints it out. The string never gets longer than 7.
I replaced it with a Integer List since the String only consisted of numbers.
The List though keeps getting longer and longer and I have no idea why. I hope I explained everything properly. If not, ask me please.
The question is probably super easy to answer for you guys.
Here is the first class, that works.
<code>    package Uebung4;

public class PermAll_Alt {

static int counter = 0;

private static void permutation(String word, String str) {

    int n = str.length();

    // System.out.println(str + " Str");
    // System.out.println(word + " word");

    if (n == 0) {

        if (

        (Integer.parseInt(word.substring(0, 1))) > (Integer.parseInt(word.substring(1, 2)))
                && (Integer.parseInt(word.substring(1, 2))) < (Integer.parseInt(word.substring(2, 3)))
                && (Integer.parseInt(word.substring(2, 3))) > (Integer.parseInt(word.substring(3, 4)))
                && (Integer.parseInt(word.substring(3, 4))) < (Integer.parseInt(word.substring(4, 5)))
                && (Integer.parseInt(word.substring(4, 5))) > (Integer.parseInt(word.substring(5, 6)))
                && (Integer.parseInt(word.substring(5, 6))) < (Integer.parseInt(word.substring(6, 7)))

        ) {
            // System.out.println(word);
            counter++;
        }

    } else {
        for (int i = 0; i < n; i++) {
            // System.out.println("Word: " +word+"\t str charat:
            // "+str.charAt(i));
            // System.out.println(word + str.charAt(i) + " \t combined");

            System.out.println("substr(0,i): " + str.substring(0, i) + " substr(i+1) " + str.substring(i + 1));
            permutation(word + str.charAt(i), str.substring(0, i) + str.substring(i + 1));
        }
    }
}

public static void main(String[] args) {
    permutation("", "1234567");
    System.out.println("Anzahl:  " + counter);
}
}
</code>
And here is my class that I edited:
<code>package Uebung4;

import java.util.ArrayList;
import java.util.List;

public class PermAll {

static int counter = 0;

private static void permutation(List<Integer> wordList, List<Integer> lis) {

  //  List<Integer> wordList2 = cloneList(wordList);

    int n = lis.size();

    if (n == 0) {
        String word = "";
        for (Integer i : wordList) {
            word += i;
        }

        if ((Integer.parseInt(word.substring(0, 1))) > (Integer.parseInt(word.substring(1, 2)))
                && (Integer.parseInt(word.substring(1, 2))) < (Integer.parseInt(word.substring(2, 3)))
                && (Integer.parseInt(word.substring(2, 3))) > (Integer.parseInt(word.substring(3, 4)))
                && (Integer.parseInt(word.substring(3, 4))) < (Integer.parseInt(word.substring(4, 5)))
                && (Integer.parseInt(word.substring(4, 5))) > (Integer.parseInt(word.substring(5, 6)))
                && (Integer.parseInt(word.substring(5, 6))) < (Integer.parseInt(word.substring(6, 7)))

        ) {
            System.out.println(word);
            // convertToDU(word);
            counter++;
        }

    } else {

        for (int i = 0; i < n; i++) {
            List<Integer> tempLis = new ArrayList<>();

           //String tempString = "";

            for (int j = 0; j < i; j++) {
                tempLis.add(lis.get(j));
            }
            System.out.print("str.substr(0,i): " + tempLis+"\t");

            for (int k = i + 1; k < lis.size(); k++) {
                tempLis.add(lis.get(k));
                System.out.print(""+lis.get(k)+", ");
            }
            System.out.println(tempLis);

            // System.out.println("word "+wordList + "\t charat:
            // "+lis.get(i));
            wordList.add(lis.get(i));

          //  System.out.println(wordList + " \t kombiniert");

            permutation(wordList, tempLis);
            // permutation(word + lis.get(i),tempLis);
        }

    }
}

public static void main(String[] args) {

    List<Integer> list = new ArrayList<Integer>();

    int anzahl = 7;

    for (int i = 1; i <= anzahl; i++) {
        list.add(i);
    }

    String para = "";
    for (Integer i : list) {
        para += i;
    }

    List<Integer> abc = new ArrayList<>();

    permutation(abc, list);
    System.out.println("Anzahl:  " + counter);

}
}
</code>
Answer: Here is a solution: I took the code that was doing the recursive call in the String args version and copied the logic to the List args version:
<code>        for (int i = 0; i < n; i++) {
            // create a copy of wordList
            List<Integer> permWordList = new ArrayList<Integer>(wordList);

            // equiv to "word + str.charAt(i)"
            permWordList.add(strLis.get(i));

            // create a copy of lis
            List<Integer> permStrList = new ArrayList<Integer>(lis);

            // equiv to "str.substring(0, i) + str.substring(i + 1)"
            permStrList.remove(i);

            permutation(permWordList, permStrList);
        }
</code>
Comment: you need to create copies of wordList and lis so that you get a fresh copy with each iteration (otherwise, lis will get smaller and smaller)
lastly, please show your appreciation by accepting and/or upvoting...
Comment: Seems to work just fine. Thanks a lot! Can you also give me some explanation, why I had to copy the List "lis"? Genius idea with removing just the element i in the one list instead of counting around i. I feel stupid for not seeing that.


R ggplot2 boxplot order by 2 factors and assign colors

Question: I have a data formatted like following:
name          site  numb  env        value     order1  order2 color
K_005_AllHuman  K   5     human       0.02941166    1   1   black
K_005_bacteria  K   5     bacteria    0.02941166    1   2   grey
K_005_oral      K   5     oral        0.02941166    1   3   blue
K_005_env       K   6     environment 0.02941166    1   4   green
K_006_AllHuman  K   6     human       0.02941166    1   1   black
K_006_bacteria  K   6     bacteria    0.02941166    1   2   grey
K_006_oral      K   6     oral        0.02941166    1   3   blue
K_006_env       K   6     environment 0.02945052    1   4   green
K_006_pathogen  K   6     pathogen    0.02945052    1   5   red
K_013_AllHuman  L   13    human       0.02928835    2   1   black
K_013_bacteria  L   13    bacteria    0.02870488    2   2   grey
K_013_oral      L   13    oral        0.02870488    2   3   blue
K_013_env       L   13    environment 0.0283742     2   4   green
K_023_AllHuman  L   23    human       0.0283742     2   1   black
K_023_bacteria  L   23    bacteria    0.0283742     2   2   grey
K_023_oral      L   23    oral        0.0283742     2   3   blue
K_023_env       L   23    environment 0.0283742     2   4   green
K_023_pathogen  L   23    pathogen    0.0283742     2   5   red

I want to plot the data in boxplots, such that boxes are forst ordered by the site name, within this, they are ordered by the numb column, and lastly they follow ordering of env column. Finally, I want to assign to the boxes colors as in color column.
I managed to produce ordering, but still the plot doesn't look like I wanted it to (no to mention colors, which get completelty mingled, when assigned manually, since each sample doesn't allways have all of the facto level of env column).
Here is the code I produced till now:
    c_df$name <- factor(c_df$name, levels = c_df$name[order(c_df$numb)])
c_df$site <- factor(c_df$site, levels = c_df$site[order(c_df$order1)])
c_df$env <- factor(c_df$env, levels = c_df$env[order(c_df$order2)])

p <- ggplot(data = c_df, aes(x = name, y = value, fill=env)) +
     geom_boxplot(outlier.size=NA) + theme_bw()
p + theme(axis.title.x =element_blank(),
          axis.text.x = element_text(angle = 90, hjust = 1, size =12),
          legend.position="none") +
     ggtitle("DeltaD") +ylab(expression(delta[d]))

Comment: change the argument `fill=env` to `fill=color`? For the ordering you can try:  `c_df <- c_df[ order(c_df$site, c_df$numb, c_df$env), ]`
Comment: You could use @Jimbou's ordering code `c_df <- c_df[ order(c_df$site, c_df$numb, c_df$env), ]` then create a factor of the `numb` column
`c_df$Numb = factor(c_df$numb)` then use an interaction in the fill `ggplot(c_df, aes(site, value, fill = interaction(Numb, color)))+geom_boxplot()`
Answer: In the plot below, to get the desired ordering, I turn name into a factor after ordering it by name then site then env.
To get the desired colors, I use scale_fill_manual to map the desired colors to each of the possible values of env. Adding a column with color names doesn't work because ggplot doesn't get the color names from the data. Rather, it maps the categories in a data column to a default color palette that is the same for all categorical variables, regardless of what the values of those variables happen to be called. To set the colors to different values, you need to use one of the scale_fill_*** functions.
Also, it looks like in the bottom half of the data the name should start with "L" rather than "K" so I've made that change. I don't think you need the order1, order2 or color columns.
The code to read in the sample data is at the bottom of this answer.
# Bulk up data frame so that we'll have more than one measurement per boxplot
c_df = rbind(c_df,c_df,c_df,c_df)
c_df$value = rnorm(nrow(c_df), 10, 5)

# Order name by site, numb, and env
c_df = c_df[order(c_df$site, c_df$numb, c_df$env),]
c_df$name = factor(c_df$name, levels=unique(c_df$name))

ggplot(data = c_df, aes(x = name, y = value, fill=env)) +
  geom_boxplot(outlier.size=NA) +
  theme_bw() +
  theme(axis.title.x =element_blank(),
        axis.text.x = element_text(angle=90, hjust=1, vjust=0.5, size=12),
        legend.position="none") +
  ggtitle("DeltaD") +ylab(expression(delta[d])) +
  scale_fill_manual(values=c("grey","green","black","blue","red"))

As another option, the plot might be easier to read with faceting. For example:
ggplot(data = c_df, aes(x = env, y = value)) +
  geom_boxplot(outlier.size=NA) +
  theme_bw() +
  facet_grid(. ~ site + numb, scales="free_x", space="free_x") +
  ggtitle("DeltaD") + ylab(expression(delta[d])) +
  labs(x="Environment") +
  theme(axis.text.x = element_text(angle=90, hjust=1, vjust=0.5, size=12))

ggplot(data = c_df, aes(x = site, y = value)) +
  geom_boxplot(outlier.size=NA) +
  theme_bw() +
  facet_grid(numb ~ env) +
  ggtitle("DeltaD") + ylab(expression(delta[d])) +
  labs(x="Site")

The best combination of faceting and fill choices will depend on what you're trying to show, whether or not there are lots of empty categories for various combinations of columns, etc. For example, your sample data has at most one site per numb, so a lot of the boxplot "slots" are empty in the second faceting example above, but perhaps your real data has more category combinations present.

Read in sample data:
c_df=read.table(text="name  site  numb  env  value order1  order2 color
K_005_AllHuman  K   5     human       0.02941166    1   1   black
K_005_bacteria  K   5     bacteria    0.02941166    1   2   grey
K_005_oral      K   5     oral        0.02941166    1   3   blue
K_005_env       K   6     environment 0.02941166    1   4   green
K_006_AllHuman  K   6     human       0.02941166    1   1   black
K_006_bacteria  K   6     bacteria    0.02941166    1   2   grey
K_006_oral      K   6     oral        0.02941166    1   3   blue
K_006_env       K   6     environment 0.02945052    1   4   green
K_006_pathogen  K   6     pathogen    0.02945052    1   5   red
L_013_AllHuman  L   13    human       0.02928835    2   1   black
L_013_bacteria  L   13    bacteria    0.02870488    2   2   grey
L_013_oral      L   13    oral        0.02870488    2   3   blue
L_013_env       L   13    environment 0.0283742     2   4   green
L_023_AllHuman  L   23    human       0.0283742     2   1   black
L_023_bacteria  L   23    bacteria    0.0283742     2   2   grey
L_023_oral      L   23    oral        0.0283742     2   3   blue
L_023_env       L   23    environment 0.0283742     2   4   green
L_023_pathogen  L   23    pathogen    0.0283742     2   5   red",
                header=TRUE, stringsAsFactors=FALSE)


Code in the template or in a module?

Question: Is it better to write hook functions in template.php (or a .inc in my theme folder) or is it better to put them in custom modules?  Or, does it matter?  Is it just a matter of organizational preference?  Does it depend?
Answer: Id say its simple case of organisation and relevance. Hooks fit into three different categories, alter, process and theme so probably best to organise these into separate include files.
inc/
template.alter.inc
template.process.inc
template.theme.inc

If your going to add a class to a button in a certain contrib module or similar then obviously creating a custom module is overkill.
Probably the best strategy to have is to work on the theme layer and it will soon be apparent if its worth putting the relevant code into its own module. Either way, you have achieved what you wanted.
Does it matter where the code is? Probably not, it's a few checks or calls wherever it is. Your probably get many an argument on best practices from various developers on this.
Comment: I'd argue 'relevance' is the key word in there...if the hook implementation will alter the display of something non-generic, it should go in the theme. If the functionality is global (potentially theme-independent) then it goes in a module. But yeah, you'll probably get differing opinions on this
Comment: It can matter where code is.  Code in a module runs on all pages; code in a theme only runs when the theme is being used on a page.  I typically do have a theme-specific module for every theme I make to handle heavy lifting, but will check `$GLOBALS['theme_key']` as needed.  Some base themes (eg, Omega) have some fancy methods for splitting things out into includes.  These are worth looking at for inspiration.
Comment: small tweeks in display of node data, i tend to just go with `template.php`. anything more substantial like altering some hook or building a report, i put in its on mod. i guess i look at mods as functionality and `template.php` as display.
Comment: thanks @Alex Gill, @Clive and @austin. It seems like there's some consensus around using `template.php` (or related incs) for narrowly scoped, lighter-weight customizations and reserving custom modules for broadly-scoped heavy-lifting.  Sometimes `template.php` hooks can contain content related alterations, like adding Ajax to an element.  Which still seems like a `template.php` thing because it's fairly simple and scoped to the display of a specific element.  Anyway, thanks again for the comments.
Answer:
Is it better to write hook functions in template.php, or is it better to put them in custom modules?

First off, themes can just implement theme functions, or alter hooks; themes cannot implement hook_user_load(), hook_node_update(), or hook_menu(), which are not alter hooks (i.e. hooks whose names end in _alter, such as hook_form_alter()).
As for implementing a functionality in a theme, or in a module, I would rather implement the functionality in a theme if it is dependent from the theme. If the functionality must be present independently from the theme, then it should be implemented in a module. The latter case is also true when the functionality needs to be implemented when the enabled theme is one between two, or three possible themes.

Code in the template or in a module?


What type of strings to use for easier bending in fast solos?

Question: I'm getting better at playing that legendary Enter Sandman solo by Kirk Hammett, and I'm getting the speed part almost covered. What I'm struggling with is hitting the target note when bending that last high D note all the way up to E. My fingers are close to bleeding.
I have a few questions (first post in MP&P, please be gentle if I am out of line!)

Are there specific strings that are easier to bend? (I'm a complete newbie with string types)
Do you know which strings Kirk Hammett used when recording that song? Should I try them?
Any other techniques to get better at bending? Just muscle power and getting the skin "hardened"?
It's not supposed to hurt much, right?
Comment: Never copy someone's gear because they play it (your 2nd question). Play with what you feel is the best, most comfortable!
Comment: If you want to bend notes like Kirk Hammett, it's important that you *don't* hit exactly the right note. ;)
Comment: I can recommend Justin Sandercoe's courses, and specifically this one about bending : http://justinguitar.com/en/IM-144-StringBending.php
Comment: Funfact not sure if you have seen them yet, you can now buy rock tips a small bottle with an apllicator hardens your finger tips for those high and repeated bends and vibrato. Especially if you are using 11s or 12s top E String
Answer: Yes, you can use thinner gauged strings to reduce tension and make the strings easier to bend. For electric guitar strings, the standard is usually around .009 or .010 inches for the high-E string (Sets are usually labelled by the gauge of the high-E string. The gauges of the rest of the set mostly depend on how thick the high-E is, but there are also variations- see Skinny Top/Heavy Bottom below). A lot of metal players like heavier strings because they sound fatter and also respond well to detuning (you can keep the same tension but with lower tunings).  But it's always a tradeoff between playability and tone. Most people say you get "more" tone out of thicker gauges, so you usually want to use the thickest strings you can physically handle. It will take some experimentation to see what works best for you.  As a beginner you should probably be using .009" sets, but .010" isn't too much harder to play, and in my opinion sounds noticeably better. For metal or hard rock the Skinny Top/Heavy Bottom strings are a good compromise, because you get fatter lower strings and thicker tone for the power chords combined with thinner higher strings that result in easier playability and bending on those strings.
The bending technique itself is also important- you want to be using more of a twisting motion in the wrist/forearm when bending strings rather than using the muscles in your fingers. Also you can use two or three fingers together to hit the really high bends. There are a ton of good instructional videos on YouTube to learn this, and it's much easier to watch and learn the proper technique than reading about it here.
Your fingers are going to hurt when you are learning guitar basically no matter what you do. Bending a lot will make them hurt more/faster, so don't overdo it until your callouses build up. My advice for anything concerning guitar: just keep practicing. As long as your technique is solid, you will get it eventually. You probably want to take a break when the fingers start bleeding though.. and it's best in the future if you space out (or shorten) your practicing sessions until your callouses and endurance improves.
Comment: One more thing: I *really* like [coated strings](http://www.elixirstrings.com/guitar-strings/electric-guitar-strings.html), and in my experience they are considerably easier on the fingers (especially the wound strings). This doesn't help as much with bending, but it might help your fingers tolerate a little more playing before it becomes too uncomfortable.
Comment: I second that calluses are the essential natural protection for your fingers. They are indispensable.
Comment: "Most people say you get "more" tone out of thicker gauges" but Tony Iommi and Ty Tabor use very light strings, for instance. I think the tone issue is more relevant with less distorted blues or classic rock tones than with metal-ish styles. I'd say go for the light gauges for comfort, and wonder about the tone in a couple of weeks/months.
Comment: @Pif I tend to agree and only use 10s myself. I used 12s at one point on a semi-hollow I played for jazzy stuff, but never noticed much difference between 9 and 10. And you are right, for beginners 9s are definitely the way to go.
Answer: In general, smaller-gauged strings will come up to the same pitch at a lower tension. They're easier to bend. They'll also have less "oomph" as a consequence, but amplification can mitigate some loss of volume.
As for technique, you want all three of your big fingers all pushing or pulling together. Don't worry about bending with a single finger alone until your fingers are much stronger. With three fingers you can get more mechanical advantage from the hand and wrist, and put even less stress on the fingers themselves. Practice 1/2-step and full-step bends at every string+fret combination.
If it hurts, stop and rest. Once callouses form, it will push the nerves deeper into the tissue, and the same pressure will hurt much less.
I'm assuming you've got an electric guitar with 22-frets, and that somewhat leaves you "searching" for the E note hanging off the fretboard. So, if that bend is difficult, I'm guessing that you have 10-s or 11-s on the guitar, so I'd recommend you try a set of 9-s. (<-- But this is a lot of guesswork! I'm guessing that if you had 9-s or 8-s on there already, you wouldn't be asking this because the bends would be easier). You should take your guitar with you when you buy new strings so you can ask them what gauge you have, and then try the next lighter gauge.
Also make sure that your strings are in-tune, and not just with each other. When I was a beginner, I had a tendency to just tune the guitar strings to each other. But later, I discovered I was always over-tightening and tuning sharp. This made the tension higher, and bends were more difficult than they needed to be.
Comment: The number of frets by itself doesn't matter in terms of physically bending.. but the scale length does. Shorter scale guitars have less tension in the strings for a given gauge so they are easier to bend. Sometimes shorter scale guitars have less frets, so it's worth consideration.
Comment: For a beginner even on 9's a whole-step bend can be a challenge, especially with the weaker fingers.
Comment: Thank you! yes I have 22 frets, is it easier to get that last note bent on a guitar with more frets? (I would believe it does, but not sure if it's worth buying a new guitar just for that :))
Comment: Good point. I've replaced that part.
Comment: I think it's *psychologically* easier with 24 frets, so you can fret the note and hear it and it's easier for your ear to know that the bend is right. But physically, it should not make much difference.
Comment: On a short scale guitar some extreme bends can be harder. I have a couple of songs where I'll bend up 5 semitones on my B string (and I use a coated .010 Elixir set) - it is easy-ish on my long scale Ibanez, but annoyingly hard on my Les Paul
Comment: That's probably the other end of the spectrum, but raises an important point: tension is related to the travel-distance necessary to achieve the pitch. Higher tension->bends are harder (requires more force) but also *shorter*.
Answer: The lighter the gauge the easier it is to bend but that does not mean it is automatically better. I do find some of the finer dynamics of vibrato and bending are lost in the lighter string tensions. Sure you can bend higher easier but subtle vibratos become harder as a consequence.
Also the loss of tension in regards to bending does make it harder to bend accurately. So if you like bending a half step up then if the strings give in too easily it does become harder to do it accurate. It all depends on what type of effects you want to use most often.
Comment: Harder to bend accurately, and easier to bend by accident!
Comment: You very soon learn to compensate, and not bend too much. Using one's ear is always best (I don't mean instead of fingers!
Answer: A few ideas...
Pitch:
Play the correct pitch with a non-bent 'reference' note and then compare your bent note to that. Do this over and over attempting to match the pitch as closely as possible. For the high E bend in the Sandman solo, if you have a 22 fret guitar you might need to hit a harmonic over the point where a 24th fret would be to get your reference note.
Use three fingers:
You should be using your first three fingers for the bend you are talking about. The work of bending the string should be shared by all three fingers, not just the 3rd finger.
This has two advantages: 1. You have three times as much grip on the string, therefore you can hold the string more lightly and still get the traction you need against the string, but with much less friction between your fingers at the frets/fretboard and your string against the frets/fretboard. This will also reduce wear on your frets.
Clean your guitar:
If your guitar neck is covered in sweat, dust or other smeggy residue you should use a guitar cleaner. Its easier to move your fingers against a clean lightly oiled fretboard.
Clean or change your strings:
Dirty/rusty strings will rip your fingers to shreds. Make sure you can slide your fingers up and down the strings with maximum smoothness.
Suck your fingers:
Your calluses should be nice and thick, but they should not be hard. In order to play comfortably all day your calluses should be pliable. So they bend around the string instead of cracking/cutting. I find that if I get hard calluses, sucking on them for a bit softens them up. You might find moisturiser works, but I prefer to have dry clean hands when I play.
Practice with four fingers as well:
(This is something I'll have to admit to being very slack on). But often you want to bend at the end of a passage that ends on your pinky finger. In this case it's advantageous to be comfortable bending on your pinky.
Ultimately you should be able to learn to bend any gauge of string (within reason) easily with practice. Then you can base your string choice on tone and durability factors.
Answer: For those wanting easier bending, try Roto strings (Pink if you use .09s) These strings are comparatively more elastic than any others Im aware of, presumably due to lower density alloy. They are also very bright for the same reason. But the downside is that they detune at different rates when whammying, so I don't recommend Roto Pink for serious whammy players. Specifically, there is a HUGE difference in amount of detune between strings at the same whammy level. (high E detunes 2 semitones, B = 4 semitones, G = 8, D= 5, A= 10, and Low E is infinite (totally slack!) I love these for bending notes, and reccomend for hardtails, but don't even consider for use with even subtle whammy use like chord vibrato!
Answer: Some very good tips, but one thing that I couldn't see mentioned is scale length and the relationship between string gauge and minimum action. There is no set scale length for guitars, but the most common ones are strat length at 25.5" and les paul at 24.75". On a longer scale guitar 9 gauge strings will be as tense as 10 are on a shorter scale.
Another thing to consider is that with slacker strings you will need a higher action to avoid fret buzz. Whilst tension is a bigger factor in how easy it is to bend a string, action height is also a factor.
If you are playing metal and want to play along with recordings, drop D and EbAbDbGbBbEb tunings are very common so you might want to factor this into what strings you have, or if you have 2 guitars, have different strings on each. Ultimately, you should experiment with different types of strings to see what you like. If you're reasonably confident about setting up your action and intonation, try different sets or go to a guitar tech and explain what you're looking for.
Answer: IT IS ALL ABOUT SOUND:

Lighter-guage (thinner) strings are easier to bend, but generally provide noticeably less sound (less metal to tickle the magnets).
It's far easier to bend a string well up the neck (to 12th fret) than near the nut.  But it feels you have to move the string farther...  Long, slow bends work best up the neck.
For chords and open string play: power comes from the big strings, ringing from the unwound ones. For fretting: wound strings break down quicker (so they sound dead).
Like that fat sound?  Use heavier strings!  Listen to SRV and most any jazz player or the older-style blues guys (Sumlin, Muddy, &c.).  They all had strong hands, and did bends/hammers/pulls down near the nut.
Are you a speed fan (Albert Lee, Malmsteen, Dime)?  A tapper?  Go with a lighter string, and keep your voicings at the 7th fret and higher.
Want sustain?  Learn to use vibrato (microtonal string bends) for ALL your fingerings.
Finally, if it hurts, it hurts...  It goes away.
Answer: For me, it's important to finely tune the strings, from top to bottom (meaning: EADGBE open and 12th fret harmonics must match), and setting the action (getting the strings as close to the fret board without buzzing).  If you do that, the bending will be easier and the notes will not be flat or sharp.  Also, guitar strings are a players preference: some players like a slightly heavier top and lighter bottom.  I have recently been using the Ernie Ball cobalt super slinky strings and I am getting hooked.  Very bright and clean.  Nice.
Answer: From personal experience I would say that the best way to go about it as a beginner would be to start with a light gauge and then gradually move up to a gauge where you're most comfortable. Each gauge offers different play-ability and feels very different. Its best to try them all eventually and then make a decision. I have currently settled on Ernie Ball Skinny Top/Heavy Bottoms .10-.52 but it may change later.
As for your questions specifically find my responses inline in italics,

Are there specific strings that are easier to bend? (I'm a complete
newbie with string types) the lighter the gauge(thinner strings), the easier it is to bend usually. Try different gauges, light to heavy. You'll find the one best for you.
Do you know which strings Kirk Hammett used when recording that song? Should I try them? Currently he uses .11-.48 Ernie Ball Power Slinky sets but I wouldn't think it would be the only one he uses since he has multiple guitars. It won't matter since its a to each their own sort of thing, you could give these a shot. If you're using .12's or .11's then it would definitely be a bit of struggle doing fast bends.
Any other techniques to get better at bending? Just muscle power and getting the skin "hardened"? Regular practice will build and keep your calluses intact. As for muscle power, make sure you're using a good technique for your bends. The Justin Sandercoe tutorial for Bending Manur has mentioned above is really great for beginners, as are most of Justin's lessons.
It's not supposed to hurt much, right? Well hurt kind of depends on what you get used to eventually. Long durations will hurt no matter what you do. A good technique should prevent you from hurting too quick and too much, and from any injuries. Changing gauges will impact your playing and how the guitar feels so trying different ones will surely help you understand whether the reason for your fingers hurting are related to a bad technique or a really heavy gauge or a badly setup guitar

Additional note, changing the string gauge will affect the tension and the action on your guitar. So move up or down gauges incrementally. You may also need to adjust your neck-bow when changing the string gauges as per your playing needs. If you're new to truss rods, your local luthier is the man for you. Hope this helps and happy guitar-ing to you.
Comment: How does having callouses help with string bending? Or any guitar playing, for that matter?
Comment: @Tim Since he asked about the skin being "hardened", which I believe is referring to callouses. Playing guitar for any decent amount of duration will eventually lead to the thinner strings biting into the tips of the fingers. Again speaking from experience, may not apply to everyone. My fingertips hurt after an hour or so if I have lost my callouses due to any breaks I take.
Answer: I used to use .010-.052 at regular A440 Pitch with a 25 1/2 inch Stat type guitar for years,but it's resulted in arthritic "lumps" on the 2nd Knuckles of all my Right Hand(Left Handed Player),as I thought"heavier better"=more tone,but I regret it now(30 years later) and Love playing like many in Eb tuning with .009 to .042,I get actually a fatter more pleasing -less brittle sound,but after finally finding Left Handed Les Paul type Guitar's(still an Extreme Challenge in Australia!) due to scale being shorter,supposedly easier I'm using Eb tuning with .010's,or .010 high Eb and a mixture.
PS KIrk Hammet has decent pitch,and I got to meet him,very cool guy,it's more the feel of the music,or his own feel at times,especially with the more bendy blues feels when in the next nano second he has to play 32nd notes,with the single semitone "psycho" rhythm chord changes underneath that Metallica helped popularize....hard job IMO.


Expression for sublattice $M$ of lattice of subgroups $L(G)$ in terms of $L(G')$ for some $G'$

Question: Let $T$ be a group and $G,A_{i} \subseteq T$ be subgroups (for $i \in I$). Denote the lattice of subgroups of $G$ as $L(G)$.
I am interested in the following sublattice of $L(G)$ defined as
$M=\{H \in L(G) | H \cap A_{i} = G \cap A_{i} \text{ for all } i \in I\}$ .
Instinct tells me that $M$ should be isomorphic to $L(G')$ where
$G' = G/(G \cap \langle A_{i} \rangle_{i \in I})$ (providing normality of $G \cap \langle A_{i} \rangle_{i \in I}$).
When all $A_{i}=1$ we have that $L(G')=L(G)$ which is isomorphic to $M$, when all $A_{i}=G$ then $L(G')=\{1\}$ which is isomorphic to $M$.
If $M \cong L(G')$ I'm seeking a outline/draft of a proof and else a  expression for the corrected $G'$ in terms of $G$? Thanks.
Answer: By the lattice theorem $L(G/\langle G \cap A_{i} \rangle_{i \in I})$ is isomorphic to $L'= \{H | \langle G \cap A_{i} \rangle_{i \in I} \subseteq H \subseteq G \}$.
If $H \in L'$ then $G \cap A_{i} \subseteq H \subseteq G$ for each $i \in I$ so $G \cap A_{i} = H \cap A_{i}$ for each $i \in I$ and hence $H \in M$.
If $H \in M$ then $G \cap A_{i} = H \cap A_{i} $ for each $i \in I$ so $G \cap A_{i} \subseteq H$ for each $i \in I$. Hence $\langle G \cap A_{i}\rangle_{i \in I} \subseteq H$ and as $H \subseteq G$ by assumption we have that $H \in L'$.
So if $G' = \langle G \cap A_{i} \rangle_{i \in I} $ then $ L(G') \cong L' = M$.


How to inflate core/res/res/layout/simple_dropdown_item_2line.xml

Question: There is this xml file under frameworks/base.
/frameworks/base/core/res/res/layout/simple_dropdown_item_2line.xml
How can I inflate that in my own android application?
Thank you.
Answer: View view = activity.getLayoutInflater().inflate(
     android.R.layout.layout.simple_dropdown_item_2line, null);
If you are doing this inside Activity code you can use this instead of activity which implies that you set the variable somewhere
Answer: you'd use android.R.layout.simple_dropdown_item_2line, I believe.


How to _delete_ element from dynamic array?

Question: I have seen other answers to questions like this, but none seemed to work for me. Say I have a dynamic array:
int* myarray;
myarray = malloc(myarray, 4*sizeof(int));
myarray[0] = 1;
myarray[1] = 2;
myarray[2] = 3;
myarray[3] = 4;

What I want to do is to remove (and free, because the array will keep on getting larger and larger) the first element of the array. I am well aware of realloc which removes the last element of the array if shrunk. Any ideas on this? Is  this possible?
Thanks in advance!
Comment: Store your array in reverse order?
Comment: @nneonneo good idea, but then how would I append items at the beginning?
Comment: You would append items at the end.
Comment: (Or, hey, you could use a linked list, a circular array, or any number of other tricks to avoid expensive array moves).
Comment: @nneonneo, so how would appending items at the end store it in a reverse order?
Comment: You say you want to always remove the first element. By storing it in reverse, you remove the last element. But, to insert an element is still going to require moving the elements around!
Comment: Anyway, you'll get better (more useful) answers if you clearly explain your usage scenario. Perhaps another data structure is more suitable.
Comment: @nneonneo right, that was my question (I meant "insert items at the beginning" not "append items at the beginning", my bad)
Answer: One method I can think of is doing

memmove(myarray, myarray+1, 3*sizeof(int))

and then use realloc to shrink the array. I'm not sure there are more efficient ways to do this in C.
Comment: +1 for memmove. He can always used a linked list as suggested in other posts too.
Comment: Good call on `memmove`.  You might want to move 3 items instead of 4 though.
Comment: Thanks, I'll see if it works... I knew it couldn't be _too_ hard
Answer: Typically a "Delete" operation is not possible on an array. Perhaps you want to create and use a linked list?
C++ has its std::vector which supports this. What it would do is to shift elements that come later, forward by 1 element. You could implement this, and call realloc later.
Storing them in reverse is an obvious workaround if only first element needs to be deleted.
Comment: Well, `realloc` works fine (and is well-defined) for increasing the size. It's just that the content of the new elements is undefined.
Comment: I'd give +1 for the linked list suggestion, but your comment about `realloc` is just wrong...
Comment: @nneonneo yup, my misunderstanding, removed.
Answer: You have to shunt all the other elements along one.  Conceptually, it's like this:
for( int i = 0; i < 3; i++ ) p[i] = p[i+1];

As others have mentioned, memmove is optimized for shifting memory segments that overlap, rather than using the above loop.
Moving data around is still inefficient as your array grows larger.  Reallocating an array every time you add an item is even worse.  General advice is don't do it.  Just keep track of how large your array is and how many items are currently stored in it.  When you grow it, grow it by a significant amount (typically you would double the size).
It sounds like you might want a circular queue, where you preallocate the array, and a head and tail pointer chase each other round and round as you push and pop items on.
Comment: ..memmove is almost certainly faster than that loop, especially for big arrays.
Answer: I don't think that you'll find a proper/clean way to do that in C. C++ as some lybraries who do that, and almost all the OO oriented languages can do that, but not C. All I can think of is moving memory and, yes, calling realloc, or setting the position you want to free to a known value wich you'll consider empty in a memory re-use policy.
Another way to turn the problem is by a dynamic implementation of the array. DOn't know if you want to go there, but if you do, here's some brief example.
Since you're only saving integers, a struct like this:
typedef struct DynamicArray_st{
 int x;
 struct DynamicArray_st *next;
}DynamicArray;

Makes it possible to alloc and free elements as the program needs to. It also allows insertion in the middle, begin or end and the same for frees.
The way you'll do it is by saving a pointer to the begin of this dynamic type and then iterate over it.
The problem is that you can't access data by the [] notation. Iterations are necessary wich makes it heavier on processing time.
Besides that, your code would become something like this:
DynamicArray *array = malloc(sizeof(DynamicArray)); /*Just a first element that will stay empty so your Dynamic array persists*/
 array->next = NULL;
 DynamicArray *aux = array;
 DynamicArray *new;
 for(i = 0; i<4; i++){
    new = malloc(sizeof(DynamicArray));
    new->next = NULL;
    new->x = i+1;
    aux->next = new;
    aux = new;
 }

Here you have a sequence of structs in a way that each struct points to the next one and has a integer inside.
If now you'd do something like:
aux = array->next; /*array points to that empty one, must be the next*/
 while(aux != NULL){
   printf("%d\n",aux->x);
   aux = aux->next;
 }

You'll get the output:
1
2
3
4

And freeing the first element is as easy as:
  aux = array->next;
  array->next = aux->next;
  free(aux);

If you try to draw it(structs are boxes and next/aux/next are arrows) you'll see one boxe's arrow outline an box - the one you want to free.
Hope this helps.


Is it good statistical practice to include an "aggregated" categorical variable in LM?

Question: I am dealing with a large data set (~100000 observations, roughly 13 variables). Most variables are of categorical nature and are stable across different observations concerning the same individual/entity, e.g. social class or income, however some are not.
My Problem is rooted in the fact that there is a varying number of observations per individual.. so there might be 3 observations belonging to the same individual or there might be 17 observations.. Therefore, I want to aggregate all observations for each individual which is rather unproblematic for variables like social class (in this data set no individual is changing social classes). So, the aggregated social class variable will be of the same categories as the original one.
However, there is one variable "brand loyality" which takes on the values of 0 (=brand loyal) or 1 (=not brand loyal). Each observation describes a purchase of a certain type of homogenous good. If 2 consecutive purchases come frome the same brand the value is 0, otherwise 1. The variable as a whole merely checks what brand was bought last (so it is kind of a lagged variable somehow) Aggregating this variable yields a number between 0 and 1 and is not of categorical nature anymore (e.g. 0.34)
Nevertheless, I believe this variable, even though not categorical anymore, conveys some information, e.g. if the variable would take on a value of 0.2 then the individual is on average rather brand loyal. If the value would be 0.8 then I would say the individual is on average by trend not loyal.
Is it good statistical practice (probably not :p) to include this aggregated variable in my regression model? And if so, I would like to know some more about the theoretical idea behind this (Why is it ok?/Why is it not ok?)
I was just wondering because this variable is highly significant in my linear model and I don't know why - at least not from the statistical point of view. From the theoretical point of view/according to my intuition this makes a lot of sense.
Answer: I'm not sure if I'm understanding correctly, but you aren't doing multilevel modeling, right? I believe that multilevel modeling could handle the aggregation by parsing the within-person variance and the between-person variance, while the the variables that don't vary within-person should be simply be treated as between level variables (don't know what repercussions would the binary nature of the variables would have). I think that this would adjust for the non-independence of observations that would occur by adding repeated measures of a non-varying state, the underestimation of standard errors. I've merely heard about multilevel modeling though, you could read if it can be of help.
If the three observations are not being considered as longitudinal in character, perhaps you could model a latent variable using these three observations as indicators (with the proper technique, e.g., wlsmv or irt models, the binary measurement would be no problem as lots of literature will confirm). A latent variable could be considered better than an average score in that it's based on the covariance among the indicators and tries to eliminate "measurement error", and perhaps model fit could be evaluated to test if it makes sense to try to aggregate them. Sorry if that's not helpful.
Comment: Thanks for your answer. I did not do a multilevel analysis, but due to your comment I did some research on multilevel analysis and this is probably what I should have done :p It did not occur to me that "Observation concernting individual i" (level 1) and "individual i" (level 2) can be considered as two levels (it is not as obvious as pupil and class for instance).
Comment: I have to admit that I merley calculated the means/average values for each individual and treated the resulting data set as enirely new data set, which is probably wrong since it neglects the within-person variance. Is there and easy and convenient way to do a multi-level analysis in R? If you could provide some sample code I would be deeply grateful (since I have never done one before.) Tanks!


Sketching a surface

Question:
If $${\bf F}=2y{\bf i}-z{\bf j}+x^2{\bf k},$$ and $s$ is the surface of the parabolic cylinder $y^2=8x$ in the first octant, bounded by the planes $y=4$ and $z=6$, evaluate $$\int_S{\bf F}\cdot{\bf\hat n}\,dS,$$ where $\bf\hat n$ points in the direction of increasing $x$, by projecting the integral onto the plane $x=0$.

I'm trying to draw a sketch to get a feel of the situation but am confused as to what the question is asking. I have sketched $y^2=8x$ in the plane $z=0$ and marked on the points where $y$ and $z$ are bounded.
Answer:
Here is a drawing of the situation . The surface $S$ is shown in tan, the yellow arrow points in the direction of  increasing x . The unit normal to the surface is the vector shown in red , the plane $R$ , $x=0$ is shown in white.  I believe you need to develop a projection formula of the form : $$ \int_S F \cdot  \hat n  dS = \int_R \frac{F \cdot  \hat n}{\| \hat n \cdot \mathbf i \|  } dR $$ where $ \mathbf i $ is the unit x vector . ( The general formula should be in your text , we are choosing the x rather than z coordinate vector, alternately you can permute indices and use the standard projection formula.)
Comment: In my sketch the z-axis seems to be pointing away from the viewer, I'm sorry about that. In any case , I plotted $ y^2 = 8x$ , so the z values develop the parabola into a parabolic cylinder
Comment: I understand the projection theorem part however i'm still having trouble with the sketch of the surface. Have you plotted $z=y^2-8x$; or $y^2=8x$ in the $z=0$ plane and extended this up to $z=6$?

Sketching a surface


warning: setlocale: LC_ALL: cannot change locale on GCE instances

Question: We are not sure when this issue exactly started, but we recently found that when we log in GCE instance (debian-8-jessie-v20170110, in us-west1-b region), following warning message always appeared on console;

warning: setlocale: LC_ALL: cannot change locale (ja_JP.UTF-8)

Do you guys have any idea why we suddenly started to get this warning message with GCE instances? We didn't change any locale related settings by ourselves.
After running sudo localedef -f UTF-8 -i ja_JP ja_JP.UTF-8, the warning message has disappeared, but it would be helpful if we could know why the issue was happening.
Answer: Your remote host doesn't support same locale configured on your local (see locale).
To ignore the warning, you can set LC_ALL to C before connecting, e.g.
LC_ALL=C ssh email@example.com

To install some specific language pack on the host, run:
sudo apt-get install language-pack-en language-pack-jp

To check all supported locale, run: locale -a.


How can I get the real password via hook_user_update()?

Question: I want to change the current user password, and get the new password(the real password, not md5 encryption) when edit the account profile via user profile form(e.g.: example.com/user/1/edit) and save. would anyone can tell me how to do that? I tried using hook_user_update(), but it didn't succeed.
I mean I want to change the current user password, and I want to get the new password.
Answer: Implement hook_form_alter() (or one of it relatives) such that it array_unshift() a new submission handler to the user update form. The submission handler should add the password to the $form_state['values'] array. You also have to add the same key to $form_state['user'], because of the way user_profile_form_submit() calculates which keys from $form_state['values'] to pass as $edit to your hook_user_update() implementation.
If you did not insist on using hook_user_update(), I'd suggest handling your custom additions to the password update directly in your submission handler.
By the way, Drupal 7 does not use a simple MD5 hash to store passwords.
Comment: I'm not going to add another answer, as the useful bit is already here - but there is no way to get a readable password out of Drupal.  To quote Kiamlaluno from [here](http://drupal.stackexchange.com/questions/18477/send-users-password-in-mail):  *Drupal doesn't encrypt the password and [save] it in the database, but it saves in database the hash of the password, which is the value returned from a one-way function;*
Comment: I try to add a drupal_set_message($form_state['values']['pass']) to the function user_profile_form_submit, and return the real password. but I dont want to hark code, so I want to get it on other customize module.
Comment: I just want to receive the new password via form widget (drupal 7 this widget's id is :edit-pass-pass1), and use this password to single sign on with other system. In order to make data synchronization,when password has changed, another system will changed at the same time.
Answer: How about reading it directly from $_REQUEST array? I've added code like this:
function hook_user_presave(&$edit, $account, $category){
 echo $_REQUEST['pass']['pass1'];
}

and it works.


Why my Js is not working in my react page?

Question: I'm trying to implement this https://codepen.io/azouaoui-med/pen/wpBadb as one of my pages inside my react proj. But dropdown doesn't work and couldn't able to close side bar which functions by js. AM not getting any error. But it simply being a static page. How to make it to work? Anybody out there help me to resolve this is issue. Thanks in advance
PS: Am getting the same output as from codepen, not the one which shows down when clicking "Run code snippet"
My output is something like this from my proj and also from code sandbox
My codesandbox for reference : https://5vbl2.csb.app/
Side bar which i tried using with dropdown

$(".sidebar-dropdown > a").click(function() {
  $(".sidebar-submenu").slideUp(200);
  if (
    $(this)
      .parent()
      .hasClass("active")
  ) {
    $(".sidebar-dropdown").removeClass("active");
    $(this)
      .parent()
      .removeClass("active");
  } else {
    $(".sidebar-dropdown").removeClass("active");
    $(this)
      .next(".sidebar-submenu")
      .slideDown(200);
    $(this)
      .parent()
      .addClass("active");
  }
});

$("#close-sidebar").click(function() {
  $(".page-wrapper").removeClass("toggled");
});
$("#show-sidebar").click(function() {
  $(".page-wrapper").addClass("toggled");
});
@keyframes swing {
  0% {
    transform: rotate(0deg);
  }
  10% {
    transform: rotate(10deg);
  }
  30% {
    transform: rotate(0deg);
  }
  40% {
    transform: rotate(-10deg);
  }
  50% {
    transform: rotate(0deg);
  }
  60% {
    transform: rotate(5deg);
  }
  70% {
    transform: rotate(0deg);
  }
  80% {
    transform: rotate(-5deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

@keyframes sonar {
  0% {
    transform: scale(0.9);
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}
body {
  font-size: 0.9rem;
}
.page-wrapper .sidebar-wrapper,
.sidebar-wrapper .sidebar-brand > a,
.sidebar-wrapper .sidebar-dropdown > a:after,
.sidebar-wrapper .sidebar-menu .sidebar-dropdown .sidebar-submenu li a:before,
.sidebar-wrapper ul li a i,
.page-wrapper .page-content,
.sidebar-wrapper .sidebar-search input.search-menu,
.sidebar-wrapper .sidebar-search .input-group-text,
.sidebar-wrapper .sidebar-menu ul li a,
#show-sidebar,
#close-sidebar {
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -ms-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
}

/*----------------page-wrapper----------------*/

.page-wrapper {
  height: 100vh;
}

.page-wrapper .theme {
  width: 40px;
  height: 40px;
  display: inline-block;
  border-radius: 4px;
  margin: 2px;
}

.page-wrapper .theme.chiller-theme {
  background: #1e2229;
}

/*----------------toggeled sidebar----------------*/

.page-wrapper.toggled .sidebar-wrapper {
  left: 0px;
}

@media screen and (min-width: 768px) {
  .page-wrapper.toggled .page-content {
    padding-left: 300px;
  }
}
/*----------------show sidebar button----------------*/
#show-sidebar {
  position: fixed;
  left: 0;
  top: 10px;
  border-radius: 0 4px 4px 0px;
  width: 35px;
  transition-delay: 0.3s;
}
.page-wrapper.toggled #show-sidebar {
  left: -40px;
}
/*----------------sidebar-wrapper----------------*/

.sidebar-wrapper {
  width: 260px;
  height: 100%;
  max-height: 100%;
  position: fixed;
  top: 0;
  left: -300px;
  z-index: 999;
}

.sidebar-wrapper ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.sidebar-wrapper a {
  text-decoration: none;
}

/*----------------sidebar-content----------------*/

.sidebar-content {
  max-height: calc(100% - 30px);
  height: calc(100% - 30px);
  overflow-y: auto;
  position: relative;
}

.sidebar-content.desktop {
  overflow-y: hidden;
}

/*--------------------sidebar-brand----------------------*/

.sidebar-wrapper .sidebar-brand {
  padding: 10px 20px;
  display: flex;
  align-items: center;
}

.sidebar-wrapper .sidebar-brand > a {
  text-transform: uppercase;
  font-weight: bold;
  flex-grow: 1;
}

.sidebar-wrapper .sidebar-brand #close-sidebar {
  cursor: pointer;
  font-size: 20px;
}
/*--------------------sidebar-header----------------------*/

.sidebar-wrapper .sidebar-header {
  padding: 20px;
  overflow: hidden;
}

.sidebar-wrapper .sidebar-header .user-pic {
  float: left;
  width: 60px;
  padding: 2px;
  border-radius: 12px;
  margin-right: 15px;
  overflow: hidden;
}

.sidebar-wrapper .sidebar-header .user-pic img {
  object-fit: cover;
  height: 100%;
  width: 100%;
}

.sidebar-wrapper .sidebar-header .user-info {
  float: left;
}

.sidebar-wrapper .sidebar-header .user-info > span {
  display: block;
}

.sidebar-wrapper .sidebar-header .user-info .user-role {
  font-size: 12px;
}

.sidebar-wrapper .sidebar-header .user-info .user-status {
  font-size: 11px;
  margin-top: 4px;
}

.sidebar-wrapper .sidebar-header .user-info .user-status i {
  font-size: 8px;
  margin-right: 4px;
  color: #5cb85c;
}

/*-----------------------sidebar-search------------------------*/

.sidebar-wrapper .sidebar-search > div {
  padding: 10px 20px;
}

/*----------------------sidebar-menu-------------------------*/

.sidebar-wrapper .sidebar-menu {
  padding-bottom: 10px;
}

.sidebar-wrapper .sidebar-menu .header-menu span {
  font-weight: bold;
  font-size: 14px;
  padding: 15px 20px 5px 20px;
  display: inline-block;
}

.sidebar-wrapper .sidebar-menu ul li a {
  display: inline-block;
  width: 100%;
  text-decoration: none;
  position: relative;
  padding: 8px 30px 8px 20px;
}

.sidebar-wrapper .sidebar-menu ul li a i {
  margin-right: 10px;
  font-size: 12px;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  border-radius: 4px;
}

.sidebar-wrapper .sidebar-menu ul li a:hover > i::before {
  display: inline-block;
  animation: swing ease-in-out 0.5s 1 alternate;
}

.sidebar-wrapper .sidebar-menu .sidebar-dropdown > a:after {
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  content: "\f105";
  font-style: normal;
  display: inline-block;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  background: 0 0;
  position: absolute;
  right: 15px;
  top: 14px;
}

.sidebar-wrapper .sidebar-menu .sidebar-dropdown .sidebar-submenu ul {
  padding: 5px 0;
}

.sidebar-wrapper .sidebar-menu .sidebar-dropdown .sidebar-submenu li {
  padding-left: 25px;
  font-size: 13px;
}

.sidebar-wrapper .sidebar-menu .sidebar-dropdown .sidebar-submenu li a:before {
  content: "\f111";
  font-family: "Font Awesome 5 Free";
  font-weight: 400;
  font-style: normal;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin-right: 10px;
  font-size: 8px;
}

.sidebar-wrapper .sidebar-menu ul li a span.label,
.sidebar-wrapper .sidebar-menu ul li a span.badge {
  float: right;
  margin-top: 8px;
  margin-left: 5px;
}

.sidebar-wrapper .sidebar-menu .sidebar-dropdown .sidebar-submenu li a .badge,
.sidebar-wrapper .sidebar-menu .sidebar-dropdown .sidebar-submenu li a .label {
  float: right;
  margin-top: 0px;
}

.sidebar-wrapper .sidebar-menu .sidebar-submenu {
  display: none;
}

.sidebar-wrapper .sidebar-menu .sidebar-dropdown.active > a:after {
  transform: rotate(90deg);
  right: 17px;
}

/*--------------------------side-footer------------------------------*/

.sidebar-footer {
  position: absolute;
  width: 100%;
  bottom: 0;
  display: flex;
}

.sidebar-footer > a {
  flex-grow: 1;
  text-align: center;
  height: 30px;
  line-height: 30px;
  position: relative;
}

.sidebar-footer > a .notification {
  position: absolute;
  top: 0;
}

.badge-sonar {
  display: inline-block;
  background: #980303;
  border-radius: 50%;
  height: 8px;
  width: 8px;
  position: absolute;
  top: 0;
}

.badge-sonar:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  border: 2px solid #980303;
  opacity: 0;
  border-radius: 50%;
  width: 100%;
  height: 100%;
  animation: sonar 1.5s infinite;
}

/*--------------------------page-content-----------------------------*/

.page-wrapper .page-content {
  display: inline-block;
  width: 100%;
  padding-left: 0px;
  padding-top: 20px;
}

.page-wrapper .page-content > div {
  padding: 20px 40px;
}

.page-wrapper .page-content {
  overflow-x: hidden;
}

/*------scroll bar---------------------*/

::-webkit-scrollbar {
  width: 5px;
  height: 7px;
}
::-webkit-scrollbar-button {
  width: 0px;
  height: 0px;
}
::-webkit-scrollbar-thumb {
  background: #525965;
  border: 0px none #ffffff;
  border-radius: 0px;
}
::-webkit-scrollbar-thumb:hover {
  background: #525965;
}
::-webkit-scrollbar-thumb:active {
  background: #525965;
}
::-webkit-scrollbar-track {
  background: transparent;
  border: 0px none #ffffff;
  border-radius: 50px;
}
::-webkit-scrollbar-track:hover {
  background: transparent;
}
::-webkit-scrollbar-track:active {
  background: transparent;
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/*-----------------------------chiller-theme-------------------------------------------------*/

.chiller-theme .sidebar-wrapper {
    background: #31353D;
}

.chiller-theme .sidebar-wrapper .sidebar-header,
.chiller-theme .sidebar-wrapper .sidebar-search,
.chiller-theme .sidebar-wrapper .sidebar-menu {
    border-top: 1px solid #3a3f48;
}

.chiller-theme .sidebar-wrapper .sidebar-search input.search-menu,
.chiller-theme .sidebar-wrapper .sidebar-search .input-group-text {
    border-color: transparent;
    box-shadow: none;
}

.chiller-theme .sidebar-wrapper .sidebar-header .user-info .user-role,
.chiller-theme .sidebar-wrapper .sidebar-header .user-info .user-status,
.chiller-theme .sidebar-wrapper .sidebar-search input.search-menu,
.chiller-theme .sidebar-wrapper .sidebar-search .input-group-text,
.chiller-theme .sidebar-wrapper .sidebar-brand>a,
.chiller-theme .sidebar-wrapper .sidebar-menu ul li a,
.chiller-theme .sidebar-footer>a {
    color: #818896;
}

.chiller-theme .sidebar-wrapper .sidebar-menu ul li:hover>a,
.chiller-theme .sidebar-wrapper .sidebar-menu .sidebar-dropdown.active>a,
.chiller-theme .sidebar-wrapper .sidebar-header .user-info,
.chiller-theme .sidebar-wrapper .sidebar-brand>a:hover,
.chiller-theme .sidebar-footer>a:hover i {
    color: #b8bfce;
}

.page-wrapper.chiller-theme.toggled #close-sidebar {
    color: #bdbdbd;
}

.page-wrapper.chiller-theme.toggled #close-sidebar:hover {
    color: #ffffff;
}

.chiller-theme .sidebar-wrapper ul li:hover a i,
.chiller-theme .sidebar-wrapper .sidebar-dropdown .sidebar-submenu li a:hover:before,
.chiller-theme .sidebar-wrapper .sidebar-search input.search-menu:focus+span,
.chiller-theme .sidebar-wrapper .sidebar-menu .sidebar-dropdown.active a i {
    color: #16c7ff;
    text-shadow:0px 0px 10px rgba(22, 199, 255, 0.5);
}

.chiller-theme .sidebar-wrapper .sidebar-menu ul li a i,
.chiller-theme .sidebar-wrapper .sidebar-menu .sidebar-dropdown div,
.chiller-theme .sidebar-wrapper .sidebar-search input.search-menu,
.chiller-theme .sidebar-wrapper .sidebar-search .input-group-text {
    background: #3a3f48;
}

.chiller-theme .sidebar-wrapper .sidebar-menu .header-menu span {
    color: #6c7b88;
}

.chiller-theme .sidebar-footer {
    background: #3a3f48;
    box-shadow: 0px -1px 5px #282c33;
    border-top: 1px solid #464a52;
}

.chiller-theme .sidebar-footer>a:first-child {
    border-left: none;
}

.chiller-theme .sidebar-footer>a:last-child {
    border-right: none;
}

        pro sidebar

          Jhon
            Smith

          Administrator

            Online

            <input type="text" class="form-control search-menu" placeholder="Search...">

            General

              Dashboard
              New

                  Dashboard 1
                    Pro

                  Dashboard 2

                  Dashboard 3

              E-commerce
              3

                  Products

                  Orders

                  Credit cart

              Components

                  General

                  Panels

                  Tables

                  Icons

                  Forms

              Charts

                  Pie chart

                  Line chart

                  Bar chart

                  Histogram

              Maps

                  Google maps

                  Open street map

            Extra

              Documentation
              Beta

              Calendar

              Examples

        3

        7

Pro Sidebar

This is a responsive sidebar template with dropdown menu based on bootstrap 4 framework.

 You can find the complete code on
              Github, it contains more themes and background image option

New !

New react pro sidebar library is now available on npm

              Github

              Demo

More templates

Angular Pro Sidebar

              Github
              Demo

Angular Dashboard

              Github
              Demo

            © 2020 made with  by -
              Mohamed Azouaoui

This is the javascript which am uisng
Comment: I get errors in the browser console when I open your codesandbox link. Also, the javascript you've provided in your question appears to use jQuery, do you load that? I'm not sure if jQuery code plays well with React. Also, mentioned on the codepen.io link, the author of that sidebar has authored one for React at: https://github.com/azouaoui-med/react-pro-sidebar
Comment: Thanks for the response @BenStephens, but https://github.com/azouaoui-med/react-pro-sidebar i've tried this also but i don't have a proper code for that. So i thought of using simple html & css, but jquery isn't working. YEs i've loaded jquery in my page. Codesandbox is working fine now. Please have a look.
Comment: Did you save your changes? https://codesandbox.io/s/5vbl2 still shows errors in the console. And I don't see the javascript code that you've got in your question anywhere.
Comment: @BenStephens have attached my output from both my proj and code sandbox
Answer: This is how it looks like for me, i can deal with icons but for functionality am helpless.
Comment: I hope console errors don't create any problem here since I've my another code which is working fine has some console errors.(PS : I DON'T HAVE THIS CONSOLE ERROR IN MY WORKING PROJECT) questions Which I've asked for, let me change it to "Why does jQuery doesn't work inside my reactjs". Help me to create the same working sidenav in codepen. Thanks in advance
Answer: Adding this here rather than a comment, so that I can show the picture ...
When I go to:
https://codesandbox.io/s/5vbl2?file=/src/App.js:200-335
This is what I see:

The highlighted code just after the start of the Secdoc function is the only bit of jQuery code I can find (and doesn't match what you had in your question); the panel at the bottom left shows the console erros that I keep mentioning.


Scatter Plot: ValueError: x and y must be the same size

Question: Being E a random distribution (not relevant to the question) and having two lists called t and u:
t = []
u = np.round(np.random.uniform(0,1, num_round), num_cifre).tolist()
for val in u:
  t.append(E.ppf(u))

They should be of the same size, in fact doing: print(len(u) == len(t)) returns True
I'm trying to create a scatter plot with them using:
plt.scatter(u,t)
plt.show()

But when I execute the code this error comes out:
ValueError: x and y must be the same size

Answer: ppf() returns an array not a single value. So you have a list of values and a list of arrays that causes the issue, I guess


Add existing items of Sharepoint list to a folder programmatically

Question: I have about 20K items in a sharepoint 2010 list and I want to arrange every 5k items in a folder programmatically and also make sure that the newly added items are also in folder once they reach 5k limit.
I have not worked on creating folders in sharepoint programmatically. Can someone help me with a piece of code.
Answer: For create folder in SPList use below sample code it will help you.
SPSite oSite = new SPSite("http://localhost/");
SPWeb oWeb = oSite.OpenWeb();
//Provide SPList name which you use...
SPList oList = oWeb.Lists["testlist"];
oWeb.AllowUnsafeUpdates = true;
//Add a Folder as List Item in SPList as below
SPListItem folderItem = oList.Items.Add(oList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder);
//Add Folder Title here
folderItem["Title"] = "1-5000-Items-Folder";
folderItem.Update();

oWeb.AllowUnsafeUpdates = false;

Comment: Please don't use signatures on StackOverflow - http://stackoverflow.com/faq#signatures
Answer: For create folder in SPList use below sample code it will help you.
SPSite oSite = new SPSite("http://localhost/");
SPWeb oWeb = oSite.OpenWeb();
//Provide SPList name which you use...
SPList oList = oWeb.Lists["testlist"];
oWeb.AllowUnsafeUpdates = true;
//Add a Folder as List Item in SPList as below
SPListItem folderItem = oList.Items.Add(oList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder);
//Add Folder Title here folderItem["Title"] = "1-5000-Items-Folder";
folderItem.Update();
oWeb.AllowUnsafeUpdates = false;

Answer: Please use CAML query to loop folder in SP. Also never use list.Items.Add() instead use listitems.add().
Use the code while finding a folder :
SPQuery query = new SPQuery();
query.Query = "<Where><And><Eq><FieldRef  Name='LinkTitle'/><Value Type='Text'>" +folderName + "</Value></Eq><Eq><FieldRef   Name='FSObjType'/><Value Type='Lookup'>1</Value></Eq></And></Where>";query.ViewAttributes = "Scope=\"RecursiveAll\"";
SPListItemCollection items = list.GetItems(query);
if (items.Count == 0){Create a folder}
else{
SPListItem listItem = list.AddItem(folderItem.Folder.ServerRelativeUrl,SPFileSystemObjectType.File, null);}


Cloudcontrol no MongoDB access

Question: I recently discovered cloudcontrol and wanted to write a little mongoDB app to store some images. I enabled the free addon mongolab.free and followed the documentation to set up a connection.
$credfile = file_get_contents($_ENV['CRED_FILE'], false);
$credentials = json_decode($credfile, true);
$uri = $credentials["MONGOLAB"]["MONGOLAB_URI"];
$m = new Mongo($uri);
$db = $m->selectDB('test');

The problem is that the following line doesn't work because I "Need to login"
$db = $m->selectDB('test');

If I try to list all available DBs via listDBs() I get the same error "Need to login"
Even when connection via the terminal, the connection establishes but with the same "need to login" warning.
I've been trying to fix this problem since three days now but I cannot find the solution :(
Hope someone can help me
Answer: The name of your database is defined in MONGOLAB_URI as well (it has the form cloudcontrol_<deployment_id>). So you don't have to explicitely define another database name (and can't).
You can extract the database name from the uri with
preg_match("#/([^/\?]+)(\?|$)#", $uri, $match);
database = $match[1];

Cloudcontrol no MongoDB access


Show that $P(X)$ is a sigma algebra.

Question:
Show that $P(X)$ is a sigma algebra.

First of all, surely this makes totally sense. But I'm wondering how you would actually prove this. How do you prove something as trivial that $P(X)$ is closed under complement. Or that it closed under countable uions ?
Comment: It *totally* makes sense. "is a sigma algebra" means that it satisfies the definition of a sigma algebra, so you would *actually* prove this by checking the axioms. You could "prove" those two "trivial" points by appealing to the definition of $P(X)$. After all, it's *important* that we're talking about $P(X)$ right? It's not true that *every* set of sets is a sigma algebra, so it must appeal to $P(X)$ somehow...
Answer: Just work with the definitions. To show that $\mathcal{P}(X)$ is closed under complement, assume that $A \subseteq X$ is a subset of $X$, i.e. $A \in \mathcal{P}(X)$. Then,
$$A^c = \{ x \in X : x \notin A \}$$
is a subset of $X$ since every element of $A^c$ is in $X$. Thus, it follows that $A^c \in \mathcal{P}(X)$. The other definitions of a $\sigma$-algebra can be checked similarly.

Show that $P(X)$ is a sigma algebra.


Dados repetidos no html (ANGULAR)

Question: Tenho um *ngFor que preenche meu html, e esses dados são buscados de uma API, aí eu utilizo schedule pra recarregar os dados toda vez que dá segundos = 15.
Só que os dados estao sendo colocados abaixo dos antigos la no HTML.
HTML:

Filial {{ element.FI }} = {{ element.porc }}

TS:
  ngOnInit() {
        schedule.scheduleJob(' 15 * * * * * ', () => {
          this.MetaService.FiliaisMetaDiarias().subscribe(
  data => {
    const response = (data as any)
    this.objeto_retorno = JSON.parse(response._body);

    this.objeto_retorno.forEach(element => {

      this.tots = element.TOTAL
      element.TOTAL = (element.TOTAL * 100).toFixed(3) + '%'
      element.TOTAL = element.TOTAL.toString().replace(".", ",")
      if (this.tots >= this.MetaAtingida) {

        this.fil.push({
          FI: element.FILIAL,
          porc: element.TOTAL
        });

        this.mainColor = 'MetaAtingida'

      }
        });
    }

Toda vez que o segundo é = 15 ele o código é recarregado e colocado no html, mas não ta apagando os dados anteriores que está no html.
Alguém sabe resolver isso?
Comment: O comportamento, me parece que se deve ao seu `this.fil.push()` se você está substiuindo os elementos, antes você deveria limpar ele.
Comment: Eu limpo o array, mas mesmo assim continua do mesmo jeito
Comment: Onde você limpa?
Comment: quando inicia a função do schedule
Comment: Era melhor usar o metodo filter e map que forEach
Answer: Veja se assim funciona.
ngOnInit() {
        schedule.scheduleJob(' 15 * * * * * ', () => {
          this.MetaService.FiliaisMetaDiarias().subscribe(
  data => {
    const response = (data as any)
    this.objeto_retorno = JSON.parse(response._body);

    this.fil.length = 0;

    this.objeto_retorno.forEach(element => {

      this.tots = element.TOTAL
      element.TOTAL = (element.TOTAL * 100).toFixed(3) + '%'
      element.TOTAL = element.TOTAL.toString().replace(".", ",")
      if (this.tots >= this.MetaAtingida) {

        this.fil.push({
          FI: element.FILIAL,
          porc: element.TOTAL
        });

        this.mainColor = 'MetaAtingida'

      }
        });
    }

Por alguma razão muito estranha, no JavaScript, você consegue "resetar" um array ao definir o seu tamanho como 0.

var fil = [1,2,3];
//push esvaziar ou redefinir o tamanho.
fil.push(4);
console.log(fil);

//redefinindo o tamanho e fazendo novo push
fil.length = 0;
fil.push(5);

console.log(fil);

Dados repetidos no html (ANGULAR)


Should I normalize all data prior feeding the neural network models?

Question: My understanding is most of the tutorials recommend normalizing / scaling the data prior feeding the tensorflow models. Doesn't normalization require that data conforms to the normal parametric distribution?  What good is a non-linear model if scaling / normalizing is a pre-requisite prior using the non-linear model such as tensorflow?
So back to the question, should I always normalize / scale my data prior feeding my tensorflow models?
Answer: Yes, normalisation/scaling is typically recommended and sometimes very important. Especially for neural networks, normalisation can be very crucial because when you input unnormalised inputs to activation functions, you can get stuck in a very flat region in the domain and may not learn at all. Or worse, you can end up with numerical issues.
One very obvious reason is that you need to tune (but you don't) the weight initialisations in the network according to the input range corresponding to that weight, e.g. let $x_1,x_2$ be two distinct features and $w_1,w_2$ be the corresponding weights. Also let the range of the feature be as follows: $x_1\in[0,1000],x_2\in[0,1]$. When you initialise $w_i$ with numbers within $[-1,1]$ for example, it won't mean the same for $x_1$ and $x_2$. Probably, the sum $w_1x_1+w_2x_2$ will be dominated by $w_1x_1$ and you won't see the effect of $w_2x_2$ for some time unless you're very lucky, and learning will be hindered significantly until the network is finally able to learn what $w_1$ should have been in the first place.

Doesn't normalization require that data conforms to the normal parametric distribution?

No, normalisation has nothing to do with normal distribution. One form of normalisation, called standardising, which is subtracting the mean and dividing by the deviation is very common in the literature and typically used for converting a normal RV into standard normal RV. Although the idea may stem from normal distributions, the operation has nothing to do with normal distribution.
Comment: This is a good read for those who needs more info. "If the distribution of the quantity is normal, then it should be standardized, otherwise the data should be normalized. " from https://machinelearningmastery.com/how-to-improve-neural-network-stability-and-modeling-performance-with-data-scaling/
Answer: The mention of Tensorflow in the question is a red herring -- the reasons that scaling is beneficial are not unique to Tensorflow, but instead are common to all methods that update model parameters using gradient descent. The reason we scale data is to improve gradient descent dynamics, and backpropagation using Tensorflow is just one application of gradient descent among many.
Optimization via gradient descent proceeds more easily when the optimization surface is more "circular" and less "elliptical."  The optimization proceeds more quickly in directions corresponding to the largest eigenvalue and more slowly in directions corresponding to the smallest eigenvalue. In other words, the optimization procedure is easier when the eigenvalues of the Hessian are on the same scale.
None of this depends on the input data conforming to any particular parametric distribution; rescaling the inputs to have a common variance has the effect of preconditioning the Hessian matrix.
More information: In Machine learning, how does normalization help in convergence of gradient descent?
In general, real-valued inputs can be rescaled.
There are some corner cases where rescaling inputs doesn't make any sense. For example, embeddings use a lookup table to transform integer-coded inputs to a specific vector. Rescaling this to have 0 mean and variance 1 (or vary between 0 and 1) is meaningless and not helpful, because it breaks the lookup table property.


Simple question about an exemple in covers

Question:
A collection $\mathcal{O}$ of open sets is an open cover of $A$
  (or, briefly, covers $A$) if every point $x\in A$ is in some open
  set in the collection $\mathcal{O}$. For example, if $\mathcal{O}$ is
  the collection of all open intervals $(a,a+1)$ for $a\in\Bbb R$, then
  $\mathcal{O}$ is a cover of $\Bbb R$. Clearly no finite number of the
  open sets in $\mathcal{O}$ will cover $\Bbb R$ or, for that matter,
  any unbounded subset of $\Bbb R$.

I don't get the last one (in italic).
Take $(0,1)$ (which is an unbounded subset of $\mathbb R$) then if we take $a=0$ then this set $\{(0,1)\}$ will cover the subset $(0,1)$.
Answer: You are misunderstanding the term "unbounded". This term means that the set contains elements of arbitrarily large magnitude, i.e., it is not contained in $[-N,N]$ for any positive number $N$.
Your comment suggests you are thinking of the term as meaning "not containing its boundary". This is incorrect. The set $(0,1)$ which you cite is indeed bounded (and not unbounded, contrary to your claim) since it is contained in (say) $[-17,17]$. You could, of course, choose the more efficient containing set $[1,1]$, but the point is there just has to be some bounding interval.
Comment: thank you mpw i cant add comments or register ,i didnt know the definition of unbounded (im not english so i thought it just means a normal open set )
Comment: If we are working in $\mathbb{R}$, a set $S$ is **bounded** if there are reals $a$ and $b$ such that $a\lt x\lt b$ for every $x$ in $S$. A set is **unbounded** if it is not bounded. In $\mathbb{R}^n$, a set $S$ is bounded if there is a ball that contains every element of $S$.
Comment: @daclaro Take care of your id information then you can log in again.


AVD Manager - Can't run multiple emulators any more

Question: I know that the AVD Manager can run multiple emulators but with the new version in the last couple of days it stopped working. It stopped doing that thing where it launches 4 command prompt windows and it just has a loading bar but now I can't run more than 1 at once. When I click start, the load bar completes but no emulator loads, no visible changes.
The only errors in the logcat in Eclipse are:
07-04 10:12:18.563: D/SntpClient(71): request time failed: java.net.SocketException:
    Address family not supported by protocol

No idea if this is relevant.
EDITED
I also seem to be getting this issue when starting the emulator as well sometimes:
Starting emulator for AVD 'Android_2_2_480x854'
WARNING: Data partition already in use. Changes will not persist!
WARNING: SD Card image already in use: C:\Users\USERNAME\.android\avd\Android_2_2_480x854.avd/sdcard.img
ko:Snapshot storage already in use: C:\Users\USERNAME\.android\avd\Android_2_2_480x854.avd/snapshots.img

This is an app created by another development team and we are just a testing team so I'm not in a position to change anything (just have the apk to test).
Things tried so far:

Restarting ADB
Looking up errors on Google
Restart ADB manager /
Eclipse
Comment: Ok I just assumed this was for Android development. If stack sites have nothing aggainst duplicates I'll move it.
Comment: Just to note, while Android development is off-topic on Android Enthusiasts we do accept "use" questions about the emulator.  This would seem to fall into that category, so I don't think it needed to be migrated.  However you are more likely to get an answer here on SO, I think, so it was probably a good thing :).  Feel free to ask any end-user questions over on Android.  CC @eldarerathis
Comment: Ok thanks for moving it across.
Answer: Right, not working for me either since the update. It's been reported to Google-issues subscribe/vote to the issue so they fix it soon.
Meanwhile, a good alternative is to set a Virtual Box running the x86 Android version. It's also quite faster than the ARM emulator, though a bit tricky to setup the network and not as automatic as creating and starting emulators from Eclipse.
Comment: That issue was a duplicate and this is the new link for the issue: http://code.google.com/p/android/issues/detail?id=33936


JSON object undefined in Internet Explorer 8

Question: Currently I'm writing a JavaScript file and have the following line:
var res = "JSON=" + JSON.stringify(result);

result is being set just above this line. The issue I'm having is that IE8 (IE8 only, that is) is reporting to me that JSON is undefined somehow. I'm not sure what to make of this since, as I understood it, IE8 is a browser that implemented JSON support. Does anyone have any idea what might be going on?
Comment: Are you in compatibility mode?
Answer: Make sure you're actually in IE 8 mode by using the preferred method, a standards doctype...
<!DOCTYPE html>

...or the undesired method, the X-UA-Compatible meta tag/header...
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />

See Defining Document Compatibility for more information.
Comment: Definitely worth checking this, because compat mode can be triggered without you necessarily realising it - open the Developer Tools (F12) and look in the toolbar for the browser mode.
Comment: I dropped this line in and checked the dev tools. Definitely running in IE8 Standards Mode.
Comment: Eventually I did fix the problem. Turns out it wasn't this BUT IE7 compatibility was going to be one of the next things I had to work on and you've no doubt saved me time already. Thanks!
Comment: @keybored: something **must** be overriding the JSON global object then.  Check your code for variations of `JSON =` (the example code you wrote in the question is a good start - are you using `eval`?).
Comment: I haven't seen anything like that but I was wondering something, the above call is being made from within an iframe. Would I need to call up to the parent to actually get at JSON?
Comment: +1 for correct answer. In my case no problem running locally in VS2010 but when published to IIS 7 64 bit server got the error.
Comment: @keybored what was your solution?
Comment: It's been a while buit IIRC it was either a bug in my JS code or a transient Facebook bug. Wish I could remember specifically.
Comment: Please use the doctype instead of the X-UA-Compatible junk
Comment: @SystemParadox: just for you, I've clarified the answer :p
Comment: @SystemParadox sorry for reviving this but i do have a valid doctype yet i still had problems with IE10 i do not have Comp mode manually set so im not sure what triggered it, my code is html valid so the only thing that worked for me is the X-UA junk, any thoughts ?
Comment: My thoughts? IE is broken. I don't use it. I don't expect to see the DOM cluttered with its junk either. If IE's JS environment is broken, load a JS shim that fixes it. Or just show an error...
Answer: Using jQuery.parseJSON solved this for me, in case you are already using JQuery.
Answer: Other things that absence of doctype or wrong doctype, or some error with html syntax, will force IE to use document modes different from what you expect.
I was using simple "" in a test document and the absence of TITLE tag as a child of HEAD tag made window.JSON become undefined.
Remember always that it's better to test the resource against the version of browser. And, if your users can use IE's with emulation of document modes, it's better you have a piece of code  to provide the JSON.parse and JSON.stringify when natives are undefined.
Answer: function parseJson(jsonString) {
    if ($.browser.msie && $.browser.version < 8) {
        return eval('(' + jsonString + ')');
    }
    else {
        return JSON.parse(jsonString);
    }
}

Comment: This doesn't even attempt to answer the question.
Answer: May happen despite <!DOCTYPE html> if the page encoding is UTF-8 with BOM (byte order mark). Try saving the file as UTF-8 without BOM, using a suitable text editor.
Answer: put following code in your js file ;
var JSON = JSON || {};

// implement JSON.stringify serialization
JSON.stringify = JSON.stringify || function (obj) {

var t = typeof (obj);
if (t != "object" || obj === null) {

    // simple data type
    if (t == "string") obj = '"'+obj+'"';
    return String(obj);

}
else {

    // recurse array or object
    var n, v, json = [], arr = (obj && obj.constructor == Array);

    for (n in obj) {
        v = obj[n]; t = typeof(v);

        if (t == "string") v = '"'+v+'"';
        else if (t == "object" && v !== null) v = JSON.stringify(v);

        json.push((arr ? "" : '"' + n + '":') + String(v));
    }

    return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
}
};

// implement JSON.parse de-serialization
JSON.parse = JSON.parse || function (str) {
if (str === "") str = '""';
eval("var p=" + str + ";");
return p;
 };

Comment: Leaving aside the lack of any attempt to actually answer the *question*, this is terrible code. Besides the opaque one-letter variable names, the broken formatting, and the resort to `eval` for parsing, the kicker is that the stringifier doesn't even work; it returns the wrong result for any string containing a double quote, a newline, a backslash, or probably plenty of other things.
Answer: Check jQuery version.
jQuery 2.0 drops support for IE 6, 7 and 8. Use jQuery 1.x instead, which is still officially supported.
you can use this Code.

read more about jquery migrate.
if not working check this article.
Comment: The OP has not said that he is using jQuery, and even if he were, he is asking about the native `JSON` global which is not part of jQuery. This answer is utterly and entirely irrelevant.
Answer: In my case the undefined error was because I was missing a JSON library.
You can add JSON object like this (replace the relative path with your own path):

For json2 library:
http://cdnjs.com/libraries/json2/
There is also a json3 library:
http://cdnjs.com/libraries/json3/
Then you can refer to it in your code:
var array = [];
array[1] = "apple";
array[2] = "orange";
alert(JSON.stringify(array));


Getting admob above actionbarsherlock

Question: I want to use AdMob and ActionBarSherlock in the same android aplication, but I don't manageto put AdMob on the top of my screen (above Sherlock ActionBar).
Anyone had some similar problems? Does anyone knows about some workaround?
Thanks.
My general layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<include layout="@layout/admob"/>
<TabHost
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@android:id/tabhost"
 android:layout_width="match_parent"
 android:layout_height="match_parent">
 <LinearLayout.....

My admob layout:
<?xml version="1.0" encoding="utf-8"?>
<com.google.ads.AdView xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
                    android:id="@+id/adView"
                    android:layout_height="wrap_content"
                    ads:adUnitId="123456"
                    ads:adSize="BANNER"
                    android:layout_width="match_parent"/>

Answer: I'm using ActionBarSherlock as wrapper and the following puts the ad above the action bar:
private ActionBarSherlock sherlock = ActionBarSherlock.wrap(this);

@Override
public void onCreate(Bundle savedInstanceState)
{
    /* ... set up layout here ... */

    adView = new AdView(this, AdSize.BANNER, "deadbeefmeat");

    ViewParent parentView = appView.getParent();
    do
    {
        parentView = parentView.getParent();
    } while(!(parentView instanceof LinearLayout));

    ((LinearLayout)parentView).addView(adView, 0);

    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
    adView.loadAd(adRequest);
}

// All setContentView methods are overridden because ActionBarSherlock has to modify the view
@Override
public void setContentView(int layoutResID)
{
    // Don't call super!
    sherlock.setContentView(layoutResID);
}

@Override
public void setContentView(View view)
{
    // Don't call super!
    sherlock.setContentView(view);
}

@Override
public void setContentView(View view, LayoutParams params)
{
    // Don't call super!
    sherlock.setContentView(view, params);
}

Comment: I haven't found a way how it works with build in Android ActionBar. Do you know a way? This is may question with android ActionBar: http://stackoverflow.com/questions/17258323/how-to-place-admob-at-the-top-of-the-screen-above-android-actionbar

Getting admob above actionbarsherlock


How do I make my UIButton title have some padding?

Question: Let's say I have a UIButton with a size of 120 wide by 30 high. I set an attributed title on it with centered text and I set a background color on the text of the attributed text for the .highlighted state.
When the user highlights the button, I want the background that shows around the title to have the same frame as the button.
I've tried positive and negative values for the button's titleEdgeInsets and contentEdgeInsets with no luck. Any suggestions here? Thanks
Comment: Well I had an answer but you totally changed the question into something I find incomprehensible.
Comment: Well I'm just hoping to get you to clarify the question. That's not combative; the aim was so I could try to help.
Comment: I understand and let me also say I greatly appreciate the time you put into answering questions on SO. I was more speaking to a question I answered last week where the comments as well as the answer all had a pretty combative tone. It also applies to questions I've asked in the past
Comment: If you're talking about your https://stackoverflow.com/questions/59672144/how-do-i-get-a-uibutton-to-size-itself-in-a-uistackview exactly the opposite is true; I spent a lot of time on that question (a couple of hours actually), writing example code that proved that the code you had supplied did not have the effect you described and, unlike your code, was a complete and reproducible example. Your response was basically to reveal that I had wasted my time because in fact your code was different than what you had showed. At that point I wasn't rude, I just walked away.
Comment: Yeah that was the main one I was referencing. I was trying to obfuscate the code so as not to copy and paste code directly and I did a bad job there. It was never my intent to waste your time, quite the contrary. I apologize for that.
Answer: The easiest (meaning most controllable) way in my opinion is to use a button subclass and override titleRect. It's called when highlighted and when unhighlighted so you get a chance to change your answer depending on the state.
However, that won't change the size of the background color of attributed text, because it applies only to the text. You'd need to change the background color of the title label itself.
Comment: Thank you Matt, I appreciate your help.


Native Postman returns 503 when posting to localhost but Chrome Postman extension works

Question: I am trying to post simple Get commands to my service running on localhost using the Windows native Postman application (V4.8.0) but they fail. The Postman Console shows

Error: tunneling socket could not be established, statusCode=503

An example of the Get command is the following request for simple status message.
https://localhost/api/admin/status

The same commands work when directed to the identical service running on an external server.
They also work posting to localhost directly from Chrome and when using the Chrome Postman extension (also V4.8.0).
SSL certificate verification is turned off.
Answer: I had the same problem.
In my case env variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY where set in my envirionment.
But in NO_PROXY the value for localhost was missing and that caused the 503 error.
After adding localhost to NO_PROXY env variable, postman worked for my localhost adresses as well.
Answer: For test localhost turn off proxy configuration.
Answer: I tried to add the NO_PROXY env. var. to no avail.
Instead I changed the proxy setting (File - Settings), and add a global proxy configuration.
I put 127.0.0.1, and for the port, it has to be the port where our web app is located. (I found that the port number cannot be overridden through the URL). In your case, I suppose it is 80.
Might not be the best workaround, nevertheless it worked.
(Postman ver: 6.7.3)


Rodapé não está sendo responsivo

Question: Eu fiz um site e o restante está responsivo, sem problema algum. Mas, o meu footer, está ficando por cima de outros elementos quando vou testar em telas menores.
HTML:

SOBRE A EMPRESA

Lorem ipsum enim lobortis consectetur quis congue
                    fames quis suspendisse torquent imperdiet orem ipsum
                    enim lobortis consectetur quis congue fames quis
                    suspendisse torquent imperdiet

LINK DE NAVEGAÇÃO

Inicio

Sobre Nós

Contatos

Serviço

Preço

SOBRE A EMPRESA

Lorem ipsum enim lobortis consectetur quis congue
            fames quis suspendisse torquent imperdiet orem ipsum
            enim lobortis consectetur quis congue fames quis
            suspendisse torquent imperdiet

 ©2020 Todos os direitos reservados

CSS:
.footersection{
    width: 100%;
    height: auto;
    padding:70px 0 20px;
    background: #00abff;
    position: absolute;
}
.footersection p{
    color:#fff;
}
.footersection li a{
    font-size: 1.0rem;
    line-height: 1.6;
    font-weight: 600;
    color: #fff;
    text-transform: capitalize;
}
.footersection h3{
    text-transform: uppercase;
    color:#fff;
    margin-bottom: 25px;
    font-size: 1.2rem!important;
    font-weight: 600;
    text-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

Comment: É só tirar o position: absolute; do footer
Answer: Ele fica por cima por conta do position:absolute, uma coisa que tu pode fazer é declarar um min-height:90vh; no elemento onde fica teu conteúdo, anterior ao footer, aí sempre que tua página não tiver conteúdo suficiente para ocupar a tela teu footer se mantém sempre no fim da página e não sobe lá pro meio dela. O tamanho da altura eu coloquei 90 de exemplo, pode mudar de acordo com a altura do teu footer
Comment: Obrigada! Deu super certo!
Answer: Tente retirar o
position: absolute

Comment: Obrigada! Consegui!

Rodapé não está sendo responsivo


What is the difference between `##` and `hashCode`?

Question: What is the difference between methods ## and hashCode?
They seem to be outputting the same values no matter which class or hashCode overloading I use. Google doesn't help, either, as it cannot find symbol ##.
Comment: A little offtopic, but you can search for such symbols using [SymbolHound](http://www.symbolhound.com/).
Comment: Ah ok. So, `1.hashCode` `==` `1.##`, and `1.2.hashCode` `==` `1.2.##`. The only thing that behaves differently is `1.0.hashCode` `!=` `1.0.##` (so `##` is better suited for comparing numbers).
Comment: `1.0 hashCode` v `1.0 ##` v `1 hashCode` v `1 ##` — http://www.scala-lang.org/api/current/scala/Any.html
Comment: From the Scala docs on Any "Equivalent to x.hashCode except for boxed numeric types. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them.".
Comment: @om-nom-nom, a little of topic, but thanks for the tip. That's awesome!
Answer: "Subclasses" of AnyVal do not behave properly from a hashing perspective:
scala> 1.0.hashCode
res14: Int = 1072693248

Of course this is boxed to a call to:
scala> new java.lang.Double(1.0).hashCode
res16: Int = 1072693248

We might prefer it to be:
scala> new java.lang.Double(1.0).##
res17: Int = 1

scala> 1.0.##
res15: Int = 1

We should expect this given that the int 1 is also the double 1. Of course this issue does not arise in Java. Without it, we'd have this problem:
Set(1.0) contains 1 //compiles but is false

Luckily:
scala> Set(1.0) contains 1
res21: Boolean = true

Comment: So, when implementing both `equals` and `hashCode` for a particular class, I'm not sure how this translates into the best strategy. I am assuming the `hashCode` implementation should use `##`. However, should the `equals` implementation use `hashCode` or `##`? Here's the answer I provided on another thread which assumes that the `equals` implementation should use `hashCode` and the `hashCode` implementation should use `##`. Evaluation and feedback on this would be greatly appreciated. https://stackoverflow.com/a/56509518/501113
Answer: ## was introduced because hashCode is not consistent with the == operator in Scala. If a == b then a.## == b.## regardless of the type of a and b (if custom hashCode implementations are correct). The same is not true for hashCode as can be seen in the examples given by other posters.
Comment: So, when implementing both `equals` and `hashCode` for a particular class, I'm not sure how this translates into the best strategy. I am assuming the `hashCode` implementation should use `##`. However, should the `equals` implementation use `hashCode` or `##`? Here's the answer I provided on another thread which assumes that the `equals` implementation should use `hashCode` and the `hashCode` implementation should use `##`. Evaluation and feedback on this would be greatly appreciated. https://stackoverflow.com/a/56509518/501113
Answer: Just want to add to the answers of other posters that although the ## method strives to keep the contract between equality and hash codes, it is apparently not good enough in some cases, like when you are comparing doubles and longs (scala 2.10.2):
> import java.lang._
import java.lang._

> val lng = Integer.MAX_VALUE.toLong + 1
lng: Long = 2147483648

> val dbl = Integer.MAX_VALUE.toDouble + 1
dbl: Double = 2.147483648E9

> lng == dbl
res65: Boolean = true

> lng.## == dbl.##
res66: Boolean = false

> (lng.##, lng.hashCode)
res67: (Int, Int) = (-2147483647,-2147483648)

> (dbl.##, dbl.hashCode)
res68: (Int, Int) = (-2147483648,1105199104)

Comment: I just checked this in scala 2.11.7 and did not see the same behavior for `==` and `.## == .##`
Comment: Really? Is this a bug?
Comment: It clearly is as according to scaladoc for ## "... it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them..."
Answer: In addition to what everyone else said, I'd like to say that ## is null-safe, because null.## returns  0 whereas null.hashCode throws NullPointerException.
From scaladoc:

Equivalent to x.hashCode except for boxed numeric types and null. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them. For null returns a hashcode where null.hashCode throws a NullPointerException.