x.nextUntil is not a function - not sure why

Question: I am getting the following error each time i click on a tab... the tabs work fine but are some usability issues using them for mobile so hoping this is the cause. If not, need to fix any errors anyway. I am getting:

Uncaught TypeError: x.nextUntil is not a function

Section of code... can provide all if needed... actually will provide all so here it is:
$(document).ready(function() {
var originalTabs = $('.originalTabs').html();

function clearTabs() {
  $('.originalTabs').html(originalTabs);
}

//clearTabs();
//desktopTabs();

function desktopTabs() {
  clearTabs();

  // cretate tabs for desktop
  var headers = $("#tab_description h6");

  $('#tab_description h6').each(function(i) {
    $(this).nextUntil("h6").andSelf().wrapAll('
');
  });

  for (var i = 0; i < headers.length; i++) {
    $('.tabs').append('
' + headers[i].innerHTML + '
');
  }

  $('ul.tabs').each(function() {
    var active, content, links = $(this).find('a');
    var listitem = $(this).find('li');
    active = listitem.first().addClass('active');
    content = $(active.attr('href'));
    $('.tab').hide();
    $(this).find('a').click(function(e) {
      $('.tab').hide();
      $('ul.tabs li').removeClass('active');
      content.hide();
      active = $(this);
      content = $($(this).attr('href'));
      active.parent().addClass('active');
      content.show();
      return false;
    });
  });

  headers.remove(); // remove headers from description
  $('#tab-0').show(); // show the first tab
}

function mobileTabs() {
  clearTabs();

  //alert("loaded mobile");

  var headers = $("#tab_description h6");

  $(headers).each(function(i) {
    $(this).append('');
    //$(this).nextUntil("h6").andSelf().wrapAll('
');
    $(this).on('click', function() {
      tabClick($(this));
    });
  });

  $('#tab_description h6').first().trigger('click').addClass("active");
  $('#tab_description h6').first().nextUntil("h6").show();
}

var tabClick = function(x) {

  //alert("clicked");
  var accordionContent = $('#tab_description p, #tab_description ul, #tab_description table, #tab_description div');

  $('#tab_description h6').removeClass("active");
  if (!$(x).hasClass("active")) {
    $(x).addClass("active");
  }

  // Check if current accordion item is open
  var isOpen = $(x).next().is(":visible");

  // Hide all accordion items
  accordionContent.hide();

  // Open accordion item if previously closed
  if (!isOpen) {
    x.nextUntil('h6').show();
    x.nextUntil(accordionContent).show();
  }

  // Disabled to stop on mobile auto scrolling down to product description when clicking through...
  //$('html, body').animate({
  //    scrollTop: $(x).offset().top - 15
  //}, 2000);

  //return false;
}

//bind to resize
$(window).resize(function() {
  if (isMobileLandscapeOnly.matches || isTabletLandscapeOnly.matches) {
    desktopTabs();
    $('#tab_description h6').on("click, touchstart", tabClick);

  } else if (isMobilePortraitOnly.matches || isTabletPortraitOnly.matches) {
    mobileTabs();
    $('#tab_description h6').on("click, touchstart", tabClick);

  } else if (isDesktop) {
    desktopTabs();
  }
});

//check for the orientation event and bind accordingly
window.addEventListener("orientationchange", function() {
  if (isMobileLandscapeOnly.matches || isTabletLandscapeOnly.matches) {
    desktopTabs();
    $('#tab_description h6').on("click, touchstart", tabClick);

  } else if (isMobilePortraitOnly.matches || isTabletPortraitOnly.matches) {
    mobileTabs();
    $('#tab_description h6').on("click, touchstart", tabClick);

  } else if (isDesktop) {
    desktopTabs();
  }
}, false);

if (isMobileLandscapeOnly.matches || isTabletLandscapeOnly.matches) {
  //alert("Mobile / Tablet (Portrait)");
  desktopTabs();
  $('#tab_description h6').on("click, touchstart", tabClick);

  //console.log(originalTabs);
} else if (isMobilePortraitOnly.matches || isTabletPortraitOnly.matches) {
  //alert("Mobile / Tablet (Portrait)");
  mobileTabs();
  $('#tab_description h6').on("click, touchstart", tabClick);

} else if (isDesktop) {
  //alert("Desktop");
  desktopTabs();
}

});

Part in question (i think)
// Open accordion item if previously closed
if (!isOpen) {
  x.nextUntil('h6').show();
  x.nextUntil(accordionContent).show();
}

Stripped down HTML...

TAB 1

TESTING CONTENT

TAB 2

TESTING CONTENT

TAB 3

TESTING CONTENT

TAB 4

TESTING CONTENT

Any ideas anyone?
Comment: `console.log(x)` to see what it is!
Comment: 2 secs! will add and let you know in a moment
Answer: x.nextUntil('h6').show();
x.nextUntil(accordionContent).show();

should be:
$(x).nextUntil('h6').show();
$(x).nextUntil(accordionContent).show();

Better yet add var $x = $(x); to the top of tabClick and use $x instead of $(x) so you're not constantly getting another jquery instance.
Comment: Silly me, do not know how i did not notice that! apologies for asking the question when should of been obvious to me but many thanks for your point in the right direction!


Light bulb socket cover

Question: Where can I get a light bulb socket cover for my never used outside flood light sockets?  I don't use the light fixture, the flood lamps are too heavy to keep in the sockets as the fixture comes detached from the house.  I'm looking for a simple solution.  I have inside flood lamps but they don't fit properly in the sockets.  Thank you.
Comment: Can you post a photo or two of the light?
Answer: I've never seen a "plug" that completely covers the socket, but you can get a two-prong adapter like this that will fill in the Edison socket and only leave the two prongs opened.
Comment: That would have been my suggestion. You can then stick a childproofing cap in it if the slots bother you.
Comment: @keshlam Good call - I have kids so I should have thought about that combo.
Answer: Leaving the flood light sockets with nothing in them is about as safe as leaving an electric socket without a plug in it*. How many of those do you have around your house?
*Unless I've missed something and an outside flood light is massively different to any other light fitting. I'm assuming it's something like this.
Comment: I disagree that this situation is comparable to an electric outlet in a house for two reasons: 1) outside, rain and debris can get blown into the light socket. Not an issue inside. 2) the openings on an outlet are much, much smaller.
Comment: @HenryJackson - If it's designed as an outside lamp, then it should be waterproof! On my own one the bulb is contained under a waterproof lid. To replace the bulb you take the lid off, change the bulb, put the lid back on. If you did the same, without actually putting a new bulb in, it'd still be waterproof. With respect to the openings - well it all depends on the bulb! Screw bulb, bayonet bulb, GU10 bulb, G9...
Answer: I don't recall a product on the open market made specifically to cover flood light fixtures. If you are concerned about keeping the elements and debris out of the socket orient the fixture to 90 degree's.

Light bulb socket cover


PHP/MySQL: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Question: I have this MySQL table:
mysql> select * from  members;
+-------+-----------+-----------+
| memid | firstname | lastname  |
+-------+-----------+-----------+
|     1 | billal    | begueradj |
|     2 | bill      | gates     |
|     3 | steve     | jobs      |
+-------+-----------+-----------+
3 rows in set (0.00 sec)

I have this code:
<?php
$output = array('error' => false);
$members = array();

try {
    $db = new PDO('mysql:host=localhost;dbname=bill;charset=utf8',
                   'root',
                   ''
    );
} catch(Exception $e) {
    die('Error in connecting to DB:
'.$e->getMessage());
}

$response = $db->query('SELECT * FROM members');
while($row = $response->fetch()){
    echo $row['firstname'].' ';
    echo $row['lastname'].'
';
    array_push($members, $row);
}

$output['members'] = $members;
$response->closeCursor();
$json = json_encode($out);
echo $json; // outputs correctly
header("Content-type: application/json");    // error here
die();
?>

And I am getting this error message when I run the PHP file containing the PHP code above:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of
  the JSON data

Why this happens?
P.S. Of course, when I comment this line: //header("Content-type: application/json"); the error message disappears
EDIT: New code version following the comments below:
<?php
    header("Content-type: application/json");
    $output = array('error' => false);
    $members = array();

    try {
        $db = new PDO('mysql:host=localhost;dbname=bill;charset=utf8',
                       'root',
                       ''
        );
    } catch(Exception $e) {
        die('Error in connecting to DB:
'.$e->getMessage());
    }

    $response = $db->query('SELECT * FROM members');
    while($row = $response->fetch()){
        array_push($members, $row);
    }

    $output['members'] = $members;
    $response->closeCursor();
    $json = json_encode($out);
    //echo $json;

?>

Still getting the same error message
Comment: you tried `ehco` and not `echo` ^
Comment: Do you actually echo out the json?
Comment: So after the `header()` line you've tried `echo $json;` and you get an error?
Comment: Oh ... yes, sorry, ... now it outputs correctly, but the error is still there
Comment: Put the `echo ` after the `header()` line.
Comment: JSON.parse is a Javascript error.
Comment: You need to remove all of the other 'echo' statements.  You should be getting an error, but your probably not showing the errors.
Answer: header() should be placed above all output, so before you echo anything.
Plus, since your not encoding the whole thing to JSON, instead only parts, I'm guessing your missing start and end of the JSON.
Correct JSON outputs:
ex1:
{
  "key1": "value1",
  "key2": "value2",
  "key3": "value3"
}

ex2:
[
  {
    "key1": "value1",
    "key2": "value2",
    "key3": "value3"
  },
  {
    "key1": "value1",
    "key2": "value2",
    "key3": "value3"
  },
  {
    "key1": "value1",
    "key2": "value2",
    "key3": "value3"
  }
]

PHP:
<?php

$output = ["error" => false, "members" => []];

try {
  $db = new PDO("mysql:host=localhost;dbname=bill;charset=utf8", "root", "");
} catch(Exception $e) {
  die("Error in connecting to DB:
{$e->getMessage()}");
}

$response = $db->query("SELECT * FROM members");

while($row = $response->fetch(PDO::FETCH_ASSOC)) {
  array_push($output["members"], $row);
}

$response->closeCursor();

$json = json_encode($output);

header("Content-type: application/json");

echo $json;

Answer: try thisit may help you out
if ($response->num_rows > 0) {
        while($row[] = $response -> fetch_assoc()) {
            $item = $row;
            $json = json_encode($item);
        }
    }

Comment: It is the same error message I posted in my question


pip install vulkan

Question: I tried to install the python wrapper to Vulkan using the command (as is instructed in this website):
pip install vulkan

However, the installation failed. Error given below.
What must I do to achieve a successful  installation?
My system is installed with Ubuntu 16.04 LTS, 4.8.0-44-generic, gcc, gcc-5, libgcc-5-dev:amd64.
$ pip install vulkan
Collecting vulkan
  Using cached vulkan-1.3.0.tar.gz
    Complete output from command python setup.py egg_info:
    c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    Traceback (most recent call last):
      File "/usr/lib/python3.5/distutils/unixccompiler.py", line 118, in _compile
        extra_postargs)
      File "/usr/lib/python3.5/distutils/ccompiler.py", line 909, in spawn
        spawn(cmd, dry_run=self.dry_run)
      File "/usr/lib/python3.5/distutils/spawn.py", line 36, in spawn
        _spawn_posix(cmd, search_path, dry_run=dry_run)
      File "/usr/lib/python3.5/distutils/spawn.py", line 159, in _spawn_posix
        % (cmd, exit_status))
    distutils.errors.DistutilsExecError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 161, in run
        cmd = self.call_command('install_lib', warn_dir=0)
      File "/usr/lib/python3/dist-packages/setuptools/command/bdist_egg.py", line 147, in call_command
        self.run_command(cmdname)
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/install_lib.py", line 23, in run
        self.build()
      File "/usr/lib/python3.5/distutils/command/install_lib.py", line 109, in build
        self.run_command('build_ext')
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 49, in run
        _build_ext.run(self)
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 338, in run
        self.build_extensions()
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 447, in build_extensions
        self._build_extensions_serial()
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 472, in _build_extensions_serial
        self.build_extension(ext)
      File "/usr/lib/python3/dist-packages/setuptools/command/build_ext.py", line 174, in build_extension
        _build_ext.build_extension(self, ext)
      File "/usr/lib/python3.5/distutils/command/build_ext.py", line 532, in build_extension
        depends=ext.depends)
      File "/usr/lib/python3.5/distutils/ccompiler.py", line 574, in compile
        self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
      File "/usr/lib/python3.5/distutils/unixccompiler.py", line 120, in _compile
        raise CompileError(msg)
    distutils.errors.CompileError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 243, in run_setup
        DirectorySandbox(setup_dir).run(runner)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 273, in run
        return func()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 242, in runner
        _execfile(setup_script, ns)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 46, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-yozcy3gj/cffi-1.10.0/setup.py", line 232, in <module>
      File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
        raise SystemExit("error: " + str(msg))
    SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1087, in run_setup
        run_setup(setup_script, args)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 246, in run_setup
        raise
      File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 166, in save_modules
        saved_exc.resume()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 141, in resume
        six.reraise(type, exc, self._tb)
      File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 243, in run_setup
        DirectorySandbox(setup_dir).run(runner)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 273, in run
        return func()
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 242, in runner
        _execfile(setup_script, ns)
      File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 46, in _execfile
        exec(code, globals, locals)
      File "/tmp/easy_install-yozcy3gj/cffi-1.10.0/setup.py", line 232, in <module>
      File "/usr/lib/python3.5/distutils/core.py", line 163, in setup
        raise SystemExit("error: " + str(msg))
    SystemExit: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-n5qfo287/vulkan/setup.py", line 28, in <module>
        cffi_modules=["_cffi_build/vulkan_build.py:ffi"]
      File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 269, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 313, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 826, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1092, in best_match
        return self.obtain(req, installer)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1104, in obtain
        return installer(requirement)
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 380, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 663, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 693, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 873, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1101, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 1089, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-n5qfo287/vulkan/

Updated: pip installation commands
I installed pip and pip3 using these commands:
wget -v https://bootstrap.pypa.io/get-pip.py -O get-pip.py
sudo python get-pip.py
pip install -U pip

I checked my installation using these commands
python3 -c "import pip; print(pip.__version__)"
python2 -c "import pip; print(pip.__version__)"

Comment: `fatal error: Python.h: No such file or directory` - did you install the `python-dev` package?
Comment: @steeldriver Nope. Just installed it. But still got the same error msgs.
Comment: Try a new terminal!
Comment: I just noticed all the messages refer to python3 - is your pip aliased to pip3 or somesuch?
Comment: @George I tried issuing the command in a new terminal and got the same error. Rebooted too and got the same error.
Comment: @steeldriver I have updated my question with the pip installation commands that I had used. This was to get the latest pip version. Thus I think the answer to your question is  yes. Correct me if I am wrong.
Answer: To solve the above error, I first installed these packages
sudo apt-get install python3.5-dev libpython3.5

When I ran pip install vulkan, I got another error:
error: could not create '/usr/local/lib/python3.5/dist-packages/pycparser': Permission denied

The installation failed because it wanted access permission to write to a root level directory. This was not possible with a normal user permission.
I tried sudo pip install vulkan but was told sudo: pip3: command not found
I read other sites the explained it was not a good practice to install pip for sudo as it can break the package installation-management system. However, with the above error message, I thought I did not have a choice if I wanted vulkan installed. I then proceeded to install python3-pip for sudo using this command:
sudo apt-get install python3-pip

The following NEW packages will be installed:
  libpython3-dev python-pip-whl python3-dev python3-pip python3-wheel

I ran sudo pip3 install vulkan and finally got:
  Running setup.py install for pycparser ... done
  Running setup.py install for vulkan ... done
Successfully installed cffi-1.10.0 pycparser-2.17 vulkan-1.3.0

To verify, I ran these commands and got a confirmation:
$ pip list --format=legacy | grep vulkan
vulkan (1.3.0)
$ pip3 list --format=legacy | grep vulkan
vulkan (1.3.0)

Notes:

I found sudo find $HOME -name 'pip' -print to be very useful. It
lists all locations of pip in a user's directory. Basically, the
command pip install -U pip mentioned in my question installed pip in
~/.local/lib/python3.5/site-packages/pip
~/.local/lib/python2.7/site-packages/pip
~/.local/bin/pip

This is where things becomes unclear to me (I would appreciate help to understand). Why did pip install vulkan wrote into /usr/local/lib/python3.5/dist-packages/ instead of ~/.local/lib/python3.5/site-packages/? I had thought that if I (a user) activated pip, the pip installation should have been confined to my home directory and not have to write into a root level directory.

pip install vulkan


How to get value of a particular cell in gridview i and pass it to db as a parameter in c#?

Question: i m using C#, i am having problem in retrieving value of particular cell in gridview. the scenario is, there is a list of jobs shown in my grid. Coloumns are job_id, and job_title. I am populating my grid from database, so the grid shows a list of jobs available. and client can click on job_title, which is a hyperlink (
Answer: you can use DataKeys Property

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.datakeys.aspx
Answer: You can embedd job_id in hyperlink - hyperlink can be part of you database (one extra column) or created when you are populating your grid with data from database.


How to repair a window screen frame?

Question: I need to repair a metal window screen frame - not the screen itself, the frame that holds the screen.
I dropped the frame and it broke apart at one corner.
On closer inspection, I see a 90 degree plastic clip inside the frame that split in two.

I think the best way to repair this is to replace the plastic fastener. I don't think glue would hold up to the stress when I put the screen into the frame.
Can someone tell me where to get the correct plastic clip, or failing that, recommend a glue that would hold it together?
Thanks in advance.
Comment: Search for "screen frame corner keys".    Also any decent local hardware store should have these and/or do the repair for you.  I replace my broken window parts from [this place](https://www.swisco.com/cl/Corner-Keys)
Answer: You need screen corners, but you'll have to figure out which ones you need based on the size of the channel in your frame.  (Obviously there are a variety of different frame extrusions out there from various manufacturers.)
Here's something to get you started:
https://windowscreenpros.com/parts-and-supplies/screen-hardware/plastic-miter-cut-screen-frame-corners/
https://www.amazon.com/Plastic-Miter-Screen-Frame-Corners/dp/B008W9JTLW
Answer: This depends a lot on where you live.  Many times the local hardware stores have the items for these type of repairs where as the bigbox stores do not.
Some hardware stores provide rebuild services for screens. The only other option would be removing the 2 broken pieces and doing a google search for that part.
Also, my area has mobile services that repair or replace screens that are very reasonably priced.  A common name is "Screen Man"  and  "New Screens"
Comment: Thank you for your reply. The problem with a Google search, which is a common problem, is that I don't know what to search for, and when I try I get bizarre results. Or I get results for clips that hold the screen in place, not the ones that hold the frame together. Can someone who is familiar with window installation tell me what this damn clip is called? Thanks.
Comment: @Dan, Try searching google on your phone.  Take a picture of the 2 broken  parts layed together and search the pic.  Sorry I should have been more concise on that. Also see my edit

How to repair a window screen frame?


Cannot read property 'name' of null error

Question: I'm still a baby on web development. I am getting the following error, can
anyone help me?
Schema:
var campgroundSchema = new mongoose.Schema({
   name: String,
   image: String,
   description: String,
   _id: String
});
var Campground = mongoose.model("Campground", campgroundSchema);
app.get("/campgrounds/:id",function(req , res){
Campground.findById(req.params.id, function(err, foundCampgrounds){
                  if(err){
                          console.log(err);
                         }else{
                       res.render("show", {campground: foundCampgrounds});
                     }
                 });
            });

This is the index.ejs template:

        <% campgrounds.forEach(function(campground){ %>

                    <img src="<%= campground.image %>">

 <%= campground.name %>

<a href="/campgrounds/ <%= campground._id %>"
                           class="btn btn-primary">More Info

         <% }) %>

show.ejs:
<%- include('partials/header')%>

this is a show template

<%= campground.name %>

<%- include('partials/footer')%>

TypeError:
 Cannot read property 'name' of null

Comment: Can you add the nodejs-code where you `res.render(..)` the page?
Comment: Not sure if I understand your question?
Comment: You have to check if foundCampgrounds exists.
Mongoose `findById` return `undefined` if it cannot find your record.

You can use:
`if (foundCampgrounds) { ... }`
Answer: On the index.ejs. Use a span to retrieve the _id from the
DB, as follows
         <%= campground._id %>

Why? Because _id is a unique object and is auto-generated. No need to even
include it on the Schema unless you want to create it yourself on which case
you'll then amend the controller with a variable. I struggled with this but now
okay.
Answer: You should check if campground is defined at all - you can either do that in your nodejs-controller or in your template. Here's an example for ejs:
<%- include('partials/header')%>
    <% if (campground) { %>

this is a show template

<%= campground.name %>

    <% } else { %>

No camground data was found

   <% } %>
<%- include('partials/footer')%>

Comment: The error is no longer there. I'm now getting: No campground data was found. The else part of your suggestion. But this cannot be true since I have one campground available on the database. Any further suggestion?
Comment: Are you sure that there's a record with `_id` set to the `id`-param in your url?
Comment: Not sure if I follow you....can you elaborate further?
Comment: Well, your mongodb records have a `_id` field. Since you are using `app.get("/campgrounds/:id")` (`:id` will be set to `req.params.id`) the question is if there is a record with this id? If not, obviously no record will be returned.
Comment: Are you referring to this?
db.campgrounds.find()
{ "_id" : ObjectId("5efed7d4ac396d054f8b8693"), "name" : "Granite Hill", "image" : "https://images.pexels.com/photos/45241/tent-camp-night
-star-45241.jpeg?auto=compress&cs=tinysrgb&h=350", "description" : "This is a huge granite hill, no bathrooms. No water. Beautiful granite
!", "__v" : 0 }
Comment: Yes, in order for your code to work (i.e. `Campground.findById` in particular) your request-url must contain `/campgrounds/5efed7d4ac396d054f8b8693` to get the record you mentioned.
Comment: I included your suggestion but still no improvement.
Comment: I figured it out. Thanks for trying to help.
Comment: Would appreciate if you accepted my answer. Thank you.


If $a+b, ab$ algebraic then $a,b$ are algebraic

Question: Let $L/K$ be a field extension and $a,b\in L $. It can easily be shown that if $a,b$ are algebraic over $K$ then sum and product are, too.
But I read that also the converse is true, say if $a+b$ and $ab$ are algebraic over $K$ then so is $a$ and $b$.
My strategy is to use that, since product and sum are algebraic we have that
$\displaystyle [\mathbb{Q}(ab,a+b):\mathbb{Q}]$ is finite, thus algebraic.
Now by using field operations (denoted $f$, e.g. multiplication, inverse ...) I somehow have to obtain an expression $a=f(a+b,a*b)$ and the same for $b$. Then the conclusion would follow. However, I could not achieve this.
Comment: Note that you don't need $a = f(a+b, ab)$, you only need $g(a) = f(a+b, ab)$ for some non-constant polynomial $g$.
Comment: If the sum and product are algebraic, then so is $(a+b)^2$, then so is $(a+b)^2-4ab=(a-b)^2$, then so is $a-b$, then so is ${a+b\over2}+{a-b\over2}$.
Comment: Because $f(a+b, ab)$ is algebraic, meaning $g(x) - f(a+b, ab)$ is a polynomial with algebraic coefficients, meaning its roots (one of which is $a$) are algebraic. So technically, you can even weaken it to there being a polynomial $h(x, y, z)$ such that $h(a, a+b, ab) = 0$.
Comment: @Arthur Why would that be? If this is true, I would be done immediately, cause obtaining $a$ as a polynomial is not hard.
Answer: Hint : $(X-a)(X-b) =X^2 - (a+b)X + ab$
Comment: @SurajKulkarni : yes,I never divide by $2$ in this proof.
Comment: Is this result true on field of charecteristics 2 also?


How do I safely route the wire for a subpanel in the garage?

Question: I'm planning on installing a 100a subpanel in my garage. It will be fed by ~80ft of #2 copper service wire. I'm routing it through the truss floor joists in the basement and it will exit somewhere as pictured by the yellow wire in my garage. As you can faintly see in the picture the garage wall is proud of the house wall by approx 5/8". I think I will need about 1.25" hole to allow for easy passing of the wire which I believe is acceptable since its a doubled up 2x4".
My question, since the two walls aren't aligned how do I route this wire safely? If I center the hole in the 2x4 then it will come through right in the middle of the drywall on the house side before curving into the floor cavity. Should I cut the drywall back and put a stud to the left extend the drywall from the garage side over the floor cavity? I pulled the tape off the drywall on the house side but haven't gotten around to removing the nails to pull the drywall off.
I haven't purchased anything yet so definitely open to your feedback and suggestions.
If needed, additional information:

Main panel 200a CH/Eaton
Sub panel 100a CHP22B100V29
Sub panel will have 2 EVSE (4-3 nmb), and 3x 120 (12-2 nmb) circuits for garage

Update:
I opened up the sheetrock and this is what I found. I don't think I can angle the hole sufficiently to clear the corner. Theres alot of structure in that corner. You can see from the image below the drywall buts up to the back of that foam insulation. If I come in from an angle I'll break into the outside of the 2x4. How would you guys run this?
Comment: If you haven't paid far too much for copper wires, pay a lot less for aluminum wires. 2 AWG aluminum is good for 90A, 1 AWG if you really want that last 10A on the feeder. You can still use a 100A (or 200A) subpanel, the wire size just limits the size of the breaker you feed it from. The EVSE circuits don't need /3 wire (they are Hot-Hot-Ground.) You need to do a Load Calculation to see if you service can support the additional load without an upgrade.
Comment: Thank you. I have performed a load calculation. I probably should've added that. I haven't purchased anything yet but I prefer to use copper even with the added cost. I figure I'm saving by DIY so I can spend a little more on materials. I'm running 4/3 just to future-proof that circuit, I should've added that note as well.
Answer: When EV novices start down the level 2 home charging path, they tend to fall into a certain series of errors. Let's head you off.
Charging rate, and unexpected headaches.
Cars need more power than level 1 (1.4kW).  They don't need that much, though.
The universal novice misconception is "cars need 50A". Only during travel.  It's wild overkill for daily at-home charging.  I consider 10A per "hour per day you spend driving" is sensible. (when you're commuting, you're not going 70 mph in town.) Technology Connections has an excellent video on this and I've cued it up. Feel free to rewind for more basics.  Really, check this out.
Any 2-car installation should contemplate Power Sharing. This gives you get the best of both worlds: Sensible space in the Load Calculation and bonkers overkill speed-charging when you want it.  How does that work?  The group of "chargers" (EVSEs) is given a current allocation to share.  When one car is actively charging, it gets all of it.  When a second car plugs in, they split the allocation 50/50, etc. etc.
The first car plugs in, it gets the full 40A. The second car plugs in, now they're splitting 20A until one finishes, then the remaining car gets 40.  How? This is not your father's battery charger. EVSE's ("chargers" but not really) send a signal to the EV telling how much power they can draw. The EV obeys that signal.   So it's easy for multiple EVSE's to coordinate - they are simply linked by a cable or even radio.  This must be Safety Rated and approved by UL, and it is.
The NEC Article 220 Load Calculation
A common error is to hear about a Load Calculation and then "freestyle it".  That's incorrect: there are only 3 acceptable ways that will comply with code, avoid a fire, and avoid main breaker trips.

The long form NEC Article 220 method
For dwellings, the alternate method in NEC 220.82, which usually calculates out better.
A worksheet your municipality has developed.

You get to take the most favorable; the municipality can't refuse an Article 220 method.
If you are using Power Sharing, you can simply program the master unit with the "spare room" figure in the Load Calc.
If you are not satisfied with that power level available to you on the Load Calc, that can be beaten using EVSEs with a grid/service limiting feature. These attach sensors to your supply wires, and limit charging if the panel or service would otherwise overload.  Nothing prevents EVSEs from using this method and Power Sharing also, but I couldn't name such a model off the top of my head.
A hardwired EVSE should never, ever be on a GFCI breaker. Why? Because an EVSE is not a charger; it #1 tells the car the safe amps, #2 energizes the connector on the car's request, and #3 is a smart GFCI. A hardwired EVSE is a GFCI receptacle, and you don't need a GFCI breaker on a GFCI receptacle.
Copper wire
Once, playing around on Apple's retail site, I found it was possible to configure an iMac to cost over $20,000, and I thought to myself, "who does that?"
Copper heavy feeder is like that Mac. In the 70s a mistake was made using aluminum AA-1350 "transmission line" wire for small branch circuits, and that's morphed into a general sense that copper is "deluxe", like that Mac. Well it's not.  #1, the lugs you'll be landing on are made of aluminum, so the concept is wasted: you're not avoiding a dissimilar metal splice, you're creating one.  And #2 the "safety" money should be spent on what actually matters.
So yeah, #1 aluminum for honest 100A, or #1/0 aluminum for honest 120A. Both are easier to work than #2 copper (lighter metal, less stiff). The distance isn't far enough for voltage drop to matter, remember it's 240V.
The 100A-bus-rating subpanel is running at "safety red-line" and has too few breaker spaces, so it paints you into a corner - you'll run out of breaker spaces soon and are limited to 20A of solar. With some of that wire budget, get a panel with lots of spaces, at least 125A internal busing (which you would need to exploit the capacity of #2 Cu or #1/0 Al) or even 200A internal busing.
How about AFCIs and GFCIs retrofitted in the main house?  Code requires them on new builds for a reason.  Ground rods tip top?
You're DIYing, so are you using a torque wrench/driver to tighten ALL connections which specify a torque, per 2014 NEC 110.14?  Untorqued copper < torqued aluminum.
Will you be trenching to proper depth? Will the feeder be outdoor rated wire?
How about EMT conduit? Because if "deluxe" is your thing, EMT is the very definition of it.   And 3/4" EMT is very DIYable (and error-forgiving, unlike PVC conduit), and will support any foreseeable charge rate, since the wires are easily pulled out and replaced.  It also carries ground for you.  You have to use copper the last few feet from disconnect/subpanel to EVSE, because EVSE makers don't bother to use Al-rated lugs. (which isn't hard and they should really do it).
In any conduit you get to use far cheaper THHN wires, which has a better thermal rating. 60A needs only #6 Cu THHN ($1.72/ft for both wires) instead of 4/3 Cu NM ($9.73/ft largely because nobody uses it). If you get an F150 Lightning and want honest 100A, you can't do that with Romex at all (SER maybe), but in that same 3/4" conduit you can fit two #3 THHN and a #8 bare ground (the ground just being there to be a 3rd wire, due to a glitch in conduit fill rules).
EVSE selection
Two months ago everything exploded.  The signal protocols on the charging plugs are absolutely first-rate - a fourth generation design from SAE, who is in the business of selling cars, not service upgrades.  However there was squabble over the physical shape of the plug, particularly the DC fast charge pins... and Tesla/NACS had basically lost to the J1772 "Fetch" connector.
And then a week in May.  Ford switched to Tesla/NACS. (whaaa? April fools joke???)  GM switched a week later.  We held our breath for a month while the foreign makers hemmed and hawed, but they all came over. The clincher was Volkswagen, which controls Electrify America.
2025 models will have NACS/Tesla. J1772/"Fetch" is not going to happen.
So... back around to our EVSE selection...  you may be constrained into needing certain models to support grid service limiting or Power Sharing. But if you can live without grid service limiting, The Tesla wall units (fairly cheap at $475) do support Power Sharing and they will have the future connector. Use an adapter for this EV and your next EV won't need it.
Comment: Wow, thank you for the thorough response. I guess I should've included more detail in my original post. I did perform a load calculation with the NEC 220.12 form I found online. It gave me 115amps so I was thinking about putting a 90amp breaker in my main panel to feed the sub. I went with the #2 service wire because I read somewhere that subpanels need to be fed with service wire. I think technically I can use #3 with the 75deg column but I figured it'd be good to setup down to #2 for safety factor. I went 4-3nmb because I don't want EMT on my garage, I wanted everything in the wall cavity.
Comment: I rant out of space - I haven't purchased anything yet and I don't fully understand your comment about needing larger feeders to support the ford lighting? is that the the vehicle to home backup? I guess I never thought about that. What is your comment about 20amp of solar? i dont have solar and I'm not sure how that plays into my planning. I am planning on putting in 2 tesla wall connectors and I was planning to do some sort of load sharing, I don't believe I need 2x48amp. I also know I'd love your feedback on future proofing this.
Comment: @4evercurious The feeder from main to subpanel must be 4-wire SER cable. To feed the EVSE's I would use #6 copper SEU - it's cheaper than 4/3 NM. Power sharing is a good idea. Split 80A with each unit limited to 60A.  (well that's bonkers overkill, but you got it to spare).
Comment: [This is what happens](https://teslamotorsclub.com/tmc/threads/fried-wall-charger-looking-for-opinions.306567/) if you don't use a torque screwdriver.Photo #1 meltdown. Photo #2 admonition to torque to soec.
Answer: For the primary question, just angle the hole so it's centered on both sides.
A 1.25" hole is 35% of a 3.5" stud so it should be acceptable, but nail protection plates on both sides of the stud would be a Really Good Idea anyway. Using a stud shoe for one side (providing nail protection and structural reinforcement) would not cost a lot extra and would add some security.
If the EVSE's are hardwired they only need a plain two-pole breaker and /2 cable if using cable. They don't use neutral. The EVSE provides a smart, self-resetting GFCI. If you use receptacles, all the breakers need to be GFCIs, including the EVSE receptacle breakers, which adds a lot of cost and introduces the case where the GCFI breaker trips and leaves your car not charging all night. Hardwiring is the better way to connect EVSEs.
Comment: Thank you! I will open up the drywall tomorrow and see if I can get an angled hole through. I was not aware of a stud shoe but i will def pick up a double to cover that penetration. I'm planning on hardwiring my EVSE but I'm running 4/3 to future-proof that circuit incase there is a future need for a neutral. I've read about the troubles of running a GFCI with EVSE and am trying to avoid that.


Where can I find "Ascended" items for level 70 legendary crafting?

Question: In Diablo 3 Reaper of Souls I have gotten 2 new recipes for legendary level 70 items:

Reaper's Wraps
Pender's Purchase

I know there are more with the same properties that I describe in this question.
These two require a base item for crafting:

Ascended Bracers
Ascended Gauntlets

How do I obtain these items?
I looked through the crafting recipes I got and the closest I have are these:

Sovereign Ascended Bracers
Sovereign Ascended Gauntlets

But neither of these produced an item that fit those recipes, they created rare items that was named something else entirely. I thought perhaps that any item named "XXX Ascended Gauntlets" would fit the gauntlets, but then I haven't really been able to find or craft an item that is called that so I'm not entirely sure.
Since the crafting recipes for those Sovereign items require Death's Breath which I'd rather not waste, I'm asking here instead of just crafting X items to see if one of them might have the right name/requirements.
So what will fit those recipes? Do I have to start farming level 70 content for white items for this? Will they drop? Is there somewhere/somehow I can up the ante for this?

Edit: Scrolling to the bottom of the two webpages linked above for the Sovereign recipes, I can see that they are listed as materials for those recipes I ask about, yet when I crafted an item from each I got items named something else, and that apparently didn't fulfill the criteria for those recipes. Either I messed up (went blind?) or there could be a bug here?
I'll farm a few more Death's Breath and try again.
Comment: AFAIk these "Sovereign Ascended bracers" produce a rare pair of  Ascended bracers. I don't know if these work or not though.
Comment: I tried both sovereign recipes once and got items named something else in both cases, thus my question, but now that I scroll to the bottom of the linked pages they are listed as materials for those recipes. Hmmm...
Comment: Rares do have a random name. That goes for all rares though.
Comment: I know, but when checking the recipes the item I had created did not fit the recipe. I'll check again to be sure though since all evidence point to it should've worked.
Comment: Based on the reddit link by Hex in his comment on his answer rare and magic items don't work.
Comment: fyi rifts seems to be a good place to find these whites.  I ran through one level yesterday with tons of armor piles that constantly dropped white armor pieces.
Answer: These "Ascended" items are simply level 70 common (white) items. You will have to farm for white drops or find a vendor who sells this particular item.
"Low quality" versions or any Magic/Rare version of the item will not work.
Comment: Superior versions should work according to [this reddit comment](http://www.reddit.com/r/Diablo/comments/21cnqv/white_items_you_may_want_to_hang_onto_for/cgc9enm).
Comment: do you know if superior versions work?
Answer: As of Patch 2.0.5. White items are no longer needed to craft legendary items.

Legendary crafted recipes no longer require specific Common armors or
  weapons and instead now require Common crafting materials
Comment: This patch was released on 5/13/14 (at least on NA servers)
Answer: Ascended Items drop on the Memorials on Graveyard in Act V. (Briarthorn Cemetery)
Answer: This video shows a good place to farm white items
Comment: Please can you summarize the contents of this video in your answer? We try and avoid link-rot as much as possible.
Comment: Summary: Go to Act V: Battlefields of Eternity. Use normal difficulty and equip all your +movement skills. Just run around, looting armor racks/scrap piles, and getting your Ascended items.
Answer: Ascended items drop more commonly from weapon racks, armor racks, and anything else similar to those when you are running around.


Madwifi Driver Installation Error : "Cannot detect kernel version"

Question: I cannot get past this error when trying to run "make" on the driver source.
<code>Makefile.inc:81: *** Cannot detect kernel version - please check compiler and KERNELPATH. Stop.
</code>
Does anyone know the procedure for installing madwifi drivers on Ubuntu 11.10?
Notes:
I have all the necessary packages installed including the linux headers and have also tried specifying the "KERNELPATH" manually.
Answer: Just install module-assistant and choose the madwifi from the module assistant list, this will allow you to download, compile and install the modules.
Comment: madwifi drivers are not in the repository so it doesn't work and yes I enabled the 3rd party sources.
Comment: Ok [here](http://www.punknix.com/?q=node/110) is a link to a tutorial for debian, i guess you should make it work or add debian repository to your sources.lst.
Comment: tried adding those repositories and 10.04 repositories and it doesn't work... would prefer not to install a driver compiled for an older version anyways.
Comment: you can try downloading the latest source from the madwifi site and than try to install it with module assistant.
Comment: not sure how I would instruct module-assistant to use the downloaded source... it says it makes and installs "debianized" source in the man file.
Answer: Used svn for the newest release and received no issues when compiling or installing.
Comment: Google search turned up questions about the same error with no resolution.


Help, 120 vs 220/240

Question: Want to install a ductless a/c in my concrete condo. It is 220 volt only draws max 1300 Watts I have a 15 amp 120 v outdoor outlet available. I know it's not optimal, but is it doable to convert to 15 amp with a 220 breaker
and change outlet and run it off of that as I can't run a 12 wire through concrete walls
Many thx
Comment: How many wires are at the outlet? Some call 240v 220v but the are the same here in the US for residential for almost everything, in a large facility it may be 120/208 the homes have single phase power but the complex can be fed with 3 phase. You may be able to change that 120v outlet to a 220/240 volt outlet but first you would need to make sure this the only outlet on that circuit, also the model of the system would be needed, I have installed systems that were 240 only (2 hots&ground) but others required a neutral and the neutral was part of the control for the inside unit. More info please
Comment: What is the power requirement for the a/c unit? What kind of plug does it have and what kind of receptacle does it require? Can't you get a small mini-split that runs on 120 V?
Comment: Are you sure only 1300 watts? That would be around 6 Amps, which isn't much. That would be < 5,000 BTU - not enough to cool even one big room.
Comment: How was the existing wiring to the receptacle here run?
Answer: Your ductless system will require 220-volts to operate.  Anything else will damage the unit.  The conventional receptacle near by is of no help.  Besides, even is it was a dedicated circuit and could be converted, you still need a 110-volt receptacle near by for service.   You will need to bring a new 12-Gauge 2-wire circuit to the location.  Good luck. You are gonna love the ductless system.
Comment: Not true. If you have 220V device and you plug it into 110V, it most likely just won't work.
BUT! Here's the catch: Most of today's devices have wide range of voltage input, usually 85-265V, because they contain switching power supply.
Comment: an air conditioner is unlikely to have that.

Help, 120 vs 220/240


Cannot connect to secure wireless with Netgear wna3100 USB

Question: I have installed Ubuntu 11.10. I used a wired connection to download and install all of the updates.
When I tried to use a Netgear WNA3100 wireless USB network adapter, it failed.  Much searching and trying things I was finally able to get it working by disabling security on my router.  I have verified this by disabling security and I was able to connect.  When I enabled security (WPA2 PSK), the connection failed.
What is necessary to enable security (WPA2 PSK) and still use the Netgear USB interface?
Here is the output from the commands most requested

lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0846:9020 NetGear, Inc. WNA3100(v1) Wireless-N 300 [Broadcom BCM43231]

lshw -C network

  *-network
       description: Ethernet interface
       product: RTL-8139/8139C/8139C+
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 3
       bus info: pci@0000:02:03.0
       logical name: eth0
       version: 10
       serial: 00:40:ca:44:e6:3e
       size: 10Mbit/s
       capacity: 100Mbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm bus_master cap_list rom ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=8139too driverversion=0.9.28 duplex=half latency=32 link=no maxlatency=64 mingnt=32 multicast=yes port=MII speed=10Mbit/s
       resources: irq:19 ioport:c800(size=256) memory:ee011000-ee0110ff memory:40000000-4000ffff
  *-network
       description: Wireless interface
       physical id: 1
       logical name: wlan0
       serial: e0:91:f5:56:e1:0d
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=ndiswrapper+bcmn43xx32 driverversion=1.56+,08/26/2009, 184.108.40.206 ip=192.168.1.104 link=yes multicast=yes wireless=IEEE 802.11g

iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11g  ESSID:"vincecarolradice"
          Mode:Managed  Frequency:2.422 GHz  Access Point: A0:21:B7:9F:E5:EE
          Bit Rate=121.5 Mb/s   Tx-Power:32 dBm
          RTS thr:2347 B   Fragment thr:2346 B
          Encryption key:off
          Power Management:off
          Link Quality:76/100  Signal level:-47 dBm  Noise level:-96 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

ndiswrapper -l

bcmn43xx32 : driver installed
    device (0846:9020) present

lsmod | grep ndis
ndiswrapper           193669  0

dmesg | grep -e ndis -e wlan

[  907.466392] ndiswrapper version 1.56 loaded (smp=yes, preempt=no)
[  907.838507] ndiswrapper (import:233): unknown symbol: ntoskrnl.exe:'IoUnregisterPlugPlayNotification'
[  907.838955] ndiswrapper: driver bcmwlhigh5 (Netgear,11/05/2009, 188.8.131.52) loaded
[  908.137940] wlan0: ethernet device e0:91:f5:56:e1:0d using NDIS driver: bcmwlhigh5, version: 0x53cb40b, NDIS version: 0x501, vendor: 'NDIS Network Adapter', 0846:9020.F.conf
[  908.141879] wlan0: encryption modes supported: WEP; TKIP with WPA, WPA2, WPA2PSK; AES/CCMP with WPA, WPA2, WPA2PSK
[  908.143048] usbcore: registered new interface driver ndiswrapper
[  908.178826] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[  994.015088] usbcore: deregistering interface driver ndiswrapper
[  994.028892] ndiswrapper: device wlan0 removed
[  994.080558] ndiswrapper version 1.56 loaded (smp=yes, preempt=no)
[  994.374929] ndiswrapper: driver bcmn43xx32 (,08/26/2009, 18.104.22.168) loaded
[  994.404366] ndiswrapper (mp_init:219): couldn't initialize device: C0000001
[  994.404384] ndiswrapper (pnp_start_device:435): Windows driver couldn't initialize the device (C0000001)
[  994.404666] ndiswrapper (mp_halt:262): device e05b6480 is not initialized - not halting
[  994.404671] ndiswrapper: device eth%d removed
[  994.404709] ndiswrapper: probe of 1-5:1.0 failed with error -22
[  994.406318] usbcore: registered new interface driver ndiswrapper
[ 2302.058692] wlan0: ethernet device e0:91:f5:56:e1:0d using NDIS driver: bcmn43xx32, version: 0x50a4f1e, NDIS version: 0x501, vendor: 'NDIS Network Adapter', 0846:9020.F.conf
[ 2302.060882] wlan0: encryption modes supported: WEP; TKIP with WPA, WPA2, WPA2PSK; AES/CCMP with WPA, WPA2, WPA2PSK
[ 2302.113838] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 2354.611318] ndiswrapper (iw_set_auth:1602): invalid cmd 12
[ 2355.268902] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 2365.400023] wlan0: no IPv6 routers present
[ 2779.226096] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 2779.422343] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 2797.574474] ndiswrapper (iw_set_auth:1602): invalid cmd 12
[ 2802.607937] ndiswrapper (iw_set_auth:1602): invalid cmd 12
[ 2803.261315] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 2813.952028] wlan0: no IPv6 routers present
[ 3135.738431] ndiswrapper (iw_set_auth:1602): invalid cmd 12
[ 3139.180963] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3139.816561] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3163.229872] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3163.444542] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3163.758297] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3163.860684] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3205.118732] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3205.139553] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3205.300542] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3353.341402] ndiswrapper (iw_set_auth:1602): invalid cmd 12
[ 3363.266399] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3363.505475] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3363.506619] ndiswrapper (set_iw_auth_mode:601): setting auth mode to 5 failed (00010003)
[ 3363.717203] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3363.779206] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3405.206152] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3405.248624] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3405.577664] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3438.852457] ndiswrapper (iw_set_auth:1602): invalid cmd 12
[ 3438.908573] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3568.282995] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3568.325237] ndiswrapper (set_iw_auth_mode:601): setting auth mode to 5 failed (00010003)
[ 3568.460716] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3568.461763] ndiswrapper (set_iw_auth_mode:601): setting auth mode to 5 failed (00010003)
[ 3568.809776] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3568.880641] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3610.122848] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3610.148328] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3610.324502] ADDRCONF(NETDEV_UP): wlan0: link is not ready
[ 3636.088798] ndiswrapper (iw_set_auth:1602): invalid cmd 12
[ 3636.712186] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[ 3647.600040] wlan0: no IPv6 routers present

I am using the system now with the router security turned off.  When I submit this, I will turn security back on.
Comment: I updated to ndiswrapper v 1.57.  Still not working.  I am trying to install the STA drivers from Broadcom but I can't figure out where to copy the wl.ko file to.  The README is not specific enough.  I have tried to put it in several different places and use modprobe to get it installed (per the instructions) but modprobe says it can't find the module when it is it the dircetory where I issue the command.
Comment: As of time of writing, this problem exists for 12.04.
Answer: I just found out how to connect to mine; however, it may not be a universal solution. Give it a shot and let's see if it works for you. On your router, change the WPA2 setting to TKIP and not AES. As soon as I did that, it instantly connected. So, I hope it helps you!


Cannot connect to the Internet after removing python3 from Xubuntu

Question: I'm using Xubuntu 19.10 and after installing Python 3.8.1 from ppa:deadsnakes/ppa, I decided that the installed by default python 3.7.5 is no longer needed and I did sudo apt remove --purge python3.7 -y. This incredibly bad idea blew off half of my system. I read that installing xubuntu-desktop again can restore the most of the broken things and it really works, but after rebooting I found that I'm no longer able to connect to the Internet. It seems that something more is removed and I missed to install it again. I saved the entire output after running the disastrous command and it is here.

Could this be fixed without reinstalling the entire Xubuntu?
Xubuntu doesn't have repair option, but if I install it on the same partition without formatting, will this preserve all my data, manually installed packages and configurations?
Answer: I know you already answered yourself, but I broke the entire desktop after removing Python3.8 (including internet connection) and fixed it by manually installing every missing dependency that makes up netplan.io from a USB.
These missing dependencies were:

libpython3.8-minimal
libpython3.8
libpython3.8-stdlib
python3-distutils
python3-lib2to3
python3.8-minimal
python3.8
python3-yaml
python3-netifaces
libnetplan0

(you can download them as *.deb from https://pkgs.org/)
After that I finally could install netplan.io to get internet access and then repair everything with:
apt --fix-broken install
apt install ubuntu-desktop
apt update
apt upgrade

Everything started because I tried to upgrade python from 3.8 to 3.10 lol
Answer: I managed to rescue my system by booting in recovery mode available in "Advanced Options for Ubuntu" in the GRUB boot menu. Then I had access at least to WiFi connection and by having working Internet again, I executed sudo apt --fix-broken install.
Answer: The reason why you can't connect to the internet via ethernet after uninstalling python3 is because... it removed netplan.io, yes, that netplan. This is from your output:
Removing netplan.io (0.98-0ubuntu1) ...
dpkg: warning: while removing netplan.io, directory '/etc/netplan' not empty so
not removed

You will have to manually connect to the internet, then all you should have to do is:
sudo apt update
sudo apt install netplan.io
reboot

And you should be good to go, a different package controls wireless connections vs wired from what I understand.
Answer: Many ubuntu tools use python3 for their work, and expect the pre-installed version, and can stop working if it is removed or upgraded. It's best not to touch the original python3 if you rely on Ubuntu tools.
Yes you can install again, using 'something else', selecting your existing partitions but ensure you do not have format checked. That option will

take note of your added software
erase system directories
install new system
add back software you had added
won't touch user files unless you formatted

Note: this assumes you don't format. Also some programs do store config files in system directories thus they will be lost, but that applies generally only to server applications (desktop programs store their files in $HOME or your user directory so won't be touched).
Of course you should backup first, I'd do it from 'live' media just to be safe, but you'll no doubt already have backups in place, but better safe than sorry.
Your alternative is downloading python3-minimal (https://packages.ubuntu.com/eoan/python3-minimal) using wget (from another box & walk across on thumb-drive if necessary) and then install dpkg, and you may be able to resurrect your system without a re-install, but it'll take longer to test for damage than the re-install option (you're likely to have removed other needed components so you'll need to assess your logs & re-install back what is required...)  Once python3-minimal is installed some tools will become available again...
Comment: You didn't answer the main question. Is it possible to enable the internet connection again?
Comment: You'll need to look at logs and see what was removed. By using the '-y' option you gave permission for loads to be removed (you should avoid using '-y' unless you're 110% sure of what will occur). I suspect yes, but without knowing what you actually removed I cannot be sure unless you provide that detail (ie. all packages you okay'ed removal to with the -y command from logs; that can differ depending on what you'd packages you'd installed post-install which I cannot know).  With `python3-minimal` yes it'll fix, unless your command removed other things needed too
Answer: Running Ubuntu 20.04, I accidentally deleted python3 which inevitably corrupted my internet connection (i.e. unable to ping) and failed to load the Ubuntu GUI / login screen.

I followed instructions provided from @YoomarXD and also had to download "netplan.io" deb package as well:
https://pkgs.org/download/netplan.io

To fix python3, restore internet (LAN) and the Ubuntu GUI
Download dependencies
libpython3.8-minimal
libpython3.8
libpython3.8-dev
libpython3.8-stdlib
python3-distutils
python3-lib2to3
python3.8-minimal
python3.8
python3.8-dev
python3-yaml
python3-netifaces
libnetplan0
2to3
netplan.io

Switch to Terminal
'safe mode'
or
press 'control' + 'alt' + 'F5'

Mount USB Stick
Find USB device
sudo fdisk -l
Mount device
sudo mkdir /media/usb
sudo mount [DEVICE] /media/usb

Install dependencies
sudo dpkg -i
sudo dpkg -i libpython3.8-minimal_3.8.2-1ubuntu1_amd64.deb
sudo dpkg -i libpython3.8-stdlib_3.8.2-1ubuntu1_amd64.deb
sudo dpkg -i libpython3.8_3.8.2-1ubuntu1_amd64.deb
sudo dpkg -i libpython3.8-dev_3.8.2-1ubuntu1_amd64.deb
sudo dpkg -i python3.8-minimal_3.8.2-1ubuntu1_amd64.deb
sudo dpkg -i python3.8_3.8.2-1ubuntu1_amd64.deb
sudo dpkg -i python3.8-dev_3.8.2-1ubuntu1_amd64.deb

sudo dpkg -i --force all
Would love to hear others thoughts, but had to force install given 'dpkg' failed to acknowledge python was installed, even after reboot.

sudo dpkg -i --force all python3-lib2to3_3.8.2-1ubuntu1_all.deb
sudo dpkg -i --force all python3-distutils_3.8.2-1ubuntu1_all.deb
sudo dpkg -i --force all python3-netifaces_0.10.4-1ubuntu4_amd64.deb
sudo dpkg -i --force all python3-yaml_5.3.1-1_amd64.deb
sudo dpkg -i --force all 2to3_3.8.2-0ubuntu2_all.deb
sudo dpkg -i --force all libnetplan0_0.99-0ubuntu1_amd64.deb
sudo dpkg -i --force all netplan.io_0.99-0ubuntu1_amd64.deb

Reboot
sudo reboot

Verify Responsive Internet
ping 188.8.131.52

Repair Everything
sudo apt --fix-broken install
sudo apt install ubuntu-desktop
sudo apt update
sudo apt upgrade
Answer: For me, it was the low level "ip" command that allowed me to get back on the network.
"ifup" and "ifdown" were not available, but "ip" was.
So, I manually added the ip address and gateway/route by using the following commands:
(note: server's ip was 192.168.0.123)
# Find out networks cards device name (for me it was enp0s3, could also be eth0 or similar...)
ip link show

# Assign the ip address manually
ip addr add 192.168.0.123/8 dev enp0s3

# Bring up the device
ip link set enp0s3 up

# add the gateway to the internet
ip route add 192.168.0.0/24 dev enp0s3

That way, my network was restarted and I could repair the installation with
sudo apt --fix-broken install


SQLalchemy mutually dependent foreign key constraints

Question: I'm trying to define 2 entities like this:
class User(Base):
    id = Column(Integer, primary_key=True)
    name = Column(String(256), index=True, unique=True)
    main_token_id = Column(ForeignKey('token.id'), nullable=False)

    main_token = relationship('Token', uselist=False)
    tokens = relationship('Token', back_populates="user", foreign_keys=['token.id'])

class Token(Base):
    id = Column(Integer, primary_key=True)
    user_id = Column(ForeignKey('user.id'), nullable=False)

    user: User = relationship("user", back_populates="tokens")

I want the user to have access to the collection of all his tokens and I also want him to have a special, main token. I want to ensure that the user has just one main token and I need integrity provided by the foreign key. By both of them actually.
I have read Cascading deletes in mutually dependent tables in SQLAlchemy but I don't feel it helps. I would like to have the integrity from both sides.
How can I make this work? If the design is flawed how can I rephrase this so that I may keep my integrity guarantees?
Comment: The sqlalchemy examples have foreign key constraints but it seems that main_token could be left null.  Is that the situation you are concerned with?  Ie. If tokens exist then a main token must exist?  Or can tokens exist without a main token?
Comment: I am interested in having the guarantee that once a user exists there exists atleast one token that is supposed to be the main one and I want to have integrity constraints on this relation guaranteeing that when the user is deleted, then the main token (specified by main_token_id) is also deleted. The user may have additional tokens also. I am not bothered if the tokens relation also includes the main token but I also want integrity constraints on this and by that I mean that when the user is deleted, all the user's tokens should also be deleted
Answer: A kludge I have used to sort of solve this problem before is to create a column like precedence = Column(Integer, nullable=False) on tokens.  Then set a unique constraint like UniqueConstraint('user_id', 'precedence'). Then set that integer manually when you create the tokens.  The token with precedence 0 or the lowest precedence is the main token.
Here is an example.  I'm sure some sqlalchemy geniuses can perform the precedence swap without 3 updates but I think in most cases that doesn't come up very often.  There is a way to defer the unique constraint within a transaction but I guess sqlite does not support that yet.
This relies on your application not clearing the main token from precedence 0, ie. no integrity check to prevent that.
from sqlalchemy import (
    create_engine,
    UnicodeText,
    Integer,
    String,
    ForeignKey,
    UniqueConstraint,
    update,
)
from sqlalchemy.schema import (
    Table,
    Column,
    MetaData,
)
from sqlalchemy.sql import select
from sqlalchemy.orm import declarative_base, relationship
from sqlalchemy.orm import Session
from sqlalchemy.exc import IntegrityError

Base = declarative_base()

engine = create_engine("sqlite://", echo=False)

class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    name = Column(String(256), index=True, unique=True)
    tokens = relationship('Token', backref="user", cascade="all, delete-orphan", order_by='Token.precedence')

    main_token = relationship('Token', primaryjoin='and_(User.id == Token.user_id, Token.precedence == 0)', viewonly=True, uselist=False)

class Token(Base):
    __tablename__ = 'tokens'
    id = Column(Integer, primary_key=True)
    precedence = Column(Integer, nullable=False)
    user_id = Column(ForeignKey('users.id'), nullable=False)
    __table_args__ = (UniqueConstraint('precedence', 'user_id', name='tokens_user_precedence'),)

Base.metadata.create_all(engine)

with Session(engine) as session:
    user = User(name='tokenizer')
    session.add(user)
    main_token = Token(user=user, precedence=0)
    session.add(main_token)
    session.add(Token(user=user, precedence=1))
    session.commit()
    assert session.query(Token).first()
    assert session.query(User).first()
    assert session.query(User).first().tokens
    assert session.query(User).first().tokens[0] == main_token
    # This viewonly relationship seems to be working.
    assert session.query(User).first().main_token == main_token

    # We don't want this so don't do this, no integrity checks here!!
    main_token.precedence = 100
    session.commit()
    assert not session.query(User).first().main_token

    # Put it back now.
    main_token.precedence = 0
    session.commit()
    assert session.query(User).first().main_token

    # Now check tokens are cleared.
    session.delete(user)
    session.commit()
    assert not session.query(Token).all()
    assert not session.query(User).all()

with Session(engine) as session:
    # Try making 2 main tokens.
    user = User(name='tokenizer')
    session.add(user)
    main_token = Token(user=user, precedence=0)
    main_token2 = Token(user=user, precedence=0)
    session.add_all([main_token, main_token2])
    try:
        session.commit()
    except IntegrityError as e:
        pass
    else:
        assert False, 'Exception should have occurred.'

with Session(engine) as session:
    # Try swapping the tokens.
    user = User(name='tokenizer')
    session.add(user)
    main_token = Token(user=user, precedence=0)
    session.add(main_token)
    other_token = Token(user=user, precedence=1)
    session.add(other_token)
    session.commit()
    old_precedence = other_token.precedence
    main_token.precedence = -1
    session.flush()
    other_token.precedence = 0
    session.flush()
    main_token.precedence = old_precedence
    session.commit()
    user.tokens[0] == other_token
    user.tokens[1] == main_token
    user.main_token == other_token
    session.commit()


How to detect when project is run by Add-Migration

Question: I have a .net Core 3.1 Web API solution, using EF Core for the database. When I execute Add-Migration to generate database migrations, the tool runs the startup project. I want to skip some code that executes when the startup project starts (it will not impact the migration generation). Is there a way to tell, in the project code, that it has been launched from the EF tool?
Comment: I do it [like this](https://github.com/MintPlayer/MintPlayer/blob/master/MintPlayer.Data/MintPlayerContext.cs#L45). I run the migration commands from the Data project. Note that the order of the constructors matters
Answer: In Entity Framework Core 7, they've added the static flag EF.InDesignTime that you can check to know if you are in design time:
using Microsoft.EntityFrameworkCore;

    public static void Main(string[] args)
    {
        if (EF.DesignTime)
          return;

        // other stuff
    }

Answer: While not completly reliable, a workarround could be to use #if DEBUG directive :
    public static void Main(string[] args)
    {
        #if DEBUG
        // Debug mode: stop here
        return;
        #endif

        // other stuff
    }


What's with the program why is it not printing any result?

Question: struct node{
    int data; struct node *next;
};

void push(struct node* head, struct node* n){
    if(n!= NULL){
        if(head==NULL)
            head = n;
        else {
            n->next = head;
            head = n;
        }
    } else printf("Cannot insert a NULL node");
}

struct node* pop(struct node* head){
    if(head!=NULL){
        struct node *n = head;
        head = head->next;
        return n;
    } else {
        printf("The stack is empty");
        return NULL;
    }
}

int main(){
    int i;
    struct node *head = NULL, *n;
    for(i=15;i>0;i--){
        struct node *temp = malloc(sizeof(struct node));
        temp -> data = i;
        temp->next = NULL;
        push(head,temp);
    }
    n = head;
    while(n!=NULL){
        printf("%d ",n->data);
        n=n->next;
    }
    return 0;
}

Comment: Indent your code. It is painful to read it as such.
Comment: You do know that you have an "Enter" key on your keyboard to add newlines between statements?
Comment: As for your problem, `stdout` is (by default) *line buffered*. That means that all output to `stdout` is only output on newline. If you don't print newlines then nothing will be printed until the program ends and the runtime-system flushes the buffers. You need to add some newlines to your printing as well.
Comment: pointer is lost out of the scope
Comment: -1 for no aparrent attempt to debug.
Answer: You need to pass the address of the pointer head to the function push. I your case the head is not getting modified because you are only passing the value in the head.
  void push(struct node** head, struct node* n){
if(n!= NULL){
    if(*head==NULL)
        *head = n;
    else {
        n->next = *head;
        *head = n;
    }
} else printf("Cannot insert a NULL node");}

int main(){
int i;
struct node *head = NULL, *n;
for(i=15;i>0;i--){
    struct node *temp = (struct node *)malloc(sizeof(struct node));
    temp -> data = i;
    temp->next = NULL;
    push(&head,temp);
}
n = head;
while(n!=NULL){
    printf("%d ",n->data);
    n=n->next;
}
return 0;}

Answer: You are passing the head pointer by value to the function push(head,temp);. The changes  to head done inside push will not be reflected in the main() function.
You should pass address of head to push().
push(&head, temp);
and inside push():
*head = n;
Similar change will be required for pop(). You can verify what I am saying by adding a printf inside the loop in main() as: printf("%p\n", head);. The value of head will remain unchanged.
BTW, it is good practice to add a \n at the end of statement inside printf, it flushes the stdout stream immmediately hence your output is printed immediately on stdout (your computer screen).


textarea inside detailsview asp.net

Question: i'm trying to build a gridview and detail to manage user notes .
everything work fine but I need to add a textbox with multiline inside the detail view :
    <asp:DetailsView ID="DetailsView1" ClientIDMode="Static" runat="server" SkinID="detailview" AllowPaging="True" Width="700px" AutoGenerateRows="False" DataKeyNames="id,Expr1" DataSourceID="SqlDataSource2" HeaderText="الملاحظات" oniteminserted="updategridview" onitemupdated="updategridview">
            <Fields>
                <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True" SortExpression="id" />
                <asp:BoundField DataField="user_id" HeaderText="user_id" SortExpression="user_id" />
                <asp:BoundField DataField="xdate" HeaderText="xdate" SortExpression="xdate" />
                <asp:TemplateField HeaderText="xcontent">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("xcontent") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="update" ClientIDMode="Static" TextMode="MultiLine" Text='<%# Eval("xcontent") %>' Height="100px" runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="insert" ClientIDMode="Static" TextMode="MultiLine" Text="" Height="100px" runat="server"></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="name" HeaderText="name" SortExpression="name"  />
                <asp:CommandField ShowInsertButton="True" />
                <asp:CommandField ShowEditButton="True"/>
            </Fields>
        </asp:DetailsView>

   <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:samy_sarc %>" InsertCommand="INSERT INTO sarcusernote(user_id, xdate, xcontent) VALUES (@user_id, @xdate, @xcontent)" SelectCommand="SELECT sarcusernote.*,(select firstname from sarcuser where id=2) as name, id AS Expr1 FROM sarcusernote WHERE (id = @id)" UpdateCommand="UPDATE sarcusernote SET user_id = @user_id, xdate = @xdate, xcontent = @xcontent WHERE (id = @id)">
        <InsertParameters>
            <asp:Parameter Name="user_id" />
            <asp:Parameter Name="xdate" />
            <asp:ControlParameter ControlID="insert" DefaultValue="%" Name="xcontent" PropertyName="Text" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1"  DefaultValue="0" Name="id" PropertyName="SelectedValue" />
        </SelectParameters>
        <UpdateParameters>

            <asp:Parameter Name="user_id" />
            <asp:Parameter Name="xdate" />
            <asp:ControlParameter ControlID="update" Name="xcontent" PropertyName="Text" Type="String" DefaultValue="%" />
            <asp:Parameter Name="id" />
        </UpdateParameters>
    </asp:SqlDataSource>

there is no error in the query ... because it's work fine.
the problem is when I update or insert some value have these error :
Exception Details: System.InvalidOperationException: Could not find control 'update' in ControlParameter 'xcontent'.
Plz Help
Answer: The problem is that your ControlParameter can't find the control that's nested inside a DetailsView (because it is in a different ContentTemplate).  There are usually two ways to solve this issue.
Approach #1: Use the "$" symbol to access the nested control.
You can update your markup to something like this:
<asp:ControlParameter ControlID="DetailsView1$update" Name="xcontent"
    PropertyName="Text" Type="String" DefaultValue="%" />

Using {outerControlID}${innerControlID} will allow your ControlParameter to find the nested control.
Approach #2: Add the parameter in code-behind.
You can programmaticaly add the control to the UpdateParameters collection in your codebehind.  This is a bit more of a hack, but I can throw out an example if you need one.
Comment: Thanks for the details and the solution
the first approach works with me .

textarea inside detailsview asp.net


Can Jordan Curve Theorem be applied on Riemann Sphere?

Question: For this question I will consider $\mathbb{R}^2 = \mathbb{C}$ only to use the Riemann Sphere.
The Jordan Curve Theorem says a jordan curve divides divides the space into a interior region, bounded by the curve and the exterior, unbounded.
The term bounded means the set is limited (exists a circle which contains all the bounded set).
Clearly a circle (a jordan curve) $x^2+y^2=1$ divides the plane into two regions $S_1$ and $S_2$, and so does the line $y - x= 0$, but both regions are unbounded.
Although the idea of "line divides a plane in two" seems intuitive, I cannot say for sure any curve that goes to infinite in both ways divides a plane in two regions (clearly unbounded).
So, interested of finding a condition to decide if a "infinite" curve divides the plane in two:
Question: If I pick a curve and project it in Riemann Sphere, and the resultant curve is a jordan curve, does it means the original curve divides a plane in two? Is the versa true? Are there counter-examples?
For example, the hyperbola $y^2-x^2=1$ is mapped into Riemann Sphere like an $8$-ish shape with the intersection at $\infty$ and therefore this hyperbola divides the plane in three, not in two. A parabola would divide the plane into two regions.
Comment: See https://math.stackexchange.com/q/4712221.
Answer: The Jordan curve theorem for the plane implies a version of the theorem for the 2-sphere: if $\gamma : S^1 \mapsto S^2$ is continuous and injective with image $\cal I$, then $S^2 \setminus {\cal I}$ is homeomorphic to two open discs. To prove this pick $x \in S^2 \setminus {\cal I}$, take it as the point at infinity and use the resulting stereographic projection to translate the problem into a problem about a continuous injection $S^1 \to \Bbb{R}^2$. Then apply the Jordan curve theorem for the plane and pull your conclusions back along the stereographic projection.
Minor issue: how do we know $S^2 \setminus {\cal I}$ is non-empty? Answer: because $S^1$ and $S^2$ are compact, $\gamma$ maps closed sets to closed sets and hence, if it were surjective, it would be a homeomorphism; but $S^2$ and $S^1$ are not homeomorphic, because removal of two distinct points disconnects $S^1$ but not $S^2$.
Comment: Thank you for the answer, but my problem is basically when the curve $\gamma$ pass throught the $\infty$ point in Riemann Sphere. The transformation $S^1 \to \mathbb{R}^2$ not necessarily is a continuous injection. As example, take $\gamma(t): \left[-\frac{\pi}{2}, \ \frac{3\pi}{2}\right] \to \left(\cos t, \ 0, \ \sin t\right)$ in the sphere. The projection of every point of $\cal I$ in $\mathbb{R}^2$ is the line $y = 0$, but it's discontinuous when $t = \pi/2$
Comment: But you can just rotate the sphere so the curve misses the point at infinity.


How to handle errors inside getServerSideProps in Next.js using next-connect

Question: I'm using Next.js and next-connect to handle middlewares.
But I'm having problems trying to handle errors when I use several middlewares inside getServerSideProps.
This is the code I have inside getServerSideProps, I just created a handler using several middlewares so then all of them run, the authentication is successful and the user data should be passed to the response, but if any fails, the error should be catched and return a redirect to '/login' page.
import nextConnect from 'next-connect';
import { openDBConnection, retrieveUserInfo } from '@/middlewares/database';
import { verifySessionCookie } from '@/middlewares/firebaseSession';
...
    export const getServerSideProps = async ({ req, res }) => {
        const handler = nextConnect()
            .use(verifySessionCookie)
            .use(openDBConnection)
            .use(retrieveUserInfo);
        try {
            await handler.run(req, res);
            return {
                props: {
                    user: req.user,
                },
            };
        } catch (e) {
            console.log(e);
            return {
                redirect: {
                    destination: '/login',
                    permanent: false,
                }
            };
        }
    }

I didn't define any try/catch block in any of the middlewares, so if an error happens it can be handled in any api page or getServerSideProps block.
Every seemed to be ok when there was only one middeware verifySessionCookie the error is returned when await handler.run(req, res) is called and then handled in the catch block.
But when using the 3 middlewares as it's shown in the piece of code, if the first middleware fails (verifySessionCookie) the error is not handled in the catch block.
I've tried to make the next() call in every middleware, using a finally clause), in this way the error is catched inside getServerSideProps but:

verifySessionCookie executes, it fails.
openDBConnection executes, it doesn't fail.
retrieveUserInfo executes, it fails.

Maybe I'm doing something wrong here, or maybe next-connect is not intended to be used this way. I don't know how can I handle the error in case that one middleware, and all the rest is not executed. Perhaps I should be calling independent async functions with (req, res) parameters inside the getServerSideProps and stop using this next-connect plugin.
Answer: the documentation on next-connect says you can add onError on your nextConnect
function onError(err, req, res, next) {
  logger.log(err);

  res.status(500).end(err.toString());
  // OR: you may want to continue
  next();
}

const handler = nextConnect({ onError });

Or in your middleware, you can pass some value with req to make it more customizable.
And In the middleware, you can add a try/catch block to pass different values with req
Something like:
export const middlewareExample = (req, res, next) => {
  try {
    // ...
    req.condition = {
      status: 'succuss, ...',
      message: '...',
      data: {
        // ...
      }
    }
    next();
  } catch(error) {
    res.status(...).end(...);
    // OR: you may want to continue
    req.condition = {
      status: 'error, ...',
      message: '...',
      data: {
        // ...
      }
    }
    next();
  }
}

export const getServerSideProps = async ({ req, res }) => {
  const handler = nextConnect()
  .use(verifySessionCookie)
  .use(openDBConnection)
  .use(retrieveUserInfo);

  await handler.run(req, res);

  if (req.condation.status === 'succuss') {
    return {
      props: {
        user: req.user,
      },
    };
  } else {
    console.log(req.condation.message);
    return {
      redirect: {
        destination: '/login',
        permanent: false,
      }
    };
  }
})

I hope this helps.


create lists that contain the rownumbers for which column i contains the maximum value of that row

Question: In a dataframe of 4 columns, I'm looking for an elegant way to get 3 lists that contain the names from column 1 if the maximum of that row in which that name is, is respectively in column 2, 3 or 4.
the first column contains parameter names,
column 2 a shapiro test outcome on the raw data of parameter x
column 3, shapiro test outcome of log10 transformed data for parameter x
column 4, shapiro test outcome of a custom transformation given by the user for parameter x
if this is the data:
          Parameter       xval xlog10val xcustomval
1       FWS.Range 0.62233371 0.9741614  0.9619065
2    FL.Red.Range 0.48195980 0.9855781  0.9643206
3 FL.Orange.Range 0.43338087 0.9727243  0.8239867
4 FL.Yellow.Range 0.53554943 0.9022795  0.9223407
5 FL.Red.Gradient 0.35194524 0.9905047  0.5718224
6       SWS.Range 0.46932823 0.9487955  0.9825318
7      SWS.Length 0.02927791 0.4565962  0.7309313
8 FWS.Fill.factor 0.93764311 0.8039806  0.0000000
9    FL.Red.Total 0.22437754 0.9655873  0.9923307

QUESTION: how to get a list that tells me all parameter names where xlog10val is the highest of the three columns (xval, xlog10val, xcuxtomval)
detailed explanation, ignore perhaps. ....
list 1, the rows where xval is the highest value, should be looking like this: 'FWS.Fill.factor' since that is the only row where xval has the highest score
list 2 is the list of all rows where xlog10val is the maximum value, and thus should contain the names of parameters where xlog10val is the maximum of that row:
'FWS.Range', 'FL.Red.Range', 'FL.Orange.Range',
'FL.Red.Gradient', 'FWS.Fill.factor'

and list 3 the rest of the names
I tried something like
df$Parameter[which(df$xval == max(df[ ,2:4]))]

but this gives integer(0) results.
EDIT
to clarify:
Lets start with looking at column 2 (xval).
PER row I need to test whether xval is the maximum of the 3 columns; xval, xlog10val, xcustomval
if this is the case, add the parameter in THAT row to the list of xval_is_the_max_of_3_columns list
Then we do the same PER row for xlog10val. IF xlog10val in row i is max of columns 2:4, add the name of that ROW to xlog10val_is_the_max_of_3_columns list.
To make the DF:
df <- data.frame(Parameter = c('FWS.Range', 'FL.Red.Range', 'FL.Orange.Range', 'FL.Yellow.Range', 'FL.Red.Gradient','SWS.Range','SWS.Length','FWS.Fill.factor','FL.Red.Total'),
        xval = c(0.622333705577588,0.481959800402278,0.433380866119736,0.535549430820635,0.351945244290616,0.469328232931424,0.0292779051823701,0.93764311477813,0.224377540663707),
        xlog10val =  c( 0.974161367853916,0.985578135386898,0.97272429360688,0.902279501804112,0.990504657326703,0.94879549470406,0.45659620937997,0.803980592920426,0.965587334461157),
        xcustomval = c(0.961906534164457,0.964320569400919,0.823986745004031,0.922340716468745,0.571822393107348,0.982531798077881,0.73093132928955,0,0.992330722386105))

Comment: `as.character(df[df$xval == max(df$xval), 'Parameter'])` should address your needs (although technically this line will return a charcater vector, not a list). That said, could you possibly elaborate on the reason why the length of lists 2 and 3 is greater than 1? Are you looking for top n values (cause max implies one value)?
Answer: We can use max.col to get the index of the maximum value per each row and with that we subset the 'Parameter'
i1 <- max.col(df[-1], 'first')
split(df$Parameter, i1)

EDIT: Based on the discussion with @Mark
Comment: hm no, this just gives me one list, and not the correct one:  FL.Red.Range    FL.Red.Range    FL.Red.Range    FL.Orange.Range FL.Red.Range    FL.Orange.Range FL.Orange.Range FWS.Range       FL.Orange.Range Not even sure why some names appear more than ones.
I need 3 seperate lists.
Comment: @Mark In your code, it is comparing the `df$xval == max(df[ ,2:4])`
Comment: @Mark  Do you need `sapply(df[-1], function(x) df$Parameter[which.max(x)])`
Comment: max.col(df[-1])   assigns correct 1,2,3 to the rows, but from there I need to get to a list of all parameter names that belong to 1, another list that belong to 2, and a final that belong to 3. Your original answer just gives messy list
Comment: df$Parameter[which(max.col(df[-1], 'first') == 1)]
df$Parameter[which(max.col(df[-1], 'first') == 2)]
df$Parameter[which(max.col(df[-1], 'first') == 3)] gives what I need
Comment: @Mark Not sure what you are after `i1 <- max.col(df[-1], 'first'); split(df$Parameter[i1], i1)`
Comment: the split goes wrong I think, it gives repeated names rather than the unique names   FL.Orange.Range FL.Orange.Range FL.Orange.Range FL.Orange.Range
Comment: @Mark  If you need `unique` names, just do `lapply(split(df$Parameter[i1], i1), unique)`
Comment: Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/183908/discussion-between-mark-and-akrun).
Comment: could also do `i1 <- names(df[-1])[max.col(df[-1], 'first')]` if you want the list to be named with the cols.
Comment: @Chris  Yes, it will give the corresponding column names, and you can split by that
Answer: I'm not sure exactly how you're selecting the parameters for list two and three, however, you can try something like this as well
df$Parameter <- as.character(df$Parameter)

par.xval.max <- df[which.max(df$xval), "Parameter"]
par.col3.gt.max <- df[df$xlog10val > max(df$xval), "Parameter"]
par.rem <- df$Parameter[! df$Parameter %in% c(par.xval.max, par.col3.gt.max)]

In this case, the values from column three are greater than the max(df$xval), and the remaining parameters are taken by negative selection using %in%
Comment: I'm not looking for the maximum of the xval column. I need to know by row, whether parameter x has the highest normality score (the numbers ) in xval, or in xlog10val or in xcustomval. So if in row n, the max score of the three columns is in column xlog10val, then parameter name in row n goes into the list that will contain all parameter names where that is the case. If in row n, the maximum of the 3 columns is in xval, that parameter name goes in the list of par names where this is the case. If the maximum of the 3 columns for row n is in xcustomval, then the name goes in the 3rd list


XCode 6.3 cannot show navigation bar

Question: I am not doing something complicated here. I have a UITableView created using storyboards. Just shows some data and has a navigation bar in order to place a title and an action button. However the bar is not showing when I am running my app. Xcode is 6.3. Any clue? Usually this works without adding a line of code.
I did a fresh build, however the problem is still there.
The view is loaded like this
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"RecentCalls" bundle:nil];
MyController *r = [sb instantiateViewControllerWithIdentifier:@"RecentCallsBoard"];
[viewControllers addObject:r]

Comment: Use the Debug->View Debugging menu to take a snapshot of the UI and look at which views are on screen, their positions, and whether there are occlusions.
Comment: I did it, but I cannot see the navigation bar
Answer: Did you make sure that the checkbox at "Shows Navigation Bar" in your Attributes Inspector is ticked?

Edit
I see that you're using this line:
[viewControllers addObject:r]

Why are you doing this? Your UINavigationController should be configured as "Initial View Controller". You've already setup the segue to your UITableViewController, so that should work.
Edit 2
I think this causes the problem:
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"RecentCalls" bundle:nil];

You shouldn't instantiate your "RecentCalls" view controller, but your Root Navigation Controller instead. Otherwise it navigates directly to your UITableViewController, what causes the absence of the UINavigationBar.
Comment: Yes, this options is enabled.
Comment: The storyboard is loaded from a tab bar. Every tab item has a storyboard, therefore I need to add this to the viewControllers object.
Comment: thanks very much. I have already placed the name storyboardid before embeding the tableview to the navigation controller.

XCode 6.3 cannot show navigation bar