Can you spend your time just walking around in Animal Crossing?

Question: My three-year-old daughter loves to just walk around the landscape of whatever game I've got in my Nintendo Switch at the time, which is great, but I'm trying to play LoZ: Skyward Sword at the minute and she's getting frustrated at the bats flying around and hitting her in the head and it's stopping me progressing out of the Knights Academy where she seems to be "safe" to walk around...
I had the thought that I could just buy Animal Crossing: NH for her since my understanding of the game is you're just managing your own little village (I've never played one!) so I was hoping she'd just be able to walk around this little village to her hearts content without some NPC interrupting her merry little path...
Is this the case or are there similar fiendish interruptions that would annoy her?
Comment: Minecraft on Nintendo Switch can work wonders for that. Put it on Creative Mode and let your kid roam around and punch blocks to their heart's content. It has a Mario-themed map that is very pretty, and a few other fun ones, too.
Comment: Alba: A Wildlife Adventure is 100% peaceful and is good for just walking around, since a large part of the game is exploring and watching animals. I recently got it on Switch for some younger kids and was happy with it.
Comment: @februaryInk - thanks, I've downloaded Alba onto my phone and shes enjoying that too!
Comment: Hi, also if you ever want to look for more games where you daughter can just walk around, look for the genre "Walking Simulators" it should have some good ones.  Hope this helps if you need it.  =)
Answer: Animal Crossing New Horizons does have scorpions that walk on the ground, as well as spiders that fall from shaken trees. However, the scorpions won't kill, they will only make the player faint, and make the player respawn at their house, no matter where they fainted on the island. I do believe there are some sort of "spawn condition" for these dangerous critters that I am not aware of…
I think you should be safe if you just stay in the village, but I can't be 100% certain.
Hope this helped.
Answer: As previously mentioned, there is minimal danger from just walking around your island  apart from mildly dangerous bugs. Spiders and scorpions both only spawn at night (real time), so if this is a problem then you could set your Switch's internal clock to daytime again and the bugs go away.
Wasps can occasionally appear when a tree is shaken, which may happen at any time of day. These flying annoyances can sting your character the same way a spider or scorpion would. They only appear when their nest happens to be shaken loose from their tree, unlike their creepy crawly counterparts which merely spawn at night.
For your daughter I think is Animal Crossing is an excellent and safe game, but just be aware that the game requires you to build your island from the ground up - so there may be little for her to do on the small island, and activities are especially limited for the first 24 hours (real time) while your character settles in.
If you wish, you can read  more about the three dangerous critters of Animal Crossing here.
Comment: @Sayse I suspect if you have her create a character, and show her YOUR character's house, and send her letters from YOUR character to HER character, she'll quickly want to use her character!  Plus the clothing items and such.
Comment: I think the perfect way to play with a 3 year old would be to have the adult play (and managing the island building business), and have the child be a guest (its one island per switch, and switch account that logs in after is a guest that has only the basics of walking around, fishing, talking, etc.)
Comment: In any way, even if shes not on her own account, there's not much truly destructive stuff you could do in ACNH
Comment: This question (https://gaming.stackexchange.com/questions/365441/can-you-have-2-different-islands-on-the-same-switch) has details about what is blocked or not for the guest player, but a Question could be added to completely list what is blocked/available for the guest.
Comment: I'm happy to do the building of the island so she has something different to walk around every so often :) and @Fredy31 - That sounds perfect except for some reason she never uses her own account on the switch even if i log in on her account before hand lol, im sure other people will find that useful of course!
Comment: @Joe - That sounds amazing for most parents, however the one detail I didn't include in my post is she's autistic and communicating tasks like that are a little difficult at her current age :)


choosing attributes when leveling

Question: I have a thief/archer that so far has nearly even distribution of attributes (magicka/health/stamina) at level 16 with stamina slightly lower.
So far my reasoning is:

although I am not primarily a mage, magic drains faster because of my thief armor and I plan to dabble more in illusion
Stamina lags behind strength because carry capacity is already boosted via thief perks

My concern is that this "jack of all trades" mentality will make the game harder in the long run. I have read that later enemies and dragons basically required offensive magic. Should I ease back on magicka and make health my primary stat (1/1.5/1)?
Answer: If you plan on using Illusion, primarily, that's a once or twice per battle kind of magic. You're not spamming illusion spells nonstop in an effort to kill everyone. You disable the big threat and cause some chaos, then add in damage with your bow at range.
Being a stealth assassin type, you also shouldn't (theoretically) be taking a lot of damage. Your companion (which you should use) should be acting as a meat shield while you put some arrows in the target, and only really beefy opponents in really narrow passageways should be damaging you. Especially if you use illusion's calm/fear effects, your health should be pretty safe.
That being said, things never go fully according to plan, so health is still a good choice. As an archer, you need stamina to zoom and slow time, and you'd be surprised how quickly it runs out once you get those perks. I have built my archery/sneak/illusion assassin using a 2:1 ratio putting points into health:stamina, and never putting anything into magicka. At some point I would like to increase my magicka by about 50 points, because it seems a little low, but at level 30 so far this seems to be a good mix.

choosing attributes when leveling


JavaScript runtime error: '$' is undefined when trying to run sample code

Question: I am trying to run the sample chart code from
http://www.highcharts.com/demo/line-time-series
but its breaking. I am getting following error

Unhandled exception at line 12, column 7  0x800a1391 - JavaScript
  runtime error: '$' is undefined

The code:
  $(function () {
      $('#container').highcharts({
          chart: {
              zoomType: 'x',
              spacingRight: 20
          },
          title: {
              text: 'USD to EUR exchange rate from 2006 through 2008'
          },
          subtitle: {
              text: document.ontouchstart === undefined ?
                  'Click and drag in the plot area to zoom in' :
                  'Pinch the chart to zoom in'
          },
          xAxis: {
              type: 'datetime',
              maxZoom: 14 * 24 * 3600000, // fourteen days
              title: {
                  text: null
              }
          },
          yAxis: {
              title: {
                  text: 'Exchange rate'
              }
          },
          tooltip: {
              shared: true
          },
          legend: {
              enabled: false
          },
          plotOptions: {
              area: {
                  fillColor: {
                      linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
                      stops: [
                          [0, Highcharts.getOptions().colors[0]],
                          [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                      ]
                  },
                  lineWidth: 1,
                  marker: {
                      enabled: false
                  },
                  shadow: false,
                  states: {
                      hover: {
                          lineWidth: 1
                      }
                  },
                  threshold: null
              }
          },

          series: [{
              type: 'area',
              name: 'USD to EUR',
              pointInterval: 24 * 3600 * 1000,
              pointStart: Date.UTC(2006, 0, 01),
              data: [
                  0.8446, 0.8445, 0.8444, 0.8451, 0.8418, 0.8264, 0.8258, 0.8232, 0.8233, 0.8258,
                  0.8283, 0.8278, 0.8256, 0.8292, 0.8239, 0.8239, 0.8245, 0.8265, 0.8261, 0.8269,
                  0.8273, 0.8244, 0.8244, 0.8172, 0.8139, 0.8146, 0.8164, 0.82, 0.8269, 0.8269,
                  0.8269, 0.8258, 0.8247, 0.8286, 0.8289, 0.8316, 0.832, 0.8333, 0.8352, 0.8357,
                  0.8355, 0.8354, 0.8403, 0.8403, 0.8406, 0.8403, 0.8396, 0.8418, 0.8409, 0.8384,
                  0.8386, 0.8372, 0.839, 0.84, 0.8389, 0.84, 0.8423, 0.8423, 0.8435, 0.8422,
                  0.838, 0.8373, 0.8316, 0.8303, 0.8303, 0.8302, 0.8369, 0.84, 0.8385, 0.84,
                  0.8401, 0.8402, 0.8381, 0.8351, 0.8314, 0.8273, 0.8213, 0.8207, 0.8207, 0.8215,
                  0.8242, 0.8273, 0.8301, 0.8346, 0.8312, 0.8312, 0.8312, 0.8306, 0.8327, 0.8282,
                  0.824, 0.8255, 0.8256, 0.8273, 0.8209, 0.8151, 0.8149, 0.8213, 0.8273, 0.8273,
                  0.8261, 0.8252, 0.824, 0.8262, 0.8258, 0.8261, 0.826, 0.8199, 0.8153, 0.8097,
                  0.8101, 0.8119, 0.8107, 0.8105, 0.8084, 0.8069, 0.8047, 0.8023, 0.7965, 0.7919,
                  0.7921, 0.7922, 0.7934, 0.7918, 0.7915, 0.787, 0.7861, 0.7861, 0.7853, 0.7867,
                  0.7827, 0.7834, 0.7766, 0.7751, 0.7739, 0.7767, 0.7802, 0.7788, 0.7828, 0.7816,
                  0.7829, 0.783, 0.7829, 0.7781, 0.7811, 0.7831, 0.7826, 0.7855, 0.7855, 0.7845,
                  0.7798, 0.7777, 0.7822, 0.7785, 0.7744, 0.7743, 0.7726, 0.7766, 0.7806, 0.785,
                  0.7907, 0.7912, 0.7913, 0.7931, 0.7952, 0.7951, 0.7928, 0.791, 0.7913, 0.7912,
                  0.7941, 0.7953, 0.7921, 0.7919, 0.7968, 0.7999, 0.7999, 0.7974, 0.7942, 0.796,
                  0.7969, 0.7862, 0.7821, 0.7821, 0.7821, 0.7811, 0.7833, 0.7849, 0.7819, 0.7809,
                  0.7809, 0.7827, 0.7848, 0.785, 0.7873, 0.7894, 0.7907, 0.7909, 0.7947, 0.7987,
                  0.799, 0.7927, 0.79, 0.7878, 0.7878, 0.7907, 0.7922, 0.7937, 0.786, 0.787,
                  0.7838, 0.7838, 0.7837, 0.7836, 0.7806, 0.7825, 0.7798, 0.777, 0.777, 0.7772,
                  0.7793, 0.7788, 0.7785, 0.7832, 0.7865, 0.7865, 0.7853, 0.7847, 0.7809, 0.778,
                  0.7799, 0.78, 0.7801, 0.7765, 0.7785, 0.7811, 0.782, 0.7835, 0.7845, 0.7844,
                  0.782, 0.7811, 0.7795, 0.7794, 0.7806, 0.7794, 0.7794, 0.7778, 0.7793, 0.7808,
                  0.7824, 0.787, 0.7894, 0.7893, 0.7882, 0.7871, 0.7882, 0.7871, 0.7878, 0.79,
                  0.7901, 0.7898, 0.7879, 0.7886, 0.7858, 0.7814, 0.7825, 0.7826, 0.7826, 0.786,
                  0.7878, 0.7868, 0.7883, 0.7893, 0.7892, 0.7876, 0.785, 0.787, 0.7873, 0.7901,
                  0.7936, 0.7939, 0.7938, 0.7956, 0.7975, 0.7978, 0.7972, 0.7995, 0.7995, 0.7994,
                  0.7976, 0.7977, 0.796, 0.7922, 0.7928, 0.7929, 0.7948, 0.797, 0.7953, 0.7907,
                  0.7872, 0.7852, 0.7852, 0.786, 0.7862, 0.7836, 0.7837, 0.784, 0.7867, 0.7867,
                  0.7869, 0.7837, 0.7827, 0.7825, 0.7779, 0.7791, 0.779, 0.7787, 0.78, 0.7807,
                  0.7803, 0.7817, 0.7799, 0.7799, 0.7795, 0.7801, 0.7765, 0.7725, 0.7683, 0.7641,
                  0.7639, 0.7616, 0.7608, 0.759, 0.7582, 0.7539, 0.75, 0.75, 0.7507, 0.7505,
                  0.7516, 0.7522, 0.7531, 0.7577, 0.7577, 0.7582, 0.755, 0.7542, 0.7576, 0.7616,
                  0.7648, 0.7648, 0.7641, 0.7614, 0.757, 0.7587, 0.7588, 0.762, 0.762, 0.7617,
                  0.7618, 0.7615, 0.7612, 0.7596, 0.758, 0.758, 0.758, 0.7547, 0.7549, 0.7613,
                  0.7655, 0.7693, 0.7694, 0.7688, 0.7678, 0.7708, 0.7727, 0.7749, 0.7741, 0.7741,
                  0.7732, 0.7727, 0.7737, 0.7724, 0.7712, 0.772, 0.7721, 0.7717, 0.7704, 0.769,
                  0.7711, 0.774, 0.7745, 0.7745, 0.774, 0.7716, 0.7713, 0.7678, 0.7688, 0.7718,
                  0.7718, 0.7728, 0.7729, 0.7698, 0.7685, 0.7681, 0.769, 0.769, 0.7698, 0.7699,
                  0.7651, 0.7613, 0.7616, 0.7614, 0.7614, 0.7607, 0.7602, 0.7611, 0.7622, 0.7615,
                  0.7598, 0.7598, 0.7592, 0.7573, 0.7566, 0.7567, 0.7591, 0.7582, 0.7585, 0.7613,
                  0.7631, 0.7615, 0.76, 0.7613, 0.7627, 0.7627, 0.7608, 0.7583, 0.7575, 0.7562,
                  0.752, 0.7512, 0.7512, 0.7517, 0.752, 0.7511, 0.748, 0.7509, 0.7531, 0.7531,
                  0.7527, 0.7498, 0.7493, 0.7504, 0.75, 0.7491, 0.7491, 0.7485, 0.7484, 0.7492,
                  0.7471, 0.7459, 0.7477, 0.7477, 0.7483, 0.7458, 0.7448, 0.743, 0.7399, 0.7395,
                  0.7395, 0.7378, 0.7382, 0.7362, 0.7355, 0.7348, 0.7361, 0.7361, 0.7365, 0.7362,
                  0.7331, 0.7339, 0.7344, 0.7327, 0.7327, 0.7336, 0.7333, 0.7359, 0.7359, 0.7372,
                  0.736, 0.736, 0.735, 0.7365, 0.7384, 0.7395, 0.7413, 0.7397, 0.7396, 0.7385,
                  0.7378, 0.7366, 0.74, 0.7411, 0.7406, 0.7405, 0.7414, 0.7431, 0.7431, 0.7438,
                  0.7443, 0.7443, 0.7443, 0.7434, 0.7429, 0.7442, 0.744, 0.7439, 0.7437, 0.7437,
                  0.7429, 0.7403, 0.7399, 0.7418, 0.7468, 0.748, 0.748, 0.749, 0.7494, 0.7522,
                  0.7515, 0.7502, 0.7472, 0.7472, 0.7462, 0.7455, 0.7449, 0.7467, 0.7458, 0.7427,
                  0.7427, 0.743, 0.7429, 0.744, 0.743, 0.7422, 0.7388, 0.7388, 0.7369, 0.7345,
                  0.7345, 0.7345, 0.7352, 0.7341, 0.7341, 0.734, 0.7324, 0.7272, 0.7264, 0.7255,
                  0.7258, 0.7258, 0.7256, 0.7257, 0.7247, 0.7243, 0.7244, 0.7235, 0.7235, 0.7235,
                  0.7235, 0.7262, 0.7288, 0.7301, 0.7337, 0.7337, 0.7324, 0.7297, 0.7317, 0.7315,
                  0.7288, 0.7263, 0.7263, 0.7242, 0.7253, 0.7264, 0.727, 0.7312, 0.7305, 0.7305,
                  0.7318, 0.7358, 0.7409, 0.7454, 0.7437, 0.7424, 0.7424, 0.7415, 0.7419, 0.7414,
                  0.7377, 0.7355, 0.7315, 0.7315, 0.732, 0.7332, 0.7346, 0.7328, 0.7323, 0.734,
                  0.734, 0.7336, 0.7351, 0.7346, 0.7321, 0.7294, 0.7266, 0.7266, 0.7254, 0.7242,
                  0.7213, 0.7197, 0.7209, 0.721, 0.721, 0.721, 0.7209, 0.7159, 0.7133, 0.7105,
                  0.7099, 0.7099, 0.7093, 0.7093, 0.7076, 0.707, 0.7049, 0.7012, 0.7011, 0.7019,
                  0.7046, 0.7063, 0.7089, 0.7077, 0.7077, 0.7077, 0.7091, 0.7118, 0.7079, 0.7053,
                  0.705, 0.7055, 0.7055, 0.7045, 0.7051, 0.7051, 0.7017, 0.7, 0.6995, 0.6994,
                  0.7014, 0.7036, 0.7021, 0.7002, 0.6967, 0.695, 0.695, 0.6939, 0.694, 0.6922,
                  0.6919, 0.6914, 0.6894, 0.6891, 0.6904, 0.689, 0.6834, 0.6823, 0.6807, 0.6815,
                  0.6815, 0.6847, 0.6859, 0.6822, 0.6827, 0.6837, 0.6823, 0.6822, 0.6822, 0.6792,
                  0.6746, 0.6735, 0.6731, 0.6742, 0.6744, 0.6739, 0.6731, 0.6761, 0.6761, 0.6785,
                  0.6818, 0.6836, 0.6823, 0.6805, 0.6793, 0.6849, 0.6833, 0.6825, 0.6825, 0.6816,
                  0.6799, 0.6813, 0.6809, 0.6868, 0.6933, 0.6933, 0.6945, 0.6944, 0.6946, 0.6964,
                  0.6965, 0.6956, 0.6956, 0.695, 0.6948, 0.6928, 0.6887, 0.6824, 0.6794, 0.6794,
                  0.6803, 0.6855, 0.6824, 0.6791, 0.6783, 0.6785, 0.6785, 0.6797, 0.68, 0.6803,
                  0.6805, 0.676, 0.677, 0.677, 0.6736, 0.6726, 0.6764, 0.6821, 0.6831, 0.6842,
                  0.6842, 0.6887, 0.6903, 0.6848, 0.6824, 0.6788, 0.6814, 0.6814, 0.6797, 0.6769,
                  0.6765, 0.6733, 0.6729, 0.6758, 0.6758, 0.675, 0.678, 0.6833, 0.6856, 0.6903,
                  0.6896, 0.6896, 0.6882, 0.6879, 0.6862, 0.6852, 0.6823, 0.6813, 0.6813, 0.6822,
                  0.6802, 0.6802, 0.6784, 0.6748, 0.6747, 0.6747, 0.6748, 0.6733, 0.665, 0.6611,
                  0.6583, 0.659, 0.659, 0.6581, 0.6578, 0.6574, 0.6532, 0.6502, 0.6514, 0.6514,
                  0.6507, 0.651, 0.6489, 0.6424, 0.6406, 0.6382, 0.6382, 0.6341, 0.6344, 0.6378,
                  0.6439, 0.6478, 0.6481, 0.6481, 0.6494, 0.6438, 0.6377, 0.6329, 0.6336, 0.6333,
                  0.6333, 0.633, 0.6371, 0.6403, 0.6396, 0.6364, 0.6356, 0.6356, 0.6368, 0.6357,
                  0.6354, 0.632, 0.6332, 0.6328, 0.6331, 0.6342, 0.6321, 0.6302, 0.6278, 0.6308,
                  0.6324, 0.6324, 0.6307, 0.6277, 0.6269, 0.6335, 0.6392, 0.64, 0.6401, 0.6396,
                  0.6407, 0.6423, 0.6429, 0.6472, 0.6485, 0.6486, 0.6467, 0.6444, 0.6467, 0.6509,
                  0.6478, 0.6461, 0.6461, 0.6468, 0.6449, 0.647, 0.6461, 0.6452, 0.6422, 0.6422,
                  0.6425, 0.6414, 0.6366, 0.6346, 0.635, 0.6346, 0.6346, 0.6343, 0.6346, 0.6379,
                  0.6416, 0.6442, 0.6431, 0.6431, 0.6435, 0.644, 0.6473, 0.6469, 0.6386, 0.6356,
                  0.634, 0.6346, 0.643, 0.6452, 0.6467, 0.6506, 0.6504, 0.6503, 0.6481, 0.6451,
                  0.645, 0.6441, 0.6414, 0.6409, 0.6409, 0.6428, 0.6431, 0.6418, 0.6371, 0.6349,
                  0.6333, 0.6334, 0.6338, 0.6342, 0.632, 0.6318, 0.637, 0.6368, 0.6368, 0.6383,
                  0.6371, 0.6371, 0.6355, 0.632, 0.6277, 0.6276, 0.6291, 0.6274, 0.6293, 0.6311,
                  0.631, 0.6312, 0.6312, 0.6304, 0.6294, 0.6348, 0.6378, 0.6368, 0.6368, 0.6368,
                  0.636, 0.637, 0.6418, 0.6411, 0.6435, 0.6427, 0.6427, 0.6419, 0.6446, 0.6468,
                  0.6487, 0.6594, 0.6666, 0.6666, 0.6678, 0.6712, 0.6705, 0.6718, 0.6784, 0.6811,
                  0.6811, 0.6794, 0.6804, 0.6781, 0.6756, 0.6735, 0.6763, 0.6762, 0.6777, 0.6815,
                  0.6802, 0.678, 0.6796, 0.6817, 0.6817, 0.6832, 0.6877, 0.6912, 0.6914, 0.7009,
                  0.7012, 0.701, 0.7005, 0.7076, 0.7087, 0.717, 0.7105, 0.7031, 0.7029, 0.7006,
                  0.7035, 0.7045, 0.6956, 0.6988, 0.6915, 0.6914, 0.6859, 0.6778, 0.6815, 0.6815,
                  0.6843, 0.6846, 0.6846, 0.6923, 0.6997, 0.7098, 0.7188, 0.7232, 0.7262, 0.7266,
                  0.7359, 0.7368, 0.7337, 0.7317, 0.7387, 0.7467, 0.7461, 0.7366, 0.7319, 0.7361,
                  0.7437, 0.7432, 0.7461, 0.7461, 0.7454, 0.7549, 0.7742, 0.7801, 0.7903, 0.7876,
                  0.7928, 0.7991, 0.8007, 0.7823, 0.7661, 0.785, 0.7863, 0.7862, 0.7821, 0.7858,
                  0.7731, 0.7779, 0.7844, 0.7866, 0.7864, 0.7788, 0.7875, 0.7971, 0.8004, 0.7857,
                  0.7932, 0.7938, 0.7927, 0.7918, 0.7919, 0.7989, 0.7988, 0.7949, 0.7948, 0.7882,
                  0.7745, 0.771, 0.775, 0.7791, 0.7882, 0.7882, 0.7899, 0.7905, 0.7889, 0.7879,
                  0.7855, 0.7866, 0.7865, 0.7795, 0.7758, 0.7717, 0.761, 0.7497, 0.7471, 0.7473,
                  0.7407, 0.7288, 0.7074, 0.6927, 0.7083, 0.7191, 0.719, 0.7153, 0.7156, 0.7158,
                  0.714, 0.7119, 0.7129, 0.7129, 0.7049, 0.7095
              ]
          }]
      });
  });

Comment: You probably need to include the jQuery library at first. (The provided jsFiddle from the site also includes jQuery: http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-time-series/)
Comment: @b_dubb It's a scripting language like JavaScript :-) [You can even add numbers](http://www.doxdesk.com/img/updates/20091116-so-large.gif)
Comment: wow. internets sure are hard. especially when your javascripts have numbers in them
Comment: possible duplicate of [Microsoft JScript runtime error: '$' is undefined](http://stackoverflow.com/questions/8530311/microsoft-jscript-runtime-error-is-undefined)
Answer:

include this in your head section. $ is an alias for Jquery.


Limit involving ratios of inverse functions

Question: Let $H(t)$ be an strictly increasing function such that $\lim_{t\to \infty}H(t)=\infty$. Assuming that $$\lim_{t\to \infty}\frac{H(t)}{\log t}=1$$ I would like to prove or disprove that
$$\lim_{y\to \infty}\frac{H^{-1}(y)}{\exp(y)}=1$$
I have not been able to find a counterexample but also not been able to prove if it is true! Looks to me this has to be true!
Answer: A counterexample. Take $H(t)=\ln(t)+\ln(\ln(t))$ then $$\lim_{t\to +\infty}\frac{H(t)}{\ln(t)} =1.$$ Moreover, by letting $y=H(t)$, we have that
$$\lim_{y\to +\infty}\frac{H^{-1}(y)}{\exp(y)}=\lim_{t\to +\infty}\frac{t}{\exp(H(t))}=\lim_{t\to +\infty}\frac{t}{\exp(\ln(t)+\ln(\ln(t)))}\\=\lim_{t\to +\infty}\frac{t}{t\cdot\ln(t)}=\lim_{t\to +\infty}\frac{1}{\ln(t)}=0.$$


What is the recommened HW specs for virtualizations?

Question: We are a startup company and doesnt have invested yet in HW resources in order to prepre our dev and testing environment. The suggestion is to buy a high end server, install vmware ESX and deploy mutiple VMs for build, TFS, database, ... for testing,stging and dev enviornment.
We are still not sure what specs to go with e.g. RAM, whether SAN is needed?, HD, Processor, etc..?
Please advice.
Comment: Voted to close: "not programming related".
Comment: How is this programming related?
Answer: You haven't really given much information to go on. It all depends on what type of applications you're developing, resource usage, need to configure different environments, etc.
Virtualization provides cost savings when you're looking to consolidate underutilized hardware. If each environment is sitting idle most of the time, then it makes sense to virtualize them.
However if each of your build/tfs/testing/staging/dev environments will be heavily used by all developers during the working day simultaniously then there might not be as many cost savings by virtualizing everything.
My advice would be if you're not sure, then don't do it. You can always virtualize later and reuse the hardware.
Answer: This is a very open ended question that really has a best answer of ... "It depends".
If you have the money to get individual machines for everything you need then go that route.  You can scale back a little on the hardware with this option.
If you don't have the money to get individual machines, then you may want to look at a top end server for this.  If this is your route, I would look at a quad machine with at least 8GB RAM and multiple NICs.  You can go with a server box that has multiple hard drive bays that you can setup multiple RAIDS on.  I recommend that you use a RAID 5 so that you have redundancy.
With something like this you can run multiple VMWare sessions without much of a problem.
I setup a 10TB box at my last job.  It had 2 NICs, 8GB, and was a quad machine.  Everything included cost about 9.5K
Answer: Your hardware requirements will somewhat depend on what kind of reliability you want for this stuff.  If you're using this to run everything, I'd recommend having at least two machines you split the VMs over, and if you're using N servers normally, you should be able to get by on N-1 of them for the time it takes your vendor to replace the bad parts.
At the low-end, that's 2 servers.  If you want higher reliability (ie. less downtime), then a SAN of some kind to store the data on is going to be required (all the live migration stuff I've seen is SAN-based).  If you can live with the 'manual' method (power down both servers, move drives from server1 to server2, power up server2, reconfigure VMs to use less memory and start up), then you don't really need the SAN route.
At the end of the day, your biggest sizing requirement will be HD and RAM.  Your HD footprint will be relatively fixed (at least in most kinds of a dev/test environment), and your RAM footprint should be relatively fixed as well (though extra here is always nice).  CPU is usually one thing you can skimp on a little bit if you have to, so long as you're willing to wait for builds and the like.
The other nice thing about going all virtualized is that you can start with a pair of big servers and grow out as your needs change.  Need to give your dev environment more power?  Get another server and split the VMs up.  Need to simulate a 4-node cluster?  Lower the memory usage of the existing node and spin up 3 copies.
At this point, unless I needed very high-end performance (ie. I need to consider clustering high-end physical servers for performance needs), I'd go with a virtualized environment.  With the extensions on modern CPUs and OS/hypervisor support for them, the hit is not that big if done correct.
Answer: If you can't afford to buy the single machines then you probably are not in a good position to start re-usably with virtualisation.
One way you can do it is take the minimum requirements for all your systems, i.e. TFS, mail, web etc., add them all together and that will give you an idea of half the minimum server you need to host all those systems.  Double it and you be near what will get you buy, if you have spare cash double/triple the RAM.  Most OSes run better with more RAM to particular ceiling.  Think about buying expandable storage of some kind and aim for half populated to start with which will keep the initial cost/GB and make for some expansion at lower cost in the future.
You can also buy servers which take multiple CPUs but only put in the minimum amount of CPUs.  Also go for as many cores on a CPU as you can get for thermal, physical and licensing efficiency.
I appreciate this is a very late reply but as I didn't see many ESX answers here I wanted to post a reply though my post equally relates to Hyper-V etc.


Can I prove convergence of and show the sum $\sum_{n=1}^{\infty} (z-1){z}^{n}$ where $|z|<1$ by assuming $z$ to be a complex number?

Question: While $z$ usually represents a complex number, in this case it isn't given if $z \in \mathbb{C}$, so would it make any difference if $z \in \mathbb{R}$?
Comment: $\mathbb R\subset\mathbb C$.
Comment: In  real case as well as complex case the series converegs iff $|z| <1$ or $z=1$.
Comment: Calculate the telescopic partial sum. Does it converge for $|z|<1$ ?
Answer: Apply the root test: if $a_n = (z-1)$, then $\limsup {|a_n|}^{\frac{1}{n}} = \limsup {|z-1|^{\frac{1}{n}}} = \lim {|z-1|^{\frac{1}{n}}} = 1$. So the radius of convergence of the power series $\sum a_nz^n$ is 1. Hence $\sum(z-1)z^n$ converges for $|z|<1$. Further, this power series converges absolutely in the open disk $B_0(1)$ and uniformly in any compact subset of $B_0(1)$.


Choosing a well filter for household use

Question: I need help with selecting the appropriate equipment to filter well water in the US for rural household use.
Current situation:

Greensand iron and hydrogen sulfide filter that has failed. Installed
about 10 years ago.
Local company that installed it claims they don't support it.
Water discolors everything orange.
There is a slight odor, but I don't know if it's caused by hydrogen
sulfide, iron or something else.
Septic tank withing 100 feet of well.
Cattle are as close as 50 feet of well, but usually are more then 500 feet away.
The adjacent property where the cattle graze (15+ acres) is sprayed
with something that smells like fertilizer.

Requirements:

At a minimum, filter iron and be safe for drinking.

Solution must be modular to allow for other types of filtration to be added inline.

Cost less than $1,500.00.

Cost less than $250 for yearly maintenance.

Should be obvious when system needs maintenance before filtration failure occurs.

Should be DIY installable.

Should be made by a reputable company that provide good US support after purchase.

Filters should be certified by a reputable third party organization.

I also need:

A recommendation for water test kits to determine the type of iron,
iron ppm and general water chemistry to ensure safe drinking water.
Help in determining the well pump flow rate and water pressure.

I've spoken to a few water filtration companies, both local and far. They all require a salesperson to come out, which is not going to happen now. Additionally, getting them to provide the total cost of the system has proven difficult. They only mention needing two maintenance items for $200 a year only to admit after repeated questioning that the system is going to cost between $4,500 - $5,000 installed.
Can anyone help ?
Comment: step one get your water analyzed, once know what the content of your water is you can select your filter and the maintenance required on it. If you are in an area with a lot of wells you should be able to find a local lab to do that for you.
Comment: You cannot test the water for "safe to drink" at home - that requires collecting a sample (following procedures carefully to not contaminate it with anything not from the well) and sending it to a laboratory (virtually all states have an official state lab for this service, which is normally/often the lowest cost option) for bacterial contamination testing. The location of the cows and septic is inappropriate, but not a guarantee of contamination if the well bore is properly sealed. You can pay for additional testing as well, and having tried "home test kits" I recommend paying the lab.
Comment: Get the water tested as the other comment says. In fact some systems can be a simple carbon filter and a UV filter but it all depends on what the initial state of the water is and, of course, the demand rate you have.
Comment: Getting the lab test results for minerals (iron, sulfides, other things you don't know about until you test) is a necessary step towards selecting a treatment option, as how you treat these things depends on what level they are at. *i.e.* low level iron can be solved with a water softener, but higher level iron requires a more dedicated (and expensive) solution.
Comment: When you have test results, you're then into the land of "various competing online water treatment companies" which are generally far more affordable than any "local option with a budget for sales people and installation folks they want to force you to use" and we are not supposed to help you choose one, but several of them are USA based and sell US-branded (some actually made, others probably made elsewhere) products, and do have some level of support (check the reviews, but also realize that when they stop selling something they probably don't support it much after that time.)
Comment: Welcome to [diy.se]. A fair bit of this question falls into the "shopping recommendation" realm which is explicitly off-topic and puts the question at risk for being closed. @Ecnerwal has done a great job of answering the question you should have asked which is "how do I determine what level of water filtration I need?". Once you know that, you are armed to approach the various companies and _tell them_ exactly what _you need_ and won't fall into the trap of getting pushed into buying something you don't want.
Comment: @FreeMan - Since your first post to this question was to threaten to have this question closed, I'll ask the site admin to delete the question and this account. People like you make it impossible on StackExchange for helpful people like Ecnerwal to help others.
Comment: @user119584 sorry you feel that way and took that as a "threat". I was simply trying to point out the rules which indicate that shopping recommendations are off topic. If you don't like the rules, then maybe you should head off to a place where that isn't the rule. BTW- I did _not_ vote to close, nor has anyone else.
Answer: Your cost restriction may not be easily met with my recommendation, but it's close. The DIY portion also requires that one be capable of managing PVC plumbing connections, which isn't particularly difficult.
I have a chlorine injection water treatment system that the local plumbing supply house would have installed for US$3000, but sold me the components for about US$1800.

The above image from Clean Water Store shows the routing of pipes and components necessary to assemble such a system. The diagram is slightly different from my installation, only in that the injection port is between the pressure tank and the settling tank. It's called a contact tank in the image.
The incoming water has chlorine injected from the "Stenner pump" which may be a brand name. Not shown in the image is a flow switch, which engages the pump when water is being used by the house. The injection volume is adjustable. Chlorine and water is in the solution tank.
The combined chlorine and water then "rests" in the contact tank. Some of the iron (most of the iron) will react with the chlorine (rust never sleeps) and settles to the bottom. The remaining iron will still be dissolved in the water.
The chlorine is removed by the carbon filter. One adjusts the chlorine injection so that the water exiting the carbon filter has no chlorine level. Pool test strips are useful for this testing.
Not shown in the diagram but present in my system is the water softener/conditioner, which will additionally remove some iron.
I have a pair of cartridge filters after the softener which are installed as pure white and when replaced every three months are iron-brown.
I can occasionally taste a bit of iron, but rarely is there any hydrogen sulfide smell, unless there's a failure somewhere in the system. It's necessary to check the solution tank periodically and refill it. The injection valve frequently collects iron deposits and has to be replaced. Both expenses fall into your US$250 limitation, although it was necessary to purchase the injection valve "duckbill" online to get a decent price. I believe it was six or seven dollars online compared to nearly thirty at the local supply house. I replace them every four months to avoid the nuisance of waiting for a failure.
Comment: Without knowing your test results, this is a solution that would address both iron and some level of bacterial contamination, though if you have bacterial contamination you have to be very sure that the system never breaks down (or treat the water you actually drink in an additional way to be certain you are not drinking contaminated water.) There are other methods of getting chlorine into the water, such as dropping it from the top of the well (still in a metered manner depending on water use rate) with a "dry pellet chlorinator."


How to transform a String into a list of tuple?

Question: We have a String that if shown with putStr would produce the timetable for buses.
it looks something like this:
    "4 | 12 32 52\n5 | 12 32 52\n"
What I need to work with is to change it into this form:
    [{4, [12 32 52]},{5, [12 32 52]}]
I need int to work with.
Please don't solve it, just give me ideas, or functions that might help.
Also we were told to use groupBy, but for group and groupBy I only get a "not in scope"
Comment: Both `group` and `groupBy` reside in Data.List module which you would need to add to your import list. You can use [Hoogle](http://hoogle.haskell.org/?hoogle=groupBy) to search functions by their name or type signature and identify in which module they are.
You may also find [unlines](https://hackage.haskell.org/package/base-220.127.116.11/docs/Prelude.html#v:lines) useful for splitting the string into individual lines, and the `readMany` function from [this post](http://stackoverflow.com/questions/20176706/reading-ints-in-haskell/20177526#20177526) for extracting Ints from your string.
Comment: In haskell, your list of tuple should be in this form  [(4, [12, 32, 52]), (5, [12, 32, 52])]
Answer: Daniel!
Yeah, you could use groupBy for helping you.
Here's the doc:
hoogle
And here are two nice examples:
example1
example2
So, you gotta decide what's in your function (a -> a -> Bool) for grouping the way you want.
Also, you have to decide if you need just one group criterion or more than one.
We could say, you have this pattern "a | b\na | b\n", and so on, well, you need to decide where "to cut" for grouping but also what happens with "a" and "b".
And that's it.
I hope I could help.


How do I go from a 3-way switch controlling my basement lights to multiple 3-way switches?

Question: Currently my basement has multiple lights that are connected to a 3-way switch that can be operated from upstairs or in the basement.
I'm renovating my basement and will break it up into 3 different sections with an open floor plan.
I'd like to have 3-way switches controlling each section of the basement individually
I'm new to this and no I cannot afford an electrician right now
Any advice will be appreciated
Comment: This question needs clarification.   Do you want more switches controlling the existing lighting? Or do you want to break up the lighting into separately controlled areas.
Comment: Do you ever want to turn the basement lights *on* from upstairs?  Or only *off*?  Is the stairway part of this lighting?
Comment: Can you turn off the breaker for the basement lights, then open up the boxes involved and post photos of their innards please?
Comment: " New to this"   means you should **NOT** be attempting to do this sort of rewiring.  If you can't afford an electrician then either wait, or find a friend with extensive electrical experience to show you what to do.
Comment: @georgeanderson I want to break up the lighting into separately controlled areas
Answer: What you're really looking for is zone control.
You still want the ability to turn all the basement lights on/off from the 3-way switches.  In fact, the ability to do so is a Code requirement, since the stairwell lights must be on a 3-way.  However, you want the ability to extinguish lights in areas you don't need.
So what you can do is add an additional block of switches on the "switched side" of the 3-way circuit.  That is, the side after the 3-way travelers.   In other words, don't overthink it.
The simplest way to do this, by the way, is to install lamps with pull chains.  But we can do it with real switches.
Let's start with a simple view of what a 3-way circuit is.  (And by the way, I strongly recommend you get colored tape and actually mark your wires these colors - because things will get really complicated if you do not!!)

Don't overthink it: don't mess with the yellows here. As things are, the "red" is on or off according to 3-way command. It branches out to your multiple, various lights including the stairwell light.    So we're going to have the "red" serve as the power input to another bank of normal (1-way) switches. They will input red "switched-hot" and output "switched, switched hot" to those lights you want separate control of.
Now, you can control the bunch with the 3-ways, and select which of the bunch turn on at the supplemental switches.
The stairwell light proper, since by law it must be under direct control of the 3-ways, will still get its power off the red, and will not be under a subsidiary switch.
Is this conservation necessary?
The better thing to do might actually be say sayonara to incandescent lights, and convert to LED.  Then you won't need to worry about the electric bill.
Comment: He never said he cared about energy use.   He most likely just wants to be able to control lights in different sections (quite probably with walls in between) separately.
Comment: @CarlWitthoft The whole article wasn't that, it was just a mention at the top Now bottom. But wow, I got a DV for that?? The DVer should maybe then rush over here and DV [this answer](https://diy.stackexchange.com/a/190602/47125), which is *all* alternative.  So no credit for the voice of experience anticipating root causes and XY problems, eh?
Comment: @harper thanks for the help. Very detailed and easy enough for a newbie to understand. I am installing canless LED Recessed lights
Answer: Of course, it's best to just re-wire everything. But, I presume you don't care where the circuit's initially powered and want to come off that basement switch.
Well then, you're in luck. You'll need to branch off of one of the existing and will be remaining 3-ways' Travelers to power the other lights and their switches. The Travelers are always on, the switches are what switches.
This will minimize your fishing and new hole making. You'll have some cutting and pulling of the old wire into the new switch locations (if you're SUPER LUCKY). I don't suspect you are, so expect to be thwarted by staples holding the old wire tight and having to do some new wiring.


Background color to be same as text color

Question: Currently I have the following code.
#Image_ID {
    color: #000066;
    font: normal 10pt Verdana, Helvetica, Arial;
    background: none;
    border: none;
}

This makes my Input Box white and gets rid of the border. But when a value is entered the value is a black color. What I want is so that when text is entered that it is the same color as the background so that it is virtually invisible.
Comment: Have you tried changing...the color attribute?
Comment: Do you have a demo we can look at?
Answer: Automatic background color to be the same as the specified color of the element, without specifying it manually can be done using the currentColor value for the background property.

body {
  color: black;
  background: currentColor;
}

Browsers support is excellent.
Comment: 8 years later and I see this now (:
Answer: This should do the trick.
#Image_ID:focus {
    color: transparent;
}

Comment: @MichaelDowney I'm glad you found a solution!
Comment: Could not get that to work. But it did give me the idea of taking my original code and changing color: #000066 to  color:transparent; which worked!


Java Return int into buffer.getInt

Question: I am using buffer with Comparator of PriorityQueue (to compare elements of streams) by reading next value with buffer.getInt(). Unfortunately, when I am  comparing it next time, I am loosing this value.
So, is it possible to return int back to buffer in java?
I tried smth like putInt but it is different..
Thanks in advance.
I am working on implementation of External Merger Sort
package sort;
import java.util.Comparator;
import inputStream.Mapping.*;

public class extComparator implements Comparator<MapInp>{

    @Override
    public int compare(MapInp o1, MapInp o2) {
        Integer a = o1.readNext();
        Integer b = o2.readNext();
        return a.compareTo(b);
    }
}

Then, I am using it in another file:
heap = new PriorityQueue<MapInp>(numOfFilesNM/d, new extComparator());
heap.add(new MapInp("data/inp.data"));
....
int t = heap.peek().readNext(); //so, here I am comparing values and loosing the value

MapInt readNext:
public int readNext() {
    if(fileLen-pos-lastPos>bufSize) bufCap = bufSize;
    else bufCap = (int) (fileLen-pos-lastPos);
    if(buffer.position()==buffer.capacity()) {
        lastPos+=pos;
        buffer.clear();
    try {
        buffer = inpCh.map(FileChannel.MapMode.READ_ONLY, lastPos,bufCap);
    }
    catch (IOException e) {
    e.printStackTrace();
    }
    pos=0;
    }
    pos+=4;
    return buffer.getInt();
}

unfortunately, I still have not resolved it. Sorry, but may be sharing of whole code will be better: https://www.dropbox.com/s/zqceyg8j6u9kvg7/test.zip?dl=0
Comment: Please show the code. https://stackoverflow.com/help/mcve
Comment: @ThomasEdwin added. The main problem - is how make comparison of two values in the stream. Now I can do it and loose values. I hope that it is possible to turn back the value into the buffer.
Answer: You do not show the definition of MapInp, but obviously it has a method called readNext. The name of that method suggests that it advances some sort of iterator. Iterators move forward.
heap.peek() returns the top item from the PriorityQueue<MapInp> without disturbing the queue. Probably you need to call some other method other than MapInp.readNext() in order to obtain the value of t.
BTW, your comment so, here I am comparing values and loosing the value seems incorrect, because I would be surprised if readNext functions according to the comment.
Comment: MapInp is a custom class for mapping. There is no other functions. Probably, I need to change smth in this class..
Comment: Thank you. Anyway, is it possible to return value to MappedByteBuffer ?
Comment: MappedByteBuffer can be read from and written to. See https://docs.oracle.com/javase/8/docs/api/java/nio/MappedByteBuffer.html
Answer: You are violating every rule of a Comparator, but let's cut it down to size.
A Comparator must have no side-effects.
You have no control whatsoever over how and when the compare() method is called, so having the method read a "next" value from somewhere is entirely wrong!!!
The ordering of a PriorityQueue is established as elements are added. You are not allowed to change the value of an element, in a way that affects the sort order, while it is part of the queue.
You're doing it entirely wrong. If you have N streams of values, that are each individually ordered (as you'd need for a merge sort), then read the first value from each stream and add to queue. Then poll() the head value, get the next value from the stream that provided that value, and put it in the queue.
I will leave the actual coding of that to you, but your first step is to throw away what you're currently doing, as far as you can manage to throw it. It is really that far from what you want to do.
Comment: Thank you. Yes, I am storing these preordered streams in queues and then merging it to one file (according to the external merge algorithm). The problem is loosing of values when I am filling this file - I found that it happens because of this comparison (so, I am reading the next value of two streams and changing its position).

I've tried to use poll() but it kills even more values and I am receiving like all the nulls in the result.
Comment: @Luno What would be the point of that? You have to throw away your code. It's bad. The `Comparator` must not modify the objects being compared, and calling `next()` is a modification. *Re-think* what you're doing.

Java Return int into buffer.getInt


two labels for each row with pickerView

Question: I'm trying to implement the viewForRow delegate so I can have two labels for each row. I currently have it working with just one label per row. Any help is highly appreciated.
func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) -> UIView {
    var returnLabel = view as UIView!

    if view == nil {
        returnLabel = UIView()
    }

    var pickerLabel = view as! UILabel!
    if view == nil {
        pickerLabel = UILabel()
    }

    let titleData = List

    let myTitle = NSAttributedString(string: titleData[row], attributes: [NSFontAttributeName:UIFont(name: "Helvetica Neue", size: 17.0)!,NSForegroundColorAttributeName:UIColor.whiteColor()])
    pickerLabel.attributedText = myTitle
    pickerLabel.textAlignment = .Center

     var pickerLabel2 = view as! UILabel!
     if view == nil {
         pickerLabel2 = UILabel()
     }

     let subtitleData = subtitleList

     let mySubtitleTitle = NSAttributedString(string: subtitleData[row], attributes: [NSFontAttributeName:UIFont(name: "Helvetica Neue", size: 12.0)!,NSForegroundColorAttributeName:UIColor.whiteColor()])
     pickerLabel2.attributedText = mySubtitleTitle
     pickerLabel2.textAlignment = .Left

    returnLabel.addSubview(pickerLabel)
    returnLabel.addSubview(pickerLabel2)

    return returnLabel
}

func pickerView(pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
    return 60
}

Comment: Do you mean you want two columns in your picker view and each column of each row should have its own `UILabel`?
Answer: You did not specify frames for your labels. Refer to full snippet:
class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

    let rowHeight:CGFloat = 60.0
    let List = ["data1_1", "data1_2", "data1_3"]
    let subtitleList = ["data2_1", "data2_2", "data2_3"]

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) -> UIView {

        var returnLabel: UIView!
        var pickerLabel: UILabel!
        var pickerLabel2: UILabel!

        if view == nil {
            returnLabel = UIView(frame: CGRectMake(0, 0, pickerView.frame.size.width, rowHeight))
            pickerLabel = UILabel(frame: CGRectMake(0, 0, returnLabel.frame.size.width, rowHeight / 2))
            pickerLabel2 = UILabel(frame: CGRectMake(0, rowHeight / 2, returnLabel.frame.size.width, rowHeight / 2))
            returnLabel.addSubview(pickerLabel)
            returnLabel.addSubview(pickerLabel2)
        }

        // title

        let titleData = List

        let myTitle = NSAttributedString(string: titleData[row], attributes: [NSFontAttributeName:UIFont(name: "Helvetica Neue", size: 17.0)!,NSForegroundColorAttributeName:UIColor.whiteColor()])
        pickerLabel.attributedText = myTitle
        pickerLabel.textAlignment = .Center

        // subtitle

        let subtitleData = subtitleList

        let mySubtitleTitle = NSAttributedString(string: subtitleData[row], attributes: [NSFontAttributeName:UIFont(name: "Helvetica Neue", size: 12.0)!,NSForegroundColorAttributeName:UIColor.whiteColor()])
        pickerLabel2.attributedText = mySubtitleTitle

        return returnLabel
    }

    func pickerView(pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
        return rowHeight
    }

    func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
        return 1
    }

    func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return List.count
    }

}

two labels for each row with pickerView


Can grails g:formRemote tag update more than one div

Question: Can g:formRemote update more than one div in grails, What would be a viable strategy for updating multiple divs? can anyone explain me this with an example...
Answer: Yes you can control the update of your page. Instead of using the update attribute, use the onSuccess event.
From the docs:

onSuccess (optional) - The JavaScript function to call if successful

Example
View
<g:formRemote name="myForm" onSuccess="updateBook(data)" method="GET"
              action="${createLink(controller: 'book', action: 'show')}"
              url="[controller: 'book', action: 'show']">
    Book Id: <input name="id" type="text" />
</g:formRemote>

Controller
def show() {
  //TODO: validate if exists and etc..
  def book = Book.get(params.id)
  render book as JSON //send JSON to the client, handling in the updateBook function.
}

Flow

User inform id
Ajax request is made
g:formRemote will call the javascript function updateBook
data will have the JSON that you can parse and do whatever you want (update divs)


Cant parse recently formatted ZonedDateTime Java 8

Question: Why this code
<code>DateTimeFormatter SENT_DATE_FORMATTER = DateTimeFormatter.ofPattern("E, d MMM YYYY HH:mm:ss Z", Locale.US);
ZonedDateTime now = ZonedDateTime.now();
String dateStr = now.format(SENT_DATE_FORMATTER);
System.out.println(dateStr);

ZonedDateTime zoned = ZonedDateTime.parse(dateStr, SENT_DATE_FORMATTER);
</code>
Prints the correct date on the sysout line but throws a DateTimeParseException (Unable to obtain ZonedDateTime from TemporalAccessor) on the parse line?
Comment: You might want to mention that parsing using **"week-based-year"** is not working... You might get faster answers that way...
Comment: Try this: http://stackoverflow.com/questions/23596530/unable-to-obtain-zoneddatetime-from-temporalaccessor-using-datetimeformatter-and
Answer: Capitalized Y stands for week-based-year, see javadoc. In order to make the parser working you rather need to change it to year (u) or year-of-era (y). Then the parser can create a date out of calendar year, month (M) and day-of-month (d). Keep in mind that the week-based-year can relate to previous or next calendar year, not the actual one if your month and day-of-month are near the start or end of calendar year. Therefore it is not possible to just equalize the week-based-year to the calendar year! And without a precisely defined calendar year it is not possible to form a date.
Otherwise, if you had the week-of-week-based-year (w) in your pattern, too, then your parser would be able to understand the input because week-based-year (Y), week-of-week-based-year (w) and day-of-week (E) would also make an interpretable combination for a date.
Note however, that all given details in the input matching your pattern must be consistent (for example 2015-08-31 is Monday and not Tuesday) otherwise the parser will complain again (at least in strict mode).
Comment: Many thanks. I spent a lot of time searching for weird solutions that i didn't noticed the capital Y
Comment: @Solci The way to detect this kind of mistake is to test a snippet of working code. Then compare to your own until you see your mistake. Hundreds of such samples posted here on StackOverflow.


Getting the version number after library's name and extension in Bash

Question: How can I get the version number after a .so file using Bash?
I have obtained the library's full path and extracted the name. Like libpcap.so.1.1.1. Now I need to get the version number after so; for example:
libpcap.so.1.1.1 --> 1.1.1
libusb-0.1.so.4.4.4 --> 4.4.4
libpcap.so.1.8.0-PRE-GIT --> 1.8.0

Edit: A sample code using grep can handle the first two examples. But not the third.
grep -Eo '[0-9][^[:alpha:]]+$' <<<'libpcap.so.1.5.3'

Comment: Do you want to scrape a known library's path / filename in order to print the version number or how should the library be identified in first place?
Comment: I have obtained the library full path and extracted the name. Like libpcap.so.1.1.1. Now I need to get the version number after so
Comment: Is the name stored in a file? Are there more than one names? Or is the printed as the result of a command?
Comment: @kos: I guess the question is clear enough and needs no more explanations! I added a sample code.
Answer: I won't guarantee that it will catch every corner case, but how about
grep -Po '\.so\.\K([0-9]+\.)*[0-9]+'

match and discard literal .so. on the left (using the PCRE \K modifier)
match zero or more occurrences of one or more digits followed by .
match one or more digits

Note that we don't want to anchor it to the end of the string ($) as your original expression does, to allow for a trailing string such as -PRE-GIT
Answer: Using awk:
awk -F'.so.' '{match($2,/([0-9]+\.*)+/);print substr($2, RSTART, RLENGTH)}

Examples
$ awk -F'.so.' '{match($2,/([0-9]+\.*)+/);print substr($2, RSTART, RLENGTH)}' <<<'libpcap.so.1.8.0-PRE-GIT1'
1.8.0

$ awk -F'.so.' '{match($2,/([0-9]+\.*)+/);print substr($2, RSTART, RLENGTH)}' <<<$'libpcap.so.1.1.1\nlibusb-0.1.so.4.4.4\nlibpcap.so.1.8.0-PRE-GIT'
1.1.1
4.4.4
1.8.0

Answer: This works for the examples you provided, and will work as long as the input string follows the pattern .*\.so\.[0-9.]*.*:
grep -Po '.*\.so.\K[0-9.]*' <<<'libpcap.so.1.1.1'

It will match the widest possible sequence of digits / dots after the last .so. substring, if any.
% grep -Po '.*\.so.\K[0-9.]*' <<<$'libpcap.so.1.1.1\nlibusb-0.1.so.4.4.4\nlibpcap.so.1.8.0-PRE-GIT'
1.1.1
4.4.4
1.8.0


How to add hyperlink in array (Javascript)

Question: I have a random quote generator script, and I need to add hyperlinks for each quote. The issue - I can't figure out how to accomplish this for the life of me.
I'm a novice in javascript but after searching around, thinking there's an easy solution to my problem, I can't find a workable answer to this.
How do I go about adding a hyperlink in an array? I'd appreciate this. It's probably so simple too.
Here's the page to the random quote generator, and I posted the code below. Thank you. https://www.hscripts.com/scripts/JavaScript/random-quote-generator.php
I posted the code below as well.

            Random Quote Generator

        Click Next to Display Random message

            <input type=button value="Next" border=0 onclick="rotate()">

Answer: You can keep html code in your array e.g.
arr.push('CSS');

But I don't prefer mix html code with js.
Look at my solution on JSFiddle https://jsfiddle.net/xoL2bbtd/
I little modified your array and add function
function add(i) {
 var chi = document.createElement('a');
 chi.textContent = arr[i].text;
 chi.setAttribute('href', arr[i].link);
 var tab1 = document.getElementById("add1");
 if (tab1.hasChildNodes()) {
  tab1.removeChild(tab1.firstChild);
 }
 tab1.appendChild(chi);
}

I create anchor element and set href attribute. In array I keep object which contains text and link property
And one more thing. Create array by using new Array is slower than using []. Check this https://jsperf.com/new-array-vs-literal/15
Comment: Rob, this is perfect! Thank you for such a straightforward answer.
Comment: I forgot to ask - how do I have it so the link opens in a new tab? I know in html it's target="_blank" but after searching 25 minutes, I can't seem to figure out how to implement this in javascript. Sorry - I wished I mentioned that beforehand.
Comment: So I did some testing, and I figured out something that works - to make the links open in a new tab.  I added a new line in the code: chi.setAttribute('target', '_blank');    .... I suppose that correct as it worked.


How to get java to produce decimal points while dividing

Question: I'm making a basic calculator where you can plus, times, divide and minus as i was experimenting to see if it worked i noticed that instead of 5 divided by being equal to 1.25 it only displayed 1.
Here's the code i use to handle the math problems:
if (box.getSelectedItem().equals(divide)){
    JOptionPane.showMessageDialog(null, Integer.parseInt(first.getText()) / Integer.parseInt(second.getText()), "Answer", -1);
    main(args);
}

Is there code that displays the decimal points as well?
Comment: Well if you're gonna use Integer, it'll truncate it down to an integer. Use a ```Double```.
Comment: No, do NOT use a `Double` or `double` to store a value on a calculator.  You'll run into all sorts of floating point issues.  Please learn to use the `BigDecimal` class.  Using `Double` or `double` is simply terrible advice for this kind of thing, although technically it might answer the question.
Answer: Since you are using Integer,it is happening.
Use Double to preserve decimals.
In your case,use
Double.parseDouble(first.getText()) / Double.parseDouble(second.getText())

Comment: Right.  And 1 / 5 + 1 / 10 is WHAT exactly?
Comment: i dont understand what are you asking?
Comment: OK, well go ahead and develop a calculator using `Double` to store the numbers.  Then use your calculator to work out `1 / 5 + 1 / 10`. If you don't get the answer that you expected, then you can rethink whether this is a good idea,
Answer: Integer division will give you Integer. Try using Double or BigDecimal data type.
Answer: You need to do the casting
(double)parseInt(first.getText()) / (double)parseInt(second.getText())

Int/Int will give you an Integer. So you need to cast it to Double to get the result in decimal.
EDIT:
If you dont want to show decimal when the result is a whole number then you need to check it like this:
Double res = (double)parseInt(first.getText()) / (double)parseInt(second.getText())
 Integer x;
 if(res % 1 == 0)
 {
    x =  (int)res
 }

Comment: I tried it and it works but now if i do 6 divided by 6 it displays 1.0 would there be any way to fix that?
Comment: @Dragon4c3:- So what result you want when you divide 6/6?
Comment: It's underlined red throughout (int)res i tried adding a ';' but nothing happened
Comment: @Dragon4c3:- Sorry it was my mistake, updated that. It was because I was casting a double to Int and then storing it into double variable.
Comment: `parseDouble()` is not really "casting", you know. `(double)parseInt()` would be.
Comment: (int)res is underlined in red do i need to extend anything or??
Comment: And also with Intger x; is that meant to be Intger or Integer?
Comment: Anyway would you know how to fix the error or am i doing something wrong?


Pushing forward certain pull back sheaf

Question: To my previous question:
Let $Y_1=Y_2=\mathbb{P}^1$, $Y=Y_1\times Y_2$, $p_i:Y\rightarrow Y_i$, $i=1,2$ be a canonnical projections. How to compute explicitly the sheaf $p_{2*}p_1^*(\mathcal{O}_{Y_1}(1))$?
Answer: Using Proposition 9.3 of Hartshorne,
$$(p_2)_*p_1^*\mathcal{O}_{\mathbb{P}^1}(1)\simeq f^*f_*\mathcal{O}_{\mathbb{P}^1}(1)$$
where $f:\mathbb{P}^1\to\mbox{Spec}(k)$ is the structural morphism. Now
$$f_*\mathcal{O}_{\mathbb{P}^1}(1)\simeq H^0(\mathbb{P}^1,\mathcal{O}_{\mathbb{P}^1}(1))\simeq k^2=\mathcal{O}_{\mbox{Spec}(k)}\oplus\mathcal{O}_{\mbox{Spec}(k)},$$ and
$$f^*f_*\mathcal{O}_{\mathbb{P}^1}(1)\simeq H^0(\mathbb{P}^1,\mathcal{O}_{\mathbb{P}^1}(1))\otimes_k\mathcal{O}_{\mathbb{P}^1}\simeq\mathcal{O}_{\mathbb{P}^1}\oplus\mathcal{O}_{\mathbb{P}^1}$$
Of course this can also be done by writing out the definition of the pullback and pushforward, finding the morphism on every open set, and proving it is an isomorphism on stalks.
Edit: This can be easily generalized: If $\mathcal{L}$ is a line bundle on $X\times X$ for any variety $X$, then $(p_2)_*p_1^*\mathcal{L}\simeq H^0(X,\mathcal{L})\otimes_k\mathcal{O}_X$.
Comment: This shouldn't be true in general. Here we use that the only non empty open set of $\mbox{Spec}(k)$ is $\mbox{Spec}(k)$, and so we get global sections.
Comment: Thank you! And the result is not a linear bundle, right?
Comment: I just edited it to make it more explicit. No, it is not a line bundle.
Comment: Thanx. The last thing I didn't understand precisely is the meaning of $$f^*(H^0(\mathbb{P}^1,\mathcal{O}_{\mathbb{P}^1}(1)))\cong H^0(\mathbb{P}^1,\mathcal{O}_{\mathbb{P}^1}(1))\otimes_k\mathcal{O}_{\mathbb{P}^1}.$$ Is it true in general that for $f:X\rightarrow Y$ and $Y$ affine and for any quasi-coherent sheaf $F$ on $X$ $$f^*f_*F\cong H^0(X, F)^{\tilde{}}\otimes_{\mathcal{O}_Y}\mathcal{O}_X?$$

Pushing forward certain pull back sheaf


Need to fix this prime generating code (SPOJ PRIME1)

Question: I am trying to solve this and i came up with this
#include <stdio.h>
#define primeLimit 100000

int prime (long int Start2,  long int Stop2 )
{
    long int a[primeLimit];
    long int i,j,k,l;
    for (i=Start2;i<=Stop2;i++) {
        a[i] = 1;
    }
    for (i=Start2;i<=Stop2;i++) {
    if (a[i]!= 0 && i!=1) {
        for (j=2; j*j i) {
            printf(" \n %d",i);
            l = i;
            for (k = i*i; k< Stop2;) {
                a[k] = 0;
                k = k+l;
            }
        }
        else {
            a[i] = 0;
        }
    }
}

return 0;
}

int main(void)
{
    long int start,stop,a,look;
    scanf("%ld", &look);
    for (a=1;a<=look;a++) {
        scanf("%ld %ld", &start,&stop);
        prime (start,stop);
    }
    return 0;
}

I am using GNU GCC compiler, CodeBlocks IDE on 32 bit windows 7 PC. The code was fine when i ran it on my compiler. But when submitted it shows runtime error (SIGSEGV) .Can anyone point me out where i am going wrong/how to do it better?
Thank you
Comment: if Stop2 >= primelimit then you overflow on the initialization of a.
Comment: It'd be helpful if you included the runtime error in your question
Comment: `long int a[primeLimit];` is going to be extremely cruel to your stack, and just might cause the program to choke. It would be better to allocate the array dynamically, or put it in the data/bss segment (by either placing it at global scope or by making it `static long int a[...];`).
Comment: Why did you leave out the most important info, the inputs? Note Douglas's comment.
Comment: @JanitoVaqueiroFerreiraFilho What are you talking about? `i` ranges from `Start2` to `Stop2`, as it should.
Comment: @JimBalter (s)he doesn't know the inputs, that's part of the point, the program ought to work correctly (and fast) for all inputs within the specified constraints.
Comment: @DanielFischer If the OP doesn't know what inputs caused the SIGSEGV, then s/he should print the inputs. I understand the point, but I'm afraid mine went sailing overhead. There's a good chance that it crashed when the upper limit was >= 100000. The problem description allows up to 1000000000.
Comment: @JimBalter The program is compiled and run on SPOJ's testing machines, you have no way to get the output of your program, so printing the inputs will only result in "Wrong answer" being reported. However, the given constraints are, iirc, that both limits are `<= 10^9`, and the difference between upper and lower limit is `<= 10^5`. So my money is firmly on Douglas nailing the cause.
Comment: @DanielFischer The OP could have tested their program with a range of inputs and seen which ones cause SIGSEGV. While you've expounding on the obvious and missing the point, I've posted an answer. "So my money is firmly on Douglas nailing the cause" -- which I've noted three times now.
Comment: @JimBalter: sorry, I misread the code =(
Answer: The allowed inputs range from 1 to 1000000000, but your array only has 100000 elements .. the difference between the two inputs. You should be indexing it with i-Start2 or k-Start2, not i or k. And you need a[primeLimit+1], because you need to access  a[Stop2-Start2], i.e., a[100000].
Comment: "You should be indexing it with i-Start2 or k-Start2 ...." I am strugling to visualize this concept. would you please explain with a code snippet. Thank you for your help.
Comment: If you can't "visualize" a relative value, I don't think I can help you. The "code snippet" is your own code; use `i-Start2`, not `i`, as the index of `a`, as I said. And why take more than 3 months to read and respond to the answers to your question? What was the point of even asking if you weren't going to read the responses at the time?
Comment: i finally got it .... when you said indexing i was thinking about the loop not the array index itself.... Thanx a lot for your help.... appreciate it... Again sorry for the late response ... i was away from these kind of online judged programming for months
Comment: I wrote "... your array only has .... You should be indexing it ..."; the pronoun "it" refers to "your array".


Custom validation attribute is not working for button click

Question: I have created a function for doing on validations on textbox entered value based on selection in drop downlist .. ..suppose If the dropdownlist  selected item is amount then the entered value in textbox must be in between  10 t0 20 like this i have got two more validations.. for that purpose, I have got one textbox and one dropdwonlist and one button in my view
when i enter value in textbox as 30 and select the drop downlist item as "Amount" and then click on the submit button, the view is not showing any error message and ( if i left textbox as empty and then press submit button its should show error msg but its not showing)  (I have written Custom functions for validating these ones  on server side)
I have put a breakpoint at a postValues method but its not hitting ...
for that I have done like this (controller part)
  public class CrossFieldsTxtboxesController : Controller
  {
        public ActionResult Index()
        {
            var itemsforDropdown = new List<SelectListItem> {
                new SelectListItem{ Text = "Amount" , Value = "Amount"},
                new SelectListItem{Text= "Pound", Value ="Pound"},
                new SelectListItem {Text ="Percent", Value ="percent"}
            };
            ViewData["Listitems"] = itemsforDropdown;
            return View("DdlCrossFields");
        }
        [HttpPost]
        public ActionResult PostValues(CrossFieldValidation model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            else
            {
                return RedirectToAction("DdlCrossFields");
            }
        }
    }

and this is my view part
@model MvcSampleApplication.Models.CrossFieldValidation
@{
    ViewBag.Title = "DdlCrossFields";
}

DdlCrossFields

@using (Html.BeginForm())
{

      @Html.TextBoxFor(m => m.TxtCrossField)
       @Html.ValidationMessageFor(m=>m.TxtCrossField)

    @Html.DropDownList("Listitems",ViewData["Listitems"] as SelectList)
    <input id="PostValues" type="Submit" value="PostValues" />
}

and this is my model part
public class CrossFieldValidation
{
    public string DDlList1
    { get; set; }

    [Required(ErrorMessage = "Quantity is required")]
    [Display(Name= "Quantity:")]
    [ValueMustbeInRange]
    [NumericAttributes]
    public string TxtCrossField
    { get; set; }
}

would any one have any idea why its not working for button click , any suggestions also would be grateful
many thanks..
Comment: The question is presently tagged with MVC3 and MVC4; which are you actually using?
Comment: I am using visual studio 2012...and mvc 4
Answer: I don't see any place where you specify an action that should handle POST request (PostValues in your case). You can use an overload of Html.BeginForm and specify POST action name explicitly:
Html.BeginForm("PostValues", "CrossFieldsTxtboxes")

If I'm right, your POST requests go to Index action and therefore ModelState.IsValid is not checked there.
You can use client side validation using jQuery Unobtrusive validation plugin. Please check if you have the following keys in your web.config file:
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />

But note that custom validation attributes require additional JavaScript code to work on client.
Comment: Is it after you submitting a form to `PostValues`? You need to initialize `ViewData["ListItems"]` in `PostValues` method as well, just refactor creating list items in a separate method and use it in `Index` and `PostValues`
Comment: I have checked in web config  file every thing is okk
Comment: thanks I am getting this error "There is no ViewData item of type 'IEnumerable' that has the key 'Listitems'."  at this line    @Html.DropDownList("Listitems",ViewData["Listitems"] as SelectList).. would you pls help on this ....
Answer: I dont see where you are actually calling the method when you do the post - do you have a javscript click handler?
You need to have the method and controller you want to go to in your Html.BeginForm() or you can have something like the below in your view:
 @Html.ActionLink("Post Values", "PostValues", "CrossFieldsTxtboxesController", null, new { @class = "postValuesButton", onclick = "return false;" })


Interchange limit-integral & Equivalency of sequence convergence and concrete convergence?

Question: I got stuck in the proof of Cauchy's Integral Formula for higher derivatives in Stein's Complex Analysis, page 48:
Under what Conditions over a function $f$, we can infer that :

$\displaystyle\lim_{h\rightarrow 0}\int_Cf(z,h)dz=\int_C\lim_{h\rightarrow 0}f(z,h)dz$

A Try :
$\displaystyle\left|\int_Cf(z,h)dz-\int_C\lim_{h\rightarrow 0}f(z,h)dz\right|\leq
P_C.\sup_{z\in C}\left|f(z,h)-\lim_{t\rightarrow 0}f(z,t)\right|$.
Now, I think there's a way to control right hand side, when $h$ would be small.
Comment: See the [monotone convergence theorem](http://en.wikipedia.org/wiki/Monotone_convergence_theorem#Lebesgue.27s_monotone_convergence_theorem) and the [dominated convergence theorem](http://en.wikipedia.org/wiki/Dominated_convergence_theorem).
Comment: i dont know measure theory, but can a measure space defined on the complex field which is not an ordered set?
Our professor did this : He argued that for every $\epsilon>0$ there exists $e>0$ such that :
$$\forall h : |h|<e\Rightarrow\sup_{z\in C}|f(z,h)-L|<\epsilon$$
where $C$ is a small circle around $z$.
Then he said this convergence is uniform and hence u can interchange integral and limit !
but what does uniform convergence means here ?
Comment: @GitGud, Now I know measure theory. But, MCT & DCT talk about sequences of functions which is a discrete space of functions. Here we have a concrete limit "$h\rightarrow0$". Is this issue solvable ?
Comment: There's nothing that stops the MCT or DCT from working if you have a parameterized family of functions rather than a sequence of functions.  Those are definitely the results that are relevant to your question.
Comment: @AntonioVargas Could you explain how it's possible to consider parameterized family of functions or make it rigorous ?
Comment: Continuity vs sequential continuity?
Comment: You know, my problem is this : Let $f_h(x)$ for $h\in[0,1]$ be a collection of functions (can think $F(h,x)=f_h(x)$ as a multivariable function) and assume that $$\lim_{n\rightarrow\infty}f_{\frac1n}(x)=g(x)$$
Now, can we infer that $\lim_{h\rightarrow0}f_{h}(x)$ exists and equals $g(x)$ ?
Comment: Equality is easy, but what about existence ?
Answer: If you are unhappy with MCT and DCT, your proof is correct. The control you need is precisely what is called uniform convergence.

With regards to your question in the comments,

Proof of $\lim_{h→ 0} f(h) = L$ iff for every null sequence $a_n$, $\lim_{n→∞} f(a_n) = L$.

Clearly LHS implies RHS. Suppose that it is not true that  $\lim_{h→ 0} f(h) = L$. Then there is some $ε >0$
such that for every $\delta>0$, we can find a point $x<\delta$ such that $|f(x) - L| > ε $. Setting $\delta = 1/n$, we extract a null sequence $0<x_n<1/n$ of such points. Thus $f(x_n) \not→ L$.
This proof can be reused with almost no change for many 'limits', e.g. uniform limits of functions.
Comment: Well done. Thank you. You solved so many problems in my mind in Analysis :))
Comment: Yes, I knew it. But my problem is this : Let $f_h(x)$ for $h\in[0,1]$ and assume that $$\lim_{n\rightarrow\infty}f_{\frac1n}(x)=g(x)$$
Now, can we infer that $\lim_{h\rightarrow0}f_{h}(x)$ exists and equals $g(x)$ ?
Comment: No, but $\lim_{h→ 0 } f_h = g$ iff for every null sequence $a_n$, $\lim_{n→∞} f_{a_n} = g$.
Comment: It's a huge help for me if you give a proof or a hint to prove this assertion.
Or maybe it's better to ask it as a different question in Math.SE ?
Comment: @FardadPouran I have edited my answer :)
Comment: @FardadPouran and I have now edited it to now use standard symbols to avoid confusion. Forgive me :)
Comment: You're welcome :)


examples of not monotonic sequences which diverge to infinity i.e. sn tends to infinity as n tends to infinity

Question: What examples are there of sequences which are not monotonic that diverge to positive infinity ?
Comment: Let $a_n$ be a monotonic sequence that diverges to $\infty$.  Let $b_{2n}=a_n$ and $b_{2n+1}=a_n-1$.  Then the sequence diverges to $\infty$, but the terms are not always increasing $(b_{2n+1}<b_{2n})$.
Comment: @MichaelBurr, those sequences do not diverge to infinity in the common sense of the word.
Comment: @MeesdeVries Apparently, I read series instead of sequence.
Comment: Hi @MichaelBurr - intuitively I understand this simple clear example. My query is, does this meet the standard definition of divergence? I'm no expert, but the definition I understand is that a divergent sequence will eventually grow larger than any value we think of, which your non-monotonic sequence does.
Answer: E.g.
$$
s_n = n + 2(-1)^n.
$$
Answer: $$s_n = \cases{n^2 & if $n$ is even \\ n^3 & if $n$ is odd }$$


echo $variable in another echo

Question: I'm stacked.
Can't get it, how put this variable:
$cat_logo = get_field('game_logo', $tax . '_' . $term_id);

This var contain link, that should be In this code:
<?php echo wpthumb( '$cat_logo', 'width=100&height=100&crop=0' ) ?>

Comment: http://php.net/manual/en/language.types.string.php#language.types.string.syntax.single
Answer: You miss the difference between variable name and variable content. There's no point quoting variable name at all:
<?php echo wpthumb($cat_logo, 'width=100&height=100&crop=0' ) ?>

If you need for any odd reason, you must use double quotes:
<?php echo wpthumb("{$cat_logo}", 'width=100&height=100&crop=0' ) ?>

Docs: https://secure.php.net/manual/en/language.types.string.php
Answer: If the $cat_logo is a string, it will be pushed out as a string.
This will work:
<?php echo wpthumb( $cat_logo, 'width=100&height=100&crop=0' ) ?>
Answer: Dont close your variable into " " or ' ' as it will read the variablename as a string, let it write out itself as a string. Try this:
<?php echo wpthumb( $cat_logo, 'width=100&height=100&crop=0' ) ?>

echo $variable in another echo


regular expressions Sequences

Question: Can any one help with this ? Not sure how to do it
For an alphabet:
$A = \{a, b, c, d\}$
For each of the words $abc$, $cbc$, $ac$, $cca$, and $bbba$, determine whether the word matches each of the following regular expressions:

$(a\lor b\lor c)b^*(a\lor c)$
$c^*ab$
$c(a\lor b\lor c)^*$
Answer: I'll do the first regular expression with each of the five words as an example of what you're to do, and I'll leave the other two regular expressions to you.
When does a word $w$ over the alphabet $A$ match the regular expression $(a\lor b\lor c)b^*(a\lor c)$?

The first letter of $w$ must match the expression $a\lor b\lor c$, which simply means that it must be $a,b$ or $c$; it cannot be $d$. All five of the words $abc,cbc,ac,cca$, and $bbba$ begin with $a,b$, or $c$, so none of them is ruled out at this stage.
The last letter of $w$ must match the expression $a\lor c$, so $w$ must end in $a$ or $c$. All five of the words $abc,cbc,ac,cca$, and $bbba$ end in $a$ or $c$, so none of them is ruled out at this stage.
What's left of $w$ after we remove the first letter (which is matched up with $a\lor b\lor c$ and the last letter (which is matched up with $a\lor c$) must match the middle part of the regular expression, $b^*$. In other words, it must be a string of $0$ or more $b$s. As the table below clearly shows, this is true for each of our five words except $cca$. Thus, we can match each of the words $abc,cbc,ac$, and $bbba$ with this regular expression, but we cannot do so with $cca$.

$$\begin{array}{c|c|c}
w&\text{first letter}&\text{last letter}&\text{remainder}\\ \hline
abc&a&c&b\\
cbc&c&c&b\\
ac&a&c&\\
cca&c&a&\color{red}c\\
bbba&b&a&bb
\end{array}$$
Comment: @Simon: You're welcome. If you get really hung up on any of the others, feel free to leave a question here.

regular expressions Sequences


Summation with .map

Question: I'm studing pure JS, and get blocked in one excercise. I already resolve it with two loops, but I need to solve using .map by now.
The problem:
A function with two parameters, one parameter is a list of numbers and the second is a numeric value. This function, must print in the console the index of the elements of the array that the sum is the second parameter.
My solution using 2 loops:

 function pairsToSum(numList, sum) {
     const result = [];

     for (i = 0; i < numList.length; i++) {
         for (j = i + 1; j < numList.length; j++) {
             if (numList[i] + numList[j] === sum) {
                 result.push([i, j]);
             };
         };
     };
     return result;
 };

 console.log(pairsToSum([1, 1, 0, 1], 2))
// [ [ 0, 1 ], [ 0, 3 ], [ 1, 3 ], [ 0, 1 ] ]

But I don't know how to do it using the .map :/
Comment: Perhaps it's supposed to be solved with a [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map), not `Array.map`?
Comment: Don't think `.map` would work that well here. Your current code is fine and would probably be the least convoluted, IMO.
Comment: `.map` wouldn't work. You should use `.reduce` instead.
Comment: I agree that `map` isn't the solution, but this can be solved in O(n) by grouping by difference rather than a nested loop. see: [Find all pairs of integers within an array which sum to a specified value](https://stackoverflow.com/questions/1494130/find-all-pairs-of-integers-within-an-array-which-sum-to-a-specified-value)
Answer: could this work?
function pairsToSum(numList, sum) {
        const result = [];

        numList.map((el1, i) => {
          numList.map((el2, j) => {
            if (j > i && el1 + el2 === sum) {
              result.push([i, j]);
            }
          });
        });
        return result;
      }

      console.log(pairsToSum([1, 1, 0, 1], 2));

Comment: this would work but it's kinda using map while forEach would have been more appropriate. On top of that the complexity is overall bigger than the for loop solution => n2 vs n(n+1)/2.
Comment: I am pretty sure there was a confusion in the terms. When asking to solve the exercise with a map, the examiner/interviewer likely meant to say with a js Map and not with Array.map
Comment: @user3252327 it is true, but the poster did not mention that, he seems just want to know how to use .map to solve it.
Comment: @waiaan this isn't a correct usage of `.map()` though, so we shouldn't be encouraging it to new developers. For more, see [Misusing `map`](https://thenewtoys.dev/blog/2021/04/17/misusing-map/)
Comment: Hi Guys! Yes, maybe I make some confusion... I understand the .map in the solution posted by @waiaan, but the answer increases the bigO notation, right? The porpouse is to optmize the bigO notation in this exercise.

The examiner said to use map.get(), maybe is in there the confusion.

Summation with .map


Select the onset date of a disease based on the number of visits

Question: I have data on physician visits for an infection. Individuals can have 1+ visits. Clinicians consider an individual is infected if he has more than one visit within a year. Then, the date of the first visit is considered as infection onset.
For example, ids 1, 2, and 3 have the following visits:
Data have;
INPUT row ID date;
CARDS;
1 1 2017-03-22
2 1 2017-04-26
3 1 2018-02-20
4 1 2018-04-07
5 1 2018-04-16
6 2 2014-01-15
7 2 2014-06-23
8 2 2014-07-23
9 2 2015-01-14
10 3 2018-01-22
11 3 2019-05-03
;
run;

Based on the clinical definition of the infection, I want these dates:

row
ID
date

1
1
2017-03-22

4
1
2018-04-07

6
2
2014-01-15

The first date of ID=1 is selected because there is 2+ visits within the a year. All visits after the first visit and within a year from the first visit are skipped (row 2 and 3). The second date is row 4, which is more than one year apart from the first visit and there is another visit within a year after.
For ID=2, we select only the first date and skip all the next visits within a year.
For ID=3, we don't select any date because there is no more than one visit within a year.
Comment: This is very complex in proc SQL and might not be doable.  Use a data step.
Comment: Thank you, and any thought on how to do it using data step?
Answer: Try following approach, you might need to tweak a bit when you work on actual full data.
  Data have;
  INPUT row:4. ID:4. date yymmdd10.;
  year=year(date);
  format date yymmdd10.;
  CARDS;
  1 1 2017-03-22
  2 1 2017-04-26
  3 1 2018-02-20
  4 1 2018-04-07
  5 1 2018-04-16
  6 2 2014-01-15
  7 2 2014-06-23
  8 2 2014-07-23
  9 2 2015-01-14
  10 3 2018-01-22
  11 3 2019-05-03
  ;
  run;

  /*keep the first date per id*/
  data first_visit;
   set have;
    by id;
    if first.id;
  run;

  /*find the year difference for each subsequent date with first date*/
  proc sql;
  create table visits1
  as
  select a.*,
  int(abs(yrdif(b.date,a.date,'ACT/365'))) as date_diff_first
  from have a
  inner join first_visit b
  on a.id=b.id;
  quit;

  /*part1 - find the first symptom onset date where we have multiple visits per year*/
  proc sql;
  create table part1_0
  as
  select distinct a.*
  from visits1 a
  inner join visits1 b
  on a.id=b.id
  and a.dateb.date
  and a.year<>b.year
  and a.date_diff_first=1 and b.date_diff_first=0
  and a.row+1=c.row;
  quit;

  data part2;
   set part2_0;
   by id;
   if first.id;
  run;

  /*combine both*/
  data final;
   set part1 part2;
   keep row id date;
  run;

  proc sort data=final; by row id date; run;


pagination buttons limits in yii2

Question: I need in my gridview pagination there show only 3 elements and then in the button pagination show 3 buttons but the button change dynamically.
example buttons pagination:
[1]-2-3...

click in second element
[2]-3-4...

my code:
public function search($params)
{
    $query = Area::find();

    $dataProvider = new ActiveDataProvider([
        'query' => $query,
        'pagination' => [
            'pageSize' => 3,
        ],
    ]);

Thanks !!
Answer: You can do this in gridview with the pager attribute
     <?= GridView::widget([
    'dataProvider' => $dataProvider,
    'summaryOptions' => ['class' =>'dfenx_pagination_summary',],
    'pager' => ['options' => ['class' => 'pagination pull-right']],
    'filterModel' => $searchModel,
    'pager' => [
        'maxButtonCount'=>3,    // Set maximum number of page buttons that can be displayed
        ],
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
      ..........

this are the option available for pager
    'pager' => [
        'options'=>['class'=>'pagination'],   // set clas name used in ui list of pagination
        'prevPageLabel' => 'Previous',   // Set the label for the "previous" page button
        'nextPageLabel' => 'Next',   // Set the label for the "next" page button
        'firstPageLabel'=>'First',   // Set the label for the "first" page button
        'lastPageLabel'=>'Last',    // Set the label for the "last" page button
        'nextPageCssClass'=>'next',    // Set CSS class for the "next" page button
        'prevPageCssClass'=>'prev',    // Set CSS class for the "previous" page button
        'firstPageCssClass'=>'first',    // Set CSS class for the "first" page button
        'lastPageCssClass'=>'last',    // Set CSS class for the "last" page button
        'maxButtonCount'=>10,    // Set maximum number of page buttons that can be displayed
        ],

pagination buttons limits in yii2


How to sync local and remote repositories

Question: After a merged pull request (PR) on GitHub with 3 commits on the remote repository (origin), I performed a pull to update my local repository (main). Somehow the things went wrong, with the standard CI tests failing locally. I reset the local repository to ignore the 3 commits using
git reset --hard SHA

and regained the local status before the PR. Then, to check the commits individually, I performed the pull explicitly using
 git fetch origin
 git merge SHA-commit1
 git merge SHA-commit2
 git merge SHA-commit3

and arrived to the same (functional) status as on remote, with all CI tests OK.
Just for completeness: I have on the remote side another PR proposal, which is not yet merged (containing some errors).
Although, my local and remote repositories are now practically the same, the command
 git status origin

shows
On branch main
Your branch and 'origin/main' have diverged,
and have 3 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

I wonder if there is an easy way to sync the two repositories (I am afraid the suggested git pull would have the same effect as before). Thanks in advance for any hint.
Answer: The short answer
To discard any local changes and put your sandbox in the same state as origin, run:
git fetch
git reset --hard origin/main

(Assumption: you're working on branch main.)
Further comments
When you're not sure what's going on in your sandbox, you should use a tool to visually look at your commit graph. There are many graphical ones, but here's a simple command line one:
git log --all --oneline --graph --decorate

The key is to make it display the graph, the branch names (local and remote), and all the branches.
This command will show you exactly how the remote and local have diverged. And then, you can decide if you want to keep your local changes and use a merge or rebase, or discard your local changes and use a hard reset.
Another note: I'm really not a fan of git pull. In fact, I never use it. It's the same as git fetch followed by git merge, but blindly does the merge whether it's a good idea or not. I prefer to 1) fetch, 2) run that git log command showing the graph, and then 3) decide if I actually want to merge or rebase or reset or whatnot.


Hide Committed Data

Question: I facing an issues no to show committed data in my table. For example once user upload data from excel it will display under the table below. Once user click save those data will be committed to database and it won't show again. Any suggestion for resolving this issues?(i am using adf Studio Edition Version 126.96.36.199.0) Thank you very much.
Comment: We need more info in order to come up with an answer. For example, you are mentioning uploading data from excel. Such feature doesn't exist in ADF (unless you are using ADF Desktop Integration maybe? ), so how do you do this exactly? We would need more technical context.
Comment: Hi;i use managed Bean to extract the data inside the excel and insert it inside the table. I didn't use any Desktop Integration.
Answer: What's the data-model that populates your table? Once you click the commit button you'll need to remove the rows from that data model. So for example if your data model is based on a query - then you will need to find a SQL that doesn't include the rows that are in the table.
Comment: Hi, at the end i did it by create 1 field call save status and use it as indicate whether my data is uplaoded or not. And in my taskflow i default create insert as default.

Hide Committed Data


Asp.Net MVC C# Additional information: The entity or complex type cannot be constructed in a LINQ to Entities query

Question: I get this error: The entity or complex type 'ebs.Models.ExtraItemVM' cannot be constructed in a LINQ to Entities query. on this line:
 booking.ExtraItemsVM = extralist.ToList();

I've seen other examples of this, where it says you get this error if you try to map to actual database tables.
In my case, I'm trying to map to a ViewModel.
My controller code is below.
Firstly get a list of "extras" from the database:
 // get a list of extras
 var extralist = db.Extras.Where(x => x.hotel_id == AccID)
    .Select(e => new ExtraItemVM
     {
      eID = e.additem_id,
      Description = e.additem_text,
      Price = e.additem_cost,
      Count = 0
     });

Then create a new "booking" view model, and try to attach the list of extras to the Booking.ExtraItemsVM property fails:
 Booking booking = new Booking();
 booking.ExtraItemsVM = extralist.ToList();

ViewModels*
 public class Booking
 {
    public int ID { get; set; }
    public bool HasResults { get; set; }
    public List<ExtraItemVM> ExtraItemsVM { get; set; }
  ...
  ...
 }

public class ExtraItemVM
{
    public int ID { get; set; }
    public long eID { get; set; }
    public string Description { get; set; }
    public decimal Price { get; set; }
    public int Count { get; set; }
}

Database Model
public class Extra
{
    [Key]
    [Display(Name = "ID")]
    public long additem_id { get; set; }
    public long hotel_id { get; set; }
    public string additem_text { get; set; }
    public decimal additem_cost { get; set; }
 }

I don't think I'm mapping to the database table - so can anyone please help show what I've done wrong please?
Thank you,
Mark
Answer: In a case like this we would need more info to really find the root cause. The first two things I would try in order to debug that would be.
1) Verifying that the query (where clause) doesn't cause any problem. For this, you need to force L2E to run the query prior to building your VM
var extralist = db.Extras.Where(x => x.hotel_id == AccID)
                  .AsEnumerable()  //This will force L2E to execute the query
                  .Select(e => new ExtraItemVM
                         {
                              eID = e.additem_id,
                              Description = e.additem_text,
                              Price = e.additem_cost,
                              Count = 0
                         });

2) The second option would be to remove the VM class and to use an anonymous class.
var extralist = db.Extras.Where(x => x.hotel_id == AccID)
                  .Select(e => new ()
                         {
                              eID = e.additem_id,
                              Description = e.additem_text,
                              Price = e.additem_cost,
                              Count = 0
                         })
                  .AsEnumerable();

If the second option works, then your VM isn't legal for L2E. In order to build a class inside of a Select statement, you must use a class with a default constructor (just as in your sample code).
A good question that can explain a lot about this is that one: The entity cannot be constructed in a LINQ to Entities query
Comment: This is a significantly better answer than mine.  I just want to enunciate the importance of understanding lazy loading in this instance.
Answer: I don't have enough information to replicate this problem, but I have a serious feeling that it is the following section of code.
var extralist = db.Extras.Where(x => x.hotel_id == AccID)
   .Select(e => new ExtraItemVM
    {
     eID = e.additem_id,
     Description = e.additem_text,
     Price = e.additem_cost,
     Count = 0
    });

The easiest way to debug this might be to eliminate the Select clause or the Where clause and see if that eliminates your problem.  You could always do this in a couple steps instead of trying to do it in one fell swoop.
Comment: First thing I'd try is to Add `.AsEnumerable()` before the `.Select([...]`
Comment: Hi @AlexandreRondeau - that's exactly it - thank you - if you submit as the answer... cheers, Mark
Comment: Hi @pitaylor - thank you for your suggestion.  It still errored when trying to attach to the booking view model.
Comment: It still errored after eliminating the select clause?  @AlexandreRondeau is correct, I am just suprised that it errored after eliminating the select clause.
Comment: Hi - yes, when I tried to attach it to the viewmodel.
Comment: Adding the `.AsEnumerable()` might fix it, but that isn't the source problem, because your code should be working.


Highcharts: Remove left and right padding in column chart

Question: I have a column chart with adjusted pointPlacements, pointPadding and groupPadding and a datetime x-axis with a max and min value.
The expected behavior would be that the chart is cut on the min and max value of the axis, but Highcharts seems to extend the x-axis to the left an right over those extremes by about half the data-interval each. (See image)
I tried about everything I found in the API Reference but couldn't get rid of that extra space on the sides.
Things I already tried:
* setting xAxis.minPadding / xAxis.maxPadding to 0 with and w/o startOnTick / endOnTick
* setting xAxis.ceiling / x.axis.floor to the max / min value
* setting xAxis.margin to 0
* setting xAxis.softMax and xAxis.softMin instead of xAxis.min and xAxis.max
* usingpointStart / pointInterval instead of x-values within the data
* setting chart.spacing to [0,0,0,0]
Fiddle: https://jsfiddle.net/d4rz572L/
Answer: You need to correctly set min and max properties:
xAxis: [{
    type: "datetime",
    // pointRange = 1530792000000 - 1530770400000
    min: 1530748800000 + (21600000 / 2),
    max: 1530835200000 - (21600000 / 2)
}]

Live demo: https://jsfiddle.net/BlackLabel/8bqt1chn/
API Reference: https://api.highcharts.com/highcharts/series.column.pointRange
Comment: The solution that worked for me was setting the `pointRange` of the column series to 0.
This ensures that highcharts thinks that the columns width is 0 and therefore it doesn't add padding to the sides of the chart.
Comment: So if I want the chart to start on the 5th of July at 0:00 and I have 6 hour intervals, I actually have to set the 5th of July at 3:00 as the starting point? Well that's just straight up not intuitive at all ^^
If it's stupid, but it works it ain't stupid ...I guess :D

Thanks a lot for the help :)
Comment: Just tried to implement your solution. Problem for my use case is that I use the axis `max` and `min` at other points in my code (e.g. `tickPositioner`) as well. So I now would have to take that change of the `max` and `min` value into consideration every time, which is of course possible, but tedious.