Will a horizontal 2x4 support my body weight?

Question: I want to use a framed doorway to do chinups but I'd hate to come crashing down to the floor on my tail bone. This doorway is framed but not drywalled.
I realize there are a lot of factors but not sure how to calculate this.  The stamp on the 2x4 says "A. F. P. A. 134 S-P-F xxxx KD-HT 2" where xxxx is illegible.  I don't know what any of that means but maybe it's useful.
I weigh about 210 lbs.
Comment: Assuming this is not a load bearing wall, what you are doing is permissible, but not best practice, ESPECIALLY given what you want to do with it later. Just to give you an idea, I did something similar, but the 2x4 was on edge and it calculated out to 375lbs max live load on a 3ft span between supports. But nobody even HAS span tables for a 2x4 on its side like that, because it's just not done. Not illegal (again, because it's not a load bearing wall), just not done.
Comment: If you are framing with that purpose in mind, wouldn't standing the 2x4 on it's side be better? I know you would need two of them for the header, but they are way, way stronger as opposed to how you have them.
Comment: The stamp indicates Number 2 Spruce/Pine/Fir which was kiln dried and heat treated to kill insects. The illegible parts are probably the mill and grading association.
Comment: When I framed it I wasn't planning on using it for chinups but I do like the idea of putting two studs on edge.  Would obviously be much stronger.  I should also clarify those two little pieces have nothing to do with the framing but I put those there with notches in them to attach the chinup bar to.  (I don't plan on finishing this room anytime soon) And no, it's not a load bearing wall.
Answer: I expected to see a double 2x4 header while you have a single; I'd make it a double.  FYI, you can look up weight it can support on beam span table/calculator.  You can rely upon the jack studs to support the weight but I'd add metal brackets (e.g. Simpson Strong Tie) to add additional support (i.e. for the not strictly vertical forces) since you're jerking around and brackets are less than $1 each.  Bracket the king studs to the header and two more brackets for the cross-beam.
P.S. Your stamp means it's kiln-dried southern pine/fir
Comment: I like your idea of the brackets.  I'll try a combination of suggestions, with two studs on end plus brackets as you suggest.  That should be plenty strong enough.
Comment: Hello, and welcome to Home Improvement. Thanks for the answer; keep 'em coming. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know how best to contribute here.


Maven: Failed to deploy artifacts, Acces denied

Question: I have a Sonatype Nexus server and I want to deploy a snapshot.
This is a snippet of my settings.xml file:
<servers>
  <server>
    <id>test-snapshots</id>
    <username>myname1</username>
    <password>mypasswd1</password>
  </server>
  <server>
    <id>test-releases</id>
    <username>myname2</username>
    <password>mypasswd2</password>
  </server>
</servers>

And this a snippet of my pom.xml file:
<distributionManagement>
  <repository>
    <id>test-releases</id>
    <name>Releases</name>
    <url>https://nxs.company.com/content/repositories/test-releases</url>
  </repository>
  <snapshotRepository>
    <id>test-snapshots</id>
    <name>Snapshots</name>
    <url>https://nxs.company.com/content/repositories/test-snapshots</url>
  </snapshotRepository>
</distributionManagement>

Doing a mvn deploy (Maven 3.0.3) I get this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy
(default-deploy) on project MyProject: Failed to deploy artifacts:
Could not transfer artifact com.company.project:MyProject:jar:1.0.0-20121003.154427-1
from/to test-snapshots (https://nxs.company.com/content/repositories/test-snapshots):
Access denied to: https://nxs.company.com/content/repositories/test-snapshots/
com.company.project/MyProject/1.0.0-SNAPSHOT/MyProject-1.0.0-20121003.154427-1.jar
-> [Help 1]

And in my Nexus logfile, I see that no credentials are received, so it will try it later with anonymous and this will of course fail. So why are no credentials passed to Nexus?
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.apache.shiro.session.mgt.DefaultSessionManager - Unable to resolve session ID from SessionKey [org.apache.shiro.web.session.mgt.WebSessionKey@791a17dc].  Returning null to indicate a session could not be found.
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.sonatype.nexus.security.filter.authc.NexusContentAuthenticationFilter - No authorization found (header or request parameter)
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.sonatype.nexus.security.filter.authc.NexusContentAuthenticationFilter - No authorization found (header or request parameter)
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.sonatype.nexus.security.filter.authc.NexusContentAuthenticationFilter - Attempting to authenticate Subject as Anonymous request...
2012-10-04 17:24:14 DEBUG [1027496148-8353] - org.sonatype.security.ldap.realms.DefaultLdapContextFactory - Initializing LDAP context using URL [ldap://10.100.100.1:3268/DC=company,DC=com] and username [firstname.lastname@example.com] with pooling [enabled]

Comment: Have you verified that your user account has permissions for that specific repository? See: http://www.sonatype.com/books/nexus-book/reference/confignx-sect-managing-privs.html
Comment: Yes, the user has the permission. But it seems the user can not login in, because there are no credentials in the request.
Comment: What's in the Nexus "authorization and authentication events" system feed?
Comment: At first sight, everything looks correctly set up. Can you open the snapshot repository url in your web browser and access contents of the repository using credentials from `settings.xml` ? Also, you could try to execute deploy with `-X` to get debug info (maybe something will show up there).
Comment: I already used the `-X` flag, but no more information. Yes, I can access the snapshot repository url, which contains one file `arcehtype-catalog.xml` with only one single line ``. Login to the Nexus frontend, I see in the log files "Using authorization header from request". This is missing if I want to deploy.
Comment: what user repos do you use? the ldap line at the end may indicate some missconfiguration, maybee maven will retry with credentials when told to. is the row of user repos in nexus correct?
Comment: The LDAP connection is okay. Login to the UI works, only deployment not.
Comment: I have also same type issue.Please go to this - http://stackoverflow.com/questions/18721155/maven-releaseperform-failure
Answer: Do you really have different username/password for each repository in Nexus? This will cause a problem with the maven http wagon because the jvm caches credentials per host and even though maven presents the alternate credentials properly, the jvm won't use them. The workaround to this is to use the webdav wagon instead since this uses the apache http client instead of the jdk urlclient.
Comment: For my Nexus repo I have one username/password combination, but I integrate also some other repositories for which I need different username / password. So it must work if I only use one username/password combination? WebDav wagon? How can I use this and what does this mean?
Answer: our nexus server has multiple accounts. in windows user_home/.m2/settings it has:
    <server>

        <id>release-nexus</id>
        <username>aa</username>
        <password>AA</password>
    </server>
    <server>

        <id>snapshots-nexus</id>
        <username>aa</username>
        <password>AA</password>
    </server>

And in project:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>some.groupid</groupId>
  <artifactId>some-demo</artifactId>
  <version>1.0.0</version>

  <distributionManagement>
    <repository>
      <id>release-nexus</id>
      <name>Maven Repository Switchboard</name>
      <url>http://nexus.foo.net/nexus/content/repositories/aa/</url>
    </repository>

    <snapshotRepository>
      <id>snapshots-nexus</id>
      <name>Maven Repository Switchboard</name>
      <url>http://nexus.foo.net/nexus/content/repositories/aa_snapshot/</url>
    </snapshotRepository>
  </distributionManagement>
</project>

after running mvn deploy
The output is:

All <repository>s configured in settings are different than what we used in project pom distributionManagement. If I put what in settings in pom, it would result in a same error forbidden. I found the correct url when I logged in nexus server with the username and password aa and AA, and I found there is a aa and aa_snapshort. So I guess authorities for PUT operation is actually on a much more detailed level.
Answer: you need the 'settings' element as root,
put this in your settings.xml file:
<settings>
    <servers>
        <server>
            <id>test-snapshots</id>
            <username>myname1</username>
            <password>mypasswd1</password>
        </server>
        <server>
            <id>test-releases</id>
            <username>myname2</username>
            <password>mypasswd2</password>
        </server>
    </servers>
</settings>


Is there any way to get any of the other angels to fight with you?

Question: There is an 'Angel Info' Screen and it seems way too empty with only Lilliel there for her to be the one and only party member option.
Answer: You're in the right spot.  But you only unlock the other angels after you complete Chapter 5.
Once you do, in the Angel Info, you can select which angel you want to use, and up at the top, where it says, "Current partner" will change to the angel you just selected.  Since each has their own unique skill, this can be beneficial to your playstyle.
Comment: I just beat Chapter 5 and they were all unlocked at once. I was actually about to add it myself. I was afraid I was supposed to be talking to them the whole time.


How should I mount a hanging closet panel with no wall for its hang rail?

Question: I am planning to install a new closet system in my second bedroom using one of those "hanging closet" kits - the kind where you secure a cleat to a wall that side panels hang off of.
The shape of the closet makes using the hang rail a little difficult though. Specifically, the closet houses my water heater in a little nook on the left side of the closet. The layout looks like this:

The plan is to have 3 separate sections, where the left section covers the water heater. It would look like

with a layout like this:

Because there's no wall behind where the single hang bar will be, my plan is to just fasten its left panel directly into studs behind the leftmost wall. Its right panel (which doubles as the middle section's left panel) would be sitting directly over the corner where the two walls meet.
My questions are

Will my plan of fastening the left section's panel directly to studs in the wall provide sufficient support to the closet, or is this a bad idea?
This might be a very stupid question, but I know corners where drywall meet typically have the metal corner guard to protect the edge. Is it okay to drive a fastener for the hang rail through this metal guard?
Comment: You want to make sure of easy access to the water heater.  Studs are the prefer mounting spots.  Metal drywall corners are used on outside corners, not often on inside corners.
Comment: Yes, the hang bar and shelf will be above the top of the water heater. The right panel of the left section will be hanging directly on top of an outside corner, not an inside corner
Comment: An outside corner I might want to drill a pilot hole first, to not crack the drywall mud.  It is quite thin on corners and very easy to crack.  Screws are easier to control than nails.
Answer: Fastening anything to the left wall should be rock solid.  The details are important.  Look at exactly how your system fastens to the wall.  Make sure the left panel can be fastened, somehow, to studs and/or the hanging rail can be driven through the left panel and fastened directly to a stud.
Mounting the other end of the tall hanger to the corner of the wall should be ok if it's not right on the edge.   The metal corner bead is protecting the two sheets of drywall that meet at the corner.  If you are too close to the corner, your screws will go through the bead and into the edge of the side-wall of the nook.  You need to be far enough to the right that your mounting hardware will connect to the studs at the corner.  The bead itself is not structural.
Comment: Thanks for the reply. The panel on the left wall is made of wood, so my plan was to screw through the panel into the the stud with a washer on the screw. For the right side, is there any way to ensure I'm hanging over the stud and not drywall? Is a stud finder reliable for corners like this?
Comment: A stud finder is not useful here.  There has to be a stud there.  Since you're going to be installing shelving there, there is no harm in drilling small test holes.  You can determine exactly where the stud is, and whether it is wood or metal, and use appropriate screws.  Assume there is 1/2 to 5/8 inches of drywall, and 1.5 inches (or more) of stud at the corner. Drill your first test hold 1 inch from the surface (side of the nook and you'll hopefully find solid wood.


Lubuntu 16.04 boot slow (cgroup: new mount options do not match the existing superblock, will be ignored)

Question: After upgrading from Lubuntu 14.04 to 16.04, the boot takes much longer time. Running dmesg, I find one task takes a significantly longer time:
cgroup: new mount options do not match the existing superblock, will be ignored

Searching on internet, it seems to be a fstab issue. It happens to those who adjust the partitions. But the thing is that I never adjust the partitions during or after the upgrade. Also the result of blkid matches the content of fstab.
Output of sudo blkid
/dev/sda1: UUID="40F4AB0BF4AB01F0" TYPE="ntfs" PARTUUID="4de78bef-01"
/dev/sda2: UUID="909fbd0b-69c1-45a3-b7fc-9bbe122fa7fe" TYPE="ext4" PARTUUID="4de78bef-02"
/dev/sda3: UUID="a5e6b8bc-14b8-4032-8e01-9dbd8a7893a5" TYPE="ext4" PARTUUID="4de78bef-03"
/dev/sda4: UUID="0471ceb6-79cd-49ad-a708-f9045d092873" TYPE="swap" PARTUUID="4de78bef-04"

Output of cat /etc/fstab
UUID=909fbd0b-69c1-45a3-b7fc-9bbe122fa7fe /               ext4    errors=remount-ro 0       1
UUID=a5e6b8bc-14b8-4032-8e01-9dbd8a7893a5 /home           ext4    defaults        0       2
UUID=0471ceb6-79cd-49ad-a708-f9045d092873 none            swap    sw              0       0

Can anybody say why it's giving this error message?
Answer: I had exactly the same issue, but after I installed a second Linux and configured it to share the swap partition with Ubuntu. Even after I adjusted the /etc/fstab file, Ubuntu would need 2 minutes to show the login screen. The command dmesg displayed the message cgroup: new mount options do not match the existing superblock, will be ignored.

In my fstab I found the following entry: #/dev/mapper/cryptswap1 none swap sw 0 0, and that was a hint that there used to exist a cryptswap partition that I probably set up when I installed Ubuntu (I do not remember now).

However, to get rid of the remains of that partition I did the following:
1. sudo swapoff
2. sudo cryptsetup remove /dev/mapper/cryptswap1 (In my case, this file was already deleted)
3. sudo vim /etc/crypttab   Here, I found an entry that referred to the non-existing cryptswap. I deleted it.
4. sudo /sbin/mkswap /dev/sda4 (In your case, swap is on /dev/sda4)
5. sudo swapon /dev/sda4.
Afterwards, my Ubuntu started normally again. I hope that helps.
Answer: My /etc/fstab somehow got a logical volume map (LVM) disk added to it. I don't know how because this is something I have never used on this machine.
/dev/mapper/vg_phoebus-lv_swap none swap sw 0 0

I used:
sudo dmsetup -v table /dev/mapper/vg_phoebus-lv_swap

and:
ls -lha /dev/mapper

to confirm there was no LVM volumes and then I removed that line from /etc/fstab.
There is a handy way to look at what's taking time to boot:
systemd-analyze blame

Mostly unrelated but through I would add it here. I also had a problem with powerd on shutdown see this bug report: powerd takes eternity to boot on pc
I disabled it as suggested:
sudo systemctl disable powerd.service

Answer: I had the same problem after updating to 16.04. I found this answer to be very helpful and it solved my problem:
https://askubuntu.com/a/614660/319782
Long story short list your UUID's
sudo blkid

Check for UUID mismatches in /etc/fstab
cat /etc/fstab

fix mismatches if they exist
sudo emacs /etc/fstab

then reboot
Comment: How do you `fix mismatches if they exist`?  What am I supposed to do here?
Comment: As shown in the original post, the result of blkid matches exactly what's inside fstab.
Comment: I only see three drives in the fstab but 4 in the blkid.
Comment: /dev/sda1 is the windows partition and I guess it's never added to fstab, even under lubuntu 14.04
Comment: Downvoted this answer I'm afraid, as it's not offering any actual help AFAIKT.
Comment: @TommyPeanuts Really? It helped me. I guess you have a different problem. Thanks for stopping by, though.
Comment: @atomSmasher the words "fix mismatches if they exist" is too vague - mismatches in what?
Answer: I had the problem (in EC2) because I changed one of the drives (the boot drive) from a solid state drive (SSD) and to a magnetic drive.  I didn't update the /etc/fstab, which showed the mount option as

defaults,discard

It turns out that the 'discard' option is unique to SSD drives* so doesn't apply to magnetic drives.  I removed the discard option and the message went away.
*http://blog.neutrino.es/2013/howto-properly-activate-trim-for-your-ssd-on-linux-fstrim-lvm-and-dmcrypt/


Get javascript values to insert them into mysql database

Question: The following code is used for getting two values from two textboxes , calculate the sum using javascript and display the result in third textbox. When I click the button, I just want these textbox values (both input and result) to be inserted into mysql database. I want to do this in the same page. How can I get the javascript values to php for inserting them into database? It would be great if you could help.
Thanks
Jeny
Code:

<form>

    Enter A
    <input name="text" type="text" id="in1"/>

    Enter B
    <input name="text2" type="text" id="in2"/>

      <button type="button" onclick="getText3()"> Get calculated result</button>

    RESULT
    <input name="text3" type="text" id="in3"/>

</form>

Comment: Have you heard about Ajax+jQuery? http://stackoverflow.com/questions/5143191/inserting-into-mysql-from-php-jquery-ajax
Comment: You want the Values when the form is submitted rite? there use Hidden Input values for submitting it!
Comment: Don't use the example of the hidden values in the form. Just do an AJAX post to the server using the values you have programmatically received from Javascript. Like in Tim's example.
Answer: For this you should use jQuery (http://jquery.com/)
Just send them to your php file like the following:
// JS:
var in1 = $('#in1').val();
var in2 = $('#in2').val();
var in3 = parseInt(in1, 10) + parseInt(in2, 10);

$('#in3').val( in3 );

$.post('file.php', { one: in1, two: in2, three: in3 }, function(data) {
    alert( data );
} )

PHP file get's them as normal POST params:
// file.php
echo $_POST['one'] . " + " . $_POST['two'] . " = " . $_POST['three'];

Comment: The only thing I would add to this is to calculate the third value (as specified in the question). You could do this by declaring var in3= in1+in2 and then add that to your data object {...., three:in3} in the AJAX post call. The only question I have is why would you want to store the addition result in the database. It makes no sense. Why store it in a database when it can be easily calculated?
Comment: You're right, I added it to my question.. The question 'why' is always difficult, I just like to think of it as people playing around to learn.
Comment: @Tim I'm just curious as to why you suggested to use jQuery for the `$.post`, but didn't use jQuery for the variables, eg `var in1 = $('#in1').val();` . Just curious if there was a particular reason?
Comment: The first lines were copied from the question. ;) I would just use jQuery for that.. -updated..
Answer:

Answer: You can Pass the JavaScript Values to a HIDDEN Value in FORM and then POST the form to the PHP Page. Below is an example of how to set hidden value.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

    <title>
      </title>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

        <form>
          <select name="category" onchange="setPrice(this);">
            <option value="men">
              Men
            </option>
            <option value="women">
              Women
            </option>
            <option value="under18">
              Under 18's
            </option>
          </select>
          <input name="price" type="hidden" value="30">
        </form>

Hope this will help you!


why is gstreamer caps is blocking pipeline

Question: I am trying a basic pipeline below. If I run the pipeline without the caps function it passes straight through (assuming same I/O format). Once I add the caps the pre-roll starts  but the video does not continue through to the sink output.
Am I coding this wrong?
thx
Art
    #include <gst/gst.h>
#include <glib.h>

static void
on_pad_added (GstElement *element,
              GstPad     *pad,
              gpointer    data)
{
  GstPad *sinkpad;
  GstElement *decoder = (GstElement *) data;

 g_print ("Dynamic pad created, linking out/in \n");

  sinkpad = gst_element_get_static_pad (decoder, "sink");

  gst_pad_link (pad, sinkpad);

  gst_object_unref (sinkpad);
}

int
main (int   argc,
      char *argv[])
{
  GMainLoop *loop;

  gboolean link_ok;

  GstElement *pipeline, *source, *decoder, *ffcs, *vidsc, *capsfout, *sink;
  GstBus *bus;
  GstCaps *caps;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("video-player");
  source   = gst_element_factory_make ("filesrc",           "file-source");
  decoder  = gst_element_factory_make ("decodebin2",        "dec-bin2");
  ffcs     = gst_element_factory_make ("ffmpegcolorspace",  "ffcs");
  vidsc    = gst_element_factory_make ("videoscale",        "vidsc");
  capsfout = gst_element_factory_make ("capsfilter",        "capsfout");
  sink     = gst_element_factory_make ("filesink",          "vidout");

  if (!pipeline || !source || !decoder || !ffcs || !vidsc || !capsfout || !sink) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }

  /* we set the input/output filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);
  g_object_set (G_OBJECT (sink), "location", argv[2], NULL);

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

  gst_bin_add_many (GST_BIN (pipeline),
                    source, decoder, ffcs, vidsc, capsfout, sink, NULL);

  /* we link the elements together */
   gst_element_link (source, decoder);
   gst_element_link (decoder, ffcs);
   gst_element_link (ffcs, vidsc);

  caps = gst_caps_new_simple("video/x-raw-yuv",
                      "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
                      "width", G_TYPE_INT, 384,
                      "height", G_TYPE_INT, 216,
                      "framerate", GST_TYPE_FRACTION, 25, 1,
                      NULL);

  link_ok = gst_element_link_filtered(vidsc,sink,caps);
  gst_caps_unref (caps);

  if (!link_ok) {
      g_warning ("Failed to link vidsc to sink!");
    }else{
        g_print("seems ok, no error reported?\n");
    }

  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);

  /* Out of the main loop, clean up nicely */
  g_print ("Returned, stopping playback\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);

  g_print ("Deleting pipeline\n");
  gst_object_unref (GST_OBJECT (pipeline));

  return 0;
}

Answer: It may be late to answer but you maybe forgot to do the dynamic pad link between some elements and you never call the on_pad_added function. I had the same problem.
Have you tried to add it since then? For example this line to dynamically link two elements instead of the gst_element_link:
g_signal_connect (decoder, "pad-added", G_CALLBACK (on_pad_added), ffcs);

Answer: For what reasons do you need the capsfilter? Only constrain the properties you need. E.g. you set a framerate, but don't have a videorate element before the capsfilter. If you don't care about the framerate (e.g. just want to force a size) remove the framerate from the caps you set on capsfilter..


Switching between Scene and Activity

Question: I am developing a game where I am using andengine SceneManager to manage various scenes. In one scene I have a button which passes control to a class that extends activity (not scene) and uses an XML file for layout.
My problem is that in that activity I have a button. Clicking on that button should open a scene. I am using the following syntax to open a scene but it doesn't do anything.
<code>SceneManager.getInstance().loadPreLevel(engine, "levelfail");
</code>
where SceneManager is the scenemanager class and loadPreLevel is a method that I use to open activate loading scene and this line of code works everywhere else in my game.
Does anyone know how to open a scene from an Activity's subclass.
Answer: First of all, Your game structure is not so good like at all. It's Better to keep only one Activity to Initialize the game start up and rest of Scene will extends scene including Splash!
I would suggest to look this article to clearing the concept about activity versus scene.
Comment: I know that but I want to impliment google in app billing and i was unable to make it working in a scene as it need override some Activity classe's methods that can be done by extending from Activity.
Comment: anyone have any other solution?

Switching between Scene and Activity


Addressable vs Alignment

Question: My questions are related to memory?

What is the difference between alignment and addressable?
If a memory is byte addressable and word aligned then can't we directly have a          word addressable memory?
Also when we say we have a block transfer what does it mean. As in if the size of the block is greater than word (databus),then does that mean it takes more than one cycle to transfer.
Answer: Short answer
Addressability refers to the smallest unit of memory that can be accessed, while alignment relates to accesses to larger groupings of memory (typically called a word).
Detailed answer
This question is probably best answered with an example.  Imagine a byte-addressable architecture that has 4 byte words.  For this example we will only consider loads and assume there are two types LB (load byte) and LW (load word of 4 bytes).
First consider an LB operation.  In this case the CPU actually accesses 4-bytes from the cache, and then shifts the output to pick the desired byte.  So LB 0x10 or LB 0x11 each access 4 bytes of memory from 0x10 to 0x13.  It doesn't really matter what the alignment of this access is.
Next consider an aligned LW operation.  The LW reads 4 bytes from memory.  So LW 0x10 reads the 4 bytes from address 0x10 to 0x13.  This can be done as a single operation just like the LB operation.
However an LW 0x11 operation would be an unaligned access. It actually needs the data from 0x11 to 0x14, but the data that is read from the cache comes in 4 byte chunks.  So it would read the 4 bytes from 0x10 to 0x13 and also have to perform another access that reads from 0x14 to 0x17.  Then it would pick the desired bytes 0x11 to 0x14 from these two accesses.
There are ways to optimize unaligned accesses at the microarchitecture level so that an unaligned access it not as costly as two aligned accesses, but an unaligned access will always require the CPU to do more work than an aligned access.  As a result some architecture prohibit unaligned accesses.  The LB is still allowed even for architectures that prohibit unaligned accesses, because the LB operation only needs a subset of the bytes from an aligned access.  Whereas an unaligned accesses needs a subset of bytes from two aligned accesses.  Other architectures allow unaligned accesses so as to not limit programmer flexibility, but they still recommend that programs perform mostly aligned accesses whenever possible.
For the second part of your question I'm not exactly sure what you mean by block transfer.  But if you are accessing more data than fits on the data bus then yes it will require more than a single cycle.

Addressable vs Alignment


Switched outlet has open neutral when switch is off

Question: I have recently purchased a house and in checking out the wiring, noticed one room has a switched outlet that is miswired.
When the wall switch controlling this is on, the outlet is fine but when it is off, a tester shows the outlet has an open neutral.
I have yet to cut the power and open up the receptacles but what should I be looking for?  Would this likely be a wiring issue in the outlet itself or at the switch? My personal guess would be that the switch is wired wrong but I've not run up against an open neutral issue before.
Comment: This could be miswired either at the switch or the outlet. You're going to need to figure out how it's wired so we can tell you how to fix it.
Comment: ...just to clarify, the switch needs to break the hot wire, not the neutral wire, so that there is no voltage potential at the outlet when the switch is off.
Comment: Longneck is right, it could be in either location. Won't know until you look. My first guess would be that the switch is controlling the neutral wire rather than the hot wire. Could be a rather simple fix if the hot and neutral are both in that switch box. Could be more complicated if there's more strange wiring.
Comment: Thanks guys, I'll check this weekend when I get home but the switch being on the neutral wire makes a lot of sense.
Comment: @shadowzen -- what results did you get back from your testing?
Comment: Finally got a chance to look at the switch.  This is a dual gang with the other switch running to ceiling fan.  It was a mess.  Both switches were wired on the neutral with all the hot wires capped together and a neutral jumper between the two switches instead of a pigtail.  No grounds on the switches themselves.  Four cables come into the switch box but only one is hot.  Now I just need to confirm which wire goes where and fix it. Guessing the 4th wire is a pass-through.
Answer: Some dopehead put the switch in the neutral wire, which is forbidden by Code as it's a shock hazard.  You'll have to turn power off to the circuit, and then pull both the receptacle and the switch out.  If you see a white wire going to either the brass screws on the receptacle, or any screws on the switch, that's your problem, unless you have a switch loop; in that case, look for a black-flagged wire (or a black wire) wire-nutted to a white wire.  (Someone also could have left  the black paint or tape flags off the switch loop's white wire, and then some dunderhead later on screwed it up without realizing what he was doing...)


Best material to seal fireplace door gaps for irregular stone fireplace?

Question: I have a stone fireplace and just installed a new door. But there's gaps because the stone is irregular. I tried using fireplace cement from the inside but it's hard to get in there and keeps falling out.
Is there any better material I can use? Some kind of sealant that won't burn up?
Thanks
Comment: if the gaps are not two big rockwool may work
Comment: I'd look at mortaring (or simply bolting) in a frame against which the door would seal better.
Comment: Can you remove the door and then smooth out the edges before reinstalling?
Answer: the best way to this is with fiberglass gasketing, sometimes called door rope.  its just a fiberglass rope.  you get some hi-temperature sealant for same, inject into the area it is to fill so that it covers stone and the metal assembly.  then, rub it all over the rope (cut to the right length ahead of time) and then simply squeeze into the gap.  different diameters might need to be used, but usually one will do.  tape off all adjacent areas and where gloves as the sealant is quite gooey and makes a big mess.  wipe the area off with acetone after to clean up prior to removing the tape
http://www.mcmaster.com/#high-temperature-seals/=103j65h
http://www.mcmaster.com/#high-temperature-sealants/=103j5zd
they will sell something similar at your local big box building store
Comment: I ended up just sealing with hi temp caulking. Wasn't able to find any door rope and I didn't really need it. Used about 4 tubes though.
Comment: i hope it works out for you. the reason you use the rope is it provides mechanical reinforcement for the sealant.  without it you will probably see cracking and spalling shortly as the sealant hardens and crystalizes.  if it fails on you, repeat the process but with the roping.  then you should have a fairly permanent repair.  good luck though.
Comment: Important to note that fiberglass is a potential carcinogen especially posing a high risk to those who are exposed consistently over a long period of time. see here for more info https://survivingmesothelioma.com/unexpected-mesothelioma-deaths-in-fiberglass-workers-raise-questions/ I wood use steel wool in this case since it provides the same structural support then I'd add caulking over it.


Ruby error could not find the generator integration_test_static_pages

Question: i am following the tutorails on net for ruby on rails  http://ruby.railstutorial.org/chapters/static-pages#sec-static_pages
And when i run the command rails generate integration_test_static_pages and i got the error
 Could not find the generator integration_test_static_pages  .I have update the bundle using bundle update and also updated all the dependencies using bundle install but  why this error is raising?
Answer: Sorry i was entering the wrong command, the actuall command is rails generate integration_test static_pages.
Resolved one!! hurrah.


Updating a grid after changes have been made

Question: Right, this is probably going to be pretty simple. I have a form that contains a grid, if you select one of the records and press 'Edit' you get taken to another form where you can edit the data attached to that record - this all works.
However upon saving it will write it to the database but will not update the aforementioned grid until I come out of my program all together and then go back in.
All I want to do is get the grid to update when exiting the other form.
I have tried opening/closing the table components, calling the 'refresh' against the query and the table.  I am connecting to the database using BDE and writing this in Rad Studio XE2.
Any help would be appreciated.
Comment: See [how-to-refresh-dbgrid-without-close-and-open-dataset-in-delphi](http://stackoverflow.com/questions/2311007/how-to-refresh-dbgrid-without-close-and-open-dataset-in-delphi) if that helps.
Answer: Hope this solves your problem
Table1.Active := False;
Table1.Active := True;

for a TTable and
TQuery1.Active := False;
TQuery1.active := True;

for a TQuery


Why is this timestring not recognised by momentjs-node?

Question: According to http://momentjs.com/docs/#/parsing/ 20130208T080910 is a supported ISO 8601 string of moment.js. Node-red-contrib-moment is the Node-red implentation of this moment.js.
I'm sending "20170630T141515" to the moment node (Date/Time Formatter) and get the debug message "The input property was NOT a recognisable date. Output will be a blank string". What is my fault here, what can I do to get a nicely foramted date output string?
Comment: I was able to duplicate your problem.  I also hit a problem where "TypeError: node.inTz.split is not a function" before the payload config is updated (you have to do something to save the editor at least once).  I'd suggest opening an issue on github; I don't know that I can dig any deeper (but I'll do what I can this week).
Comment: Have you tried sending "20170630T141515Z"?
Comment: Yes, this doesn't change anything :-/
Answer: In your case try to set the Moment parsing format to: YYYYMMDDTHHmmss
Vanilla JS with Moment.JS: moment("20170630T141515", "YYYYMMDDTHHmmss");


TeamCity Android Proguard results in "Your input classes appear to be inconsistent."

Question: When I build my Android project from the command line with
gradlew assembleRelease

It works, but when I run it from my teamcity build agent the build gives a lot of warnings and fails witht he following errors:
[11:40:43][Step 4/10] Warning: there were 75 unresolved references to program class members.
[11:40:43][Step 4/10]          Your input classes appear to be inconsistent.
[11:40:43][Step 4/10]          You may need to recompile the code.
[11:40:43][Step 4/10]          (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
[11:40:43][Step 4/10] :proguardRelease FAILED

I've tried modifying my build config to run gradlew from command line instead of using the gradle build runner but it is still broken. There is obviously something different between running the command from TeamCity versus running it manually through command line, but I don't know what that could be. Where to look?
Answer: Your problem and solution are right what it says on the tin:

Your input classes appear to be inconsistent.
You may need to recompile the code.

Given you're using Gradle, it's possible one version of gradle doesn't match the other or doesn't behave the same. This is particularly true if e.g. you've upgraded gradle from an older version.
Fix is simple: gradle clean or gradlew clean then try again.
Comment: That didn't work, however my build is working now after recreating the build environment in another directory. It doesn't make sense. Thanks for the help.


Django: How do I create a view to update multiple records on an intermediate model with a Many-to-Many-through relationship?

Question: I am a beginner to Django, and am creating an RSVP site to handle multiple events and keep track of guests to those events.  I have a model for Guest, for Event, and an intermediate model for GuestEvent.  I would like a page to loop through every GuestEvent for a Guest and allow me to update the attending, adults, and children fields in GuestEvent.  I will never need to create or delete these fields through the front-end.
I am currently trying to use the class-based UpdateView, but could easily switch to a different view.  I've tried to use django-betterforms and django-extra-views, but didn't have any luck with either.  I've also made a few attempts at following tutorials for formsets and inline formsets with no success.
My models look like this:
class Event(models.Model):
    name = models.CharField(max_length=200)
    description = models.TextField(null=True, blank=True)
    date = models.DateTimeField('event date')
    guests = models.ManyToManyField('Guest', through='GuestEvent')

class Guest(models.Model):
    first_name = models.CharField(max_length=45, null=True, blank=True)
    last_name = models.CharField(max_length=45, null=True, blank=True)
    events = models.ManyToManyField('Event', through='GuestEvent')

class GuestEvent(models.Model):
    guest = models.ForeignKey('Guest', related_name='guests')
    event = models.ForeignKey('Event', related_name='events')
    attending = models.NullBooleanField()
    adults = models.IntegerField(null=True, blank=True)
    children = models.IntegerField(null=True, blank=True)

What would be the best way to get these intermediate records in some sort of update view?
Answer: I think I have this mostly working now with Django-Extra-Views.
My view looks like this:
class GuestEventInline(InlineFormSet):
    model = GuestEvent
    fields = [ 'attending', 'adults', 'children' ]
    extra = 0
    can_delete=False

class Invite2View(UpdateWithInlinesView):
    template_name = "weddings/invite2.html"
    model = Guest
    inlines = [ GuestEventInline ]

And my template looks like this:
<form action="" method="post" class="form-horizontal">
    {% csrf_token %}
    {{ form }}
    {% for formset in inlines %}
        {{ formset.id }}
        {{ formset.management_form}}
        {%for subform in formset%}

{{ subform.instance.event }}

            {{ subform.as_p }}
        {% endfor %}
    {% endfor %}
    {% buttons submit='Save' %}{% endbuttons %}
</form>


How to detect when the player is at half a heart with command blocks 1.16.3

Question: I am making a game where if the player is at half a heart I want to teleport them to a place. Is it possible to detect player health with command blocks? Thanks.
Comment: Possible duplicate of [Is it possible to check for an injured player in Minecraft?](https://gaming.stackexchange.com/questions/145030/is-it-possible-to-check-for-an-injured-player-in-minecraft)
Answer: For this method you need a scoreboard for health. You can make it with the following command.
scoreboard objectives add health health

To test if a player has a certain amount of health, you can do it with the following command:
execute as @a[scores={health=<number>}] at @s run tp <coordinates>

Default health is 0–20. Half a heart is 1.
Comment: Thank you so much! It works perfectly!


Unity Scope doesn't search contacs

Question: I migrated from Gnome 3.x to Unity, the one thing I miss is the contact search from Gnome.
Mine online contacts Google and Facebook are successful synced with online accounts. When I looked in Gnome contacts there was nothing synced?
Also I can not use Unity Dash to search my contacts. Anyone with an solution?
Sorry for the mediocre English its not my mother tongue.
Answer: Currently there is no Unity scope installed by default that will search your contacts.
There is a prototype scope that could fill that role if it is completed here:
https://launchpad.net/unity-lens-people
It isn't really ready for prime time yet though, so is not in the Ubuntu archive.

Unity Scope doesn't search contacs


16.04 Cannot Access Terminal

Question: I'm having troubles. . . I cannot access any terminal (though I haven't tried safe mode).  Default terminal, Xterm, UXterm crash in GUI after being clicked.  Ctrl-Alt-F1 Will bring up a terminal login, but after entering credentials, it loops log in instead of giving a prompt.  The ctrl-alt-f1 screen greys out and is barely readable after login prompt shows.
I have tried updating the system.
Rebooting several times.
Recent system changes?  I installed SSH.  Thought to uninstall it to check, but I don't have terminal access.
7.8 G memory
Intel i7-2600 @3.4 x4
AMD Caicos
64 bit
I'm no power linux user, so forgive me if this is a noob issue.
Thanks
Comment: You may be able to sftp "clean" copies of the default `~/.profile` and `~/.bashrc` from `/etc/skel` - most likely it's one of those (or the equivalent shell config, if you are using some alternate login shell)
Comment: logged in as another user and guest, and was able to access terminal.  Neither of those accounts have root access, but this is probably a config issue on my account?  Any issues with Ubuntu updates of late?
Comment: Since you've installed SSH can you SSH onto it from another PC?
Comment: default setting is no remote access on ssh.  sftp works fine tho ; /
Comment: no dice.  was able to import from /etc/skel  additionally, after looking at my bash history, I had recently installed mysecureshell and plexmediaserver.  I don't know if this has anything to do with it, but plexmediaserver, deluge, are not showing files that exist on a partition on another HD.  Disk scan shows OK, and can load files directly from partition.  Possible corruption issue? I'm making a recovery usb now and will keep digging.
Comment: A fun complication, GRUB broke.  Whoot!
Answer: Created new root account.
Removed mysecureshell and plexmediaserver
Problem resolved, mostly.  Cannot access terminal through ctl-alt-F1.

16.04 Cannot Access Terminal


how to improve performance of Ubuntu 12.10?

Question: My Dell have 3GB RAM. In Windows 7, I can easily get 22-25 mbps copying speed
but here in Ubuntu I am getting only 7-8 mbps. I even installed zRam.
<code>sudo add-apt-repository ppa:shnatsel/zram
sudo apt-get update
sudo apt-get install zramswap-enabler
</code>
this also did not worked.
Please tell me how can I improve my laptop's performance?
Comment: Copying *from* what *to* what, *over* what? And why would you expect zram to improve anything related to disk throughput?
Comment: copying from external hard disk..via google i got this link
[enter link description here][1]

  [1]: http://ubuntuportal.com/2012/05/how-to-increase-performance-ubuntu-pclaptop-with-low-ram.html

so i installed zRam
Answer: Yeah, I don't think zram would help you at all, unless your physical memory usage is being capped (which it likely isn't for file transfers).
It might possibly be related to the driver in-use for the hard drive controller (assuming SATA). May need more information though, like laptop specs, and/or model.
Comment: i have Dell Inspiron 15R(N5010)
Comment: same model [1]: http://www.techradar.com/reviews/pc-mac/laptops-portable-pcs/laptops-and-netbooks/dell-inspiron-15r-697899/specification
with 3 GB RAM


An error occurred while trying to call the requested method validateAssets. (1272)

Question: When I tried to submit an App to Itunes Connect I got the following error.
<code>App Store Connect Operation Error

An error occurred while trying to call the requested method validateAssets. (1272)
</code>

Any suggestions on what I need to change to be able to submit my app?
Comment: Same error today. Sometimes its "validateMetadata. (1272)"
Comment: Same is happening for me, just now... Is this a App Store Connect outage?
Comment: same error with validateMetadata (1272). how to fixe it?
Comment: Same story, looking for a fix
Comment: Nothing new yet, Apple System status says there is an outage.
Comment: The resurrection of the issue! https://github.com/fastlane/fastlane/issues/19572
Answer: Looks like theres an apple developer outage: https://developer.apple.com/system-status/
Answer: Try multiple times, I've managed to upload build right now in less then 100 attempts xD
Comment: Nvm, even after "successful" upload the build is not visible on Appstore Connect even as "Processing", so it was just a partial victory. Best thing is to give up and wait for Apple to fix problems :/
Comment: Came here to say this! After it's showing as green tick successful in Organizer, i actually can't see it in App Store connect! So yeah, bugger.
Comment: my new version finally showed up... seems like it's resolved? as far as i can see it so far


Google Maps api

Question: I have to provide such functionality:
User checks 2-10 cities at Google Maps, I count the way between those cities using roads and show the way. The additional information is length of the full way.
Is it possible with google maps?
Comment: You're basically giving us the spec and asking for 'teh codez'. What have you tried and what isn't working?
Comment: @sergio-boombastic I used another map engine and I know how to work with it. Now I have a request for google maps and I don't know is that functionality possible there. I don't want to spend my time for reading it. If it's not available I'll use my old map engine.
Answer: If you already know the order you want to be travelling to the cities in, then you just have to make a DirectionsRequest using the in between cities as waypoints. If you don't know the order, as long as you know the start and end, you can have Google Maps optimize the order of the waypoints for you.
http://code.google.com/apis/maps/documentation/javascript/services.html#Waypoints

Google Maps api


Bad Company 2 Vietnam compatibility

Question: A friend of mine bought the Vietnam expansion in the Playstation Store and tried to share with me. I downloaded the expansion with the account he provided, but it didn't work, the option to play Vietnam didn't show on my game's menu. My Bad Company 2 copy is from Hong Kong, and he said it might be because the account he used to buy his Vietnam expansion was from the UK. If I buy the expansion myself with my US account, will it work for my copy of the game? Is there a way to know beforehand if it will work?
Answer: BC2 Vietnam expansion pack is physically just the activation code (similar to CD-key) to enable it. Obviously it can be used only once for one account only.
Comment: So, will it work if I buy it, regardless of which account I use or the region my copy was bought in?
Comment: Well, I don't know how about PSN version, in case of PC it's all just sold by EA Store and linked to EA user account.

Bad Company 2 Vietnam compatibility


Pass a string to ASyncTask when NDEF_DISCOVERED

Question: I am working in NFC tag. My task is that when a NFC is scanned, I must read the NFC information and send it to ASyncTask. In ASyncTask, I will used the HttpClient to send that information to server. I read NFC information successfully. I searched and found my solution. I just used the simplest solution such as below.  That code works well. The ASyncTask is initialized in ACTION_NDEF_DISCOVERED, hence, when tag is scanned,  ASyncTask will be created and call the request to server. My problem is that ASyncTask created many times (whenever tag is scanned). Do we have any way to create ASyncTask just one time in onCreate, and we will pass a string to the ASyncTask when tag is scan?
    /////Read NFC Information///////////////
    @Override
    protected void onNewIntent(Intent intent) {
        if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
            //Read NFC tag succesfull
            String NFC_information=100;
            new AsyncCallWS().execute("101");
        }
    }
    private class AsyncCallWS extends AsyncTask<String, Void, Void> {
        @Override
        protected Void doInBackground(String... params) {
            String url="server_link"+params[0];
            try {
                String content_feedback=getStringContent(url);

            } catch (Exception e) {e.printStackTrace();
            }
            return null;
        }
        @Override
        protected void onPostExecute(Void result) {
            Log.i(TAG, "onPostExecute");
        }
        @Override
        protected void onPreExecute() {
            Log.i(TAG, "onPreExecute");
        }
        @Override
        protected void onProgressUpdate(Void... values) {
            Log.i(TAG, "onProgressUpdate");
        }
    }
    public static String getStringContent(String uri) throws Exception {
    {
        try {
            HttpClient client = new DefaultHttpClient();
            HttpGet request = new HttpGet();
            request.setURI(new URI(uri));
            HttpResponse response = client.execute(request);
            InputStream ips  = response.getEntity().getContent();
            BufferedReader buf = new BufferedReader(new InputStreamReader(ips,"UTF-8"));
            StringBuilder sb = new StringBuilder();
            String s;
            while(true )
            {
                s = buf.readLine();
                if(s==null || s.length()==0)
                    break;
                sb.append(s);

            }
            buf.close();
            ips.close();
            return sb.toString();

            }
        finally { }
    }

Comment: What is the problem with this? your code is fine.
Comment: May be you need to create AsyncCallWS Object once in onCreate() and you need to call execute() using existing AsyncCallWS  object, Which was created in onCreate().
Comment: @DegenSharew: You can see that AsyncCallWS is created many time by new AsyncCallWS().execute("101");, hence, whenever tag is scaned, a  new AsyncCallWS() is called. I think that it is not necessary
Comment: I see that but it is fine.
Comment: Yes you are creating a new AsyncTask on each new Intent received,You could probably create it once during initalization of the Object and be calling the execute method
Answer: You can do it like below:
public void onResume() {
    super.onResume();
    ...
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
        Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        if (rawMsgs != null) {
            msgs = new NdefMessage[rawMsgs.length];
            for (int i = 0; i < rawMsgs.length; i++) {
                msgs[i] = (NdefMessage) rawMsgs[i];
                //consider single message is there hence loop will iterate only once
                new MyAsync().execute(msgs[i]);
            }
        }
    }
    //process the msgs array
}

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="text/plain" />
</intent-filter>

Because after calling onNewIntent, onResume gets called.
Comment: Yes you can. Because the thing you want goes from here only do don't need redundancy


Python regex fractions

Question: I'm trying to use regex to replace instances of a fraction (specifically 1/2) with the decimal equivalent
string = "7 1/2"
re.sub(r'[1/2]', '.5', string)

Firstly, I think the above replaces all instances of 1, /, 2 with .5, whereas I'm trying to find and replace the entire term "1/2"
Secondly, how do you handle the leading space before the fraction itself?
Comment: instead of `[ ]` use `()` to capture the fraction group
Comment: "I think the above..." Have you tried or is this just speculation?
Comment: well when I try it on 7 1/2 I get 7 .5.5.5 so I believe its true in that case, just not sure if thats the generalized outcome
Answer: A general solution should be like below which should use a lambda function in the replacement part of re.sub.
>>> import re
>>> from __future__ import division
>>> s = "7 1/2"
>>> re.sub(r'(\d+)/(\d+)', lambda m: str(int(m.group(1))/int(m.group(2))), s)
'7 0.5'
>>> re.sub(r'(\d+)/(\d+)', lambda m: str(int(m.group(1))/int(m.group(2))), '7 9/2')
'7 4.5'

Update:
>>> re.sub(r'^(\d+)\s+(\d+)/(\d+)$', lambda m: str(float(int(m.group(1)) + int(m.group(2))/int(m.group(3)))), '7 9/2')
'11.5'

Comment: Thanks, how would you add the converted fraction part back to the integer though? "7 1/2" should be "7.5" and "7 9/2" should be "11.5"
Answer: As an alternative to regex, if you always have a single number per string, and the fractional part is separated from the whole number part by whitespace, you could use the fractions module to perform a conversion:
from fractions import Fraction

for s in '7 1/2', '1 33/66', '22 21/22', '123', '123.45':
    f = sum(Fraction(x) for x in s.split())
    print(float(f))

Output

7.5
1.5
22.9545454545
123.0
123.45

Python regex fractions


Create Django Authentication using Amazon Cognito

Question: I am trying to run my Django login and signup authentication using Amazon Cognito and all other services using default database.
But I am not able to find any suitable example for that.
I have followed the following documentation. But didn't get any success.
https://github.com/labd/django-cognito-jwt
I am usinng the following libraries:
Django==4.1.7
djangorestframework==3.14.0
django-cognito-jwt==0.0.4
Can anyone please help me in this?
Thank you.
Answer: https://python-social-auth.readthedocs.io/en/latest/
https://python-social-auth.readthedocs.io/en/latest/backends/cognito.html
Try out the cognito backend for this library, it has integration with django rest framework out of the box, and takes care of all the user management for you.
Comment: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/34665623)
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).


Buying a house that has a natural spring flowing through the basement out to a pond. What to do?

Question: My husband and I are looking to buy a house from the 1800's and there is a natural spring in the basement that is stone trenched (open) out to an attached pond in the yard.
The current owners put plexiglass over the trench inside (We assume, because of moisture issues the open trench caused in the basement).  The plexiglass does have a lot of condensation on it.
What are the concerns with a trench like this and it being covered?
Do you think the moisture is still of concern?
Should the plexiglass have vents in it Or is there enough venting with it flowing to an outside trench?
Also, are there concerns of little critters or snakes attracted to this space?
Any experience towards owning a house with an open spring is greatly appreciated!  we're not sure if this is a deal breaker.
Comment: Is possible to speak with the previous owners and ask them about any of your concerns.
Comment: Would check house for rot and mould, before anything else, by a professional home inspector.
Comment: Might give you a nice option for a ground source heatpump, depending on the spring flow-rate.
Comment: Are you sure it's condensation and not mist?   For condensation to occur, the plexiglass needs to be colder than the water and since it's a ground water, that doesn't seem likely.
Comment: If I were you I definitely would buy a good moisture meter, and as you're inspecting the home, poke it anywhere that shouldn't get wet to make sure it isn't.  And if you do end up buying the home, repeat this process periodically.  Since this house has a source of water intrusion most don't, it could also have moisture problems that most inspectors won't know to look for.  But since the house has been standing so long, those problems are probably not deal-breakers and can be mitigated as long as you know about them.
Answer: Would not (in concept) be a deal-breaker for me. Specific case might vary with detailed examination.
If you want to go high-falutin' Frank Lloyd Wright's Fallingwater had a spring in the entryway as well as being built over a stream (can't do that in new construction...)
The one you are looking at probably served as basic refrigeration and drinking water supply when built - stick the milk cans in the trough of cool water.
Critter control would normally be (this era) by having stainless steel screen that the water flows out through, but critters don't come upstream through.
I would not "vent" the covering to the house - that would defeat the point of having the covering.
Answer: My uncle had a house like this.  Big spring too, several hundred gallons a minute. My recollection was that it was an easily visible current 4 feet wide and 10 inches deep.
Being in a warm climate, it was uncovered.  About 20 feet of it was in the house.  He had a window that was framed only on 3 sides with the unframed side an inch below the water level.  Outside it ran through a series of trout ponds.  Now and then a trout would come inside.
In theory it could have allowed critters that swim well (beaver, muskrat, skunk, raccoon, rat) to come in.  Don't recall him mentioning that.  He wanted the path under the glass to be free of obstruction in case one of the grandkids fell into the stream.  Didn't want them pinned to a screen by the current.


GET parameter value contains comma, netty encodes it - breaking the service

Question: I'm consuming a Weather.com web service which takes a "latitude,longitude" value (e.g. "40.87601089477539,-87.43512725830078") and using Netty to handle the network communication.
The service responds with an error, which is caused by my parameter value's comma being escaped (i.e. "40.87601089477539%2C-87.43512725830078").
# works (when a confidential API key is added)
http://api.weather.com/v2//location?geocode=40.87601089477539,-87.43512725830078

# doesn't work
http://api.weather.com/v2//location?geocode=40.87601089477539%2C-87.43512725830078

The escaping is done in in com.ning.http.client.RequestBuilderBase.toUrl(boolean encode). If I was able to pass false to it then my problem would be solved but it is the Netty library that makes a callout to this method rather than me, and the option is hard-coded.
1) Is there a workaround for Netty consumers? 2) What's the right way to fix this?
EDIT Additional details
Stack trace:
RequestBuilderBase$RequestImpl.toUrl(boolean) line: 166
RequestBuilderBase$RequestImpl.getUrl() line: 118
RequestBuilderBase$RequestImpl.<init>(Request) line: 78
RequestBuilder(RequestBuilderBase<T>).<init>(Class<T>, Request) line: 323
RequestBuilder.<init>(Request) line: 42
NettyAsyncHttpProvider$HttpProtocol.handle(ChannelHandlerContext, MessageEvent) line: 2115
NettyAsyncHttpProvider.messageReceived(ChannelHandlerContext, MessageEvent) line: 1128
NettyAsyncHttpProvider(SimpleChannelUpstreamHandler).handleUpstream(ChannelHandlerContext, ChannelEvent) line: 75
DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline$DefaultChannelHandlerContext, ChannelEvent) line: 564
DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(ChannelEvent) line: 792
ChunkedWriteHandler.handleUpstream(ChannelHandlerContext, ChannelEvent) line: 141
DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline$DefaultChannelHandlerContext, ChannelEvent) line: 564
DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(ChannelEvent) line: 792
HttpContentDecompressor(HttpContentDecoder).messageReceived(ChannelHandlerContext, MessageEvent) line: 100
HttpContentDecompressor(SimpleChannelUpstreamHandler).handleUpstream(ChannelHandlerContext, ChannelEvent) line: 75
DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline$DefaultChannelHandlerContext, ChannelEvent) line: 564
DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(ChannelEvent) line: 792
Channels.fireMessageReceived(ChannelHandlerContext, Object, SocketAddress) line: 296
HttpClientCodec$Decoder(ReplayingDecoder<T>).unfoldAndFireMessageReceived(ChannelHandlerContext, Object, SocketAddress) line: 600
HttpClientCodec$Decoder(ReplayingDecoder<T>).callDecode(ChannelHandlerContext, Channel, ChannelBuffer, ChannelBuffer, SocketAddress) line: 584
HttpClientCodec$Decoder(ReplayingDecoder<T>).messageReceived(ChannelHandlerContext, MessageEvent) line: 445
HttpClientCodec$Decoder(SimpleChannelUpstreamHandler).handleUpstream(ChannelHandlerContext, ChannelEvent) line: 75
HttpClientCodec.handleUpstream(ChannelHandlerContext, ChannelEvent) line: 92
DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline$DefaultChannelHandlerContext, ChannelEvent) line: 564
DefaultChannelPipeline.sendUpstream(ChannelEvent) line: 559
Channels.fireMessageReceived(Channel, Object, SocketAddress) line: 268
Channels.fireMessageReceived(Channel, Object) line: 255
NioWorker.read(SelectionKey) line: 94
NioWorker(AbstractNioWorker).processSelectedKeys(Set<SelectionKey>) line: 372
NioWorker(AbstractNioWorker).run() line: 246
NioWorker.run() line: 38
ThreadRenamingRunnable.run() line: 102
DeadLockProofWorker$1.run() line: 42
ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1142
ThreadPoolExecutor$Worker.run() line: 617 [local variables unavailable]
Thread.run() line: 745 [local variables unavailable]

Comment: I do not think Netty library itself depends on com.ning.http.client. But Ning is using Netty as one of its http layer.
Comment: Hmmm, I'll take a closer look at my stack trace. ning appears deeper in the stack trace than netty but perhaps that is callback-related. Thanks for the reply.
Comment: I am not netty expert, but I was just thinking why not making a little function/method to convert % to , and get it to works?
Answer: To answer my own question, none of the public libraries are to blame here. There is a flag you can set to prevent the encoding (setUseRawUrl(true)):
AsyncHttpClient asyncHttpClient = new AsyncHttpClient(
    new AsyncHttpClientConfig.Builder()
        .setUseRawUrl(true)
        .build());
Future<Response> f = asyncHttpClient.prepareGet(url).execute();
Response r = f.get();


Ellipse equation which lies on $x=y$

Question: How do I write an ellipse equation which lies on the line $x=y$?
I know its vertex are $(\pm3\sqrt{2},\pm3\sqrt{2})$ and $(\pm\sqrt{14},\mp\sqrt{14})$. Also, its center is the origin. But certainly, when I plot
$$\frac{x^2}{18}+\frac{y^2}{14}=1$$
it lies on $x$-axis.
Comment: You have to rotate it 45 degrees. See here if it helps: https://www.youtube.com/watch?v=h9OWnuarYuc
Comment: Doing so requires a mapping from $x$ to $x\cos\theta-y\sin\theta$ and $y$ to $x\sin\theta-y\cos\theta$
Comment: @Gordon that's what I thought. But how am I able to do it?
Answer: An ellipse rotated by $45^\circ$ like this has an equation of the form:
$$A(x-y)^2+B(x+y)^2=1$$
Now you can just substitute the $(x,y)$-coordinates of the vertices to find $A$ and $B$. You will find that they have a very simple form.
Note that the axes are not $\sqrt{18}$ and $\sqrt{14}$, as you might expect; the distances of those vertices from the origin are multiplied by $\sqrt2$ by the rotation. So your equation
$$\frac{x^2}{18}+\frac{y^2}{14}=1$$
actually defines a smaller ellipse.
Comment: @mvfs314: Substitute $(x,y)=(\sqrt{14},-\sqrt{14})$ into the equation $A(x-y)^2+B(x+y)^2=1$. This will give you $A$. Now substitute $(x,y)=(3\sqrt 2,3\sqrt 2)$: this will give you $B$.
Comment: What I got was: the equation on the $x=y$ axis, is $$\dfrac{x^2}{36}+\dfrac{y^2}{28}=1$$ But when I triy to change the variables to using $x\cos45º-y\sin45º$ and $-x\sin45º+y\cos45º$, it doesn't work.

Ellipse equation which lies on $x=y$


Should html links with images have both title and alt attributes?

Question: I understand it is generally a best quality practice to have title tags for hyperlinks and alt tags for images. This is good for several reasons: additional information for low bandwidth users, additional information for assistive technologies, better display of search results from search engines, etc.
My question is when an image is a hyperlink, i.e.

Should that be done with the a title attribute

or with the img alt tag

or with both

or with both having both

Moved here from the qa site.  closed there.
Comment: I have a family member who is blind and her screen-reader uses the alt tags to describe the images (not the title tag).  She hates it when she browses to sites and can't navigate them because they don't have alt tags, it make the site unusable to her.
Comment: Related: [What should the ALT text be for an image that is also a link?](http://ux.stackexchange.com/q/48754/17023)
Answer: Both of them
However, the alt description in the image should be for the link description, not for the image itself
From Accessibility and Usability at Penn State: Image ALT Tag Tips for HTML

term "ALT tag" is a common shorthand term used to refer to the ALT
attribute within in the IMG tag.

Any time you use an image, be sure to include an ALT tag or ALT text
within the IMG tag. Doing so will provide a clear text alternative of
the image for screen reader users. WCAG 2.0 Guideline 1.1.1.—"All
non-text content that is presented to the user has a text alternative
that serves the equivalent purpose."

The description in the ALT tag

should be meaningful in the context of the Web page, specifically:

Images used as links should have alternative (or "alt") text
describing the destination of the link, not the image itself.

Alt text

with acronyms should be written with spaces in between letters. For
instance, <alt="I T S at P S U" > (read by a screen reader as "ITS at
PSU") is preferable to <alt="ITS at PSU" > (read as "It's at Sue").

Images used as spacers or in toolbars should have an empty ALT tag
(i.e. <alt="" >). Screen readers will simply skip over images with
empty ALT tags.

Images that already include a text description within

the main text of the page can have a summary ALT tag.

If you want to

provide a tooltip for visual browsers, use the TITLE tag in addition
to the ALT tag, since it is supported in most browsers. For example:

While there is no official length restriction on the length of alt
text, many experts recommend 125 characters or fewer because of
restrictions within the JAWS screen reader. Many versions of JAWS
break up longer text tracts into blocks of 125 characters, which can
be confusing to users.

For an especially complex image, such as a

chart, equation or diagram, a link to an extended text description
should also be included.

Images that are used as buttons or labels

should use fonts that are readable to a large segment of the audience
(probably 12 pixels/point or larger).

In some cases you can replace

decorative or layout-related images with styled HTML elements, such as
HRs or DIVs, for which you change background colors and specify
background images.

The article above clearly explains the alt usage on image links. However, the title part is incomplete in the original article, but you should use both, because one of them will help you with assistive technologies and accessibility , while the title on links will help you with this, but also with better readability and SEO.
Additional concerns
On top of the above, you should never rely on title only, see The title attribute

Relying on the title attribute is currently discouraged as many user
agents do not expose the attribute in an accessible manner as required
by this specification (e.g. requiring a pointing device such as a
mouse to cause a tooltip to appear, which excludes keyboard-only users
and touch-only users, such as anyone with a modern phone or tablet).

but... by no adding it, you get this:

If this attribute is omitted from an element, then it implies that the
title attribute of the nearest ancestor HTML element with a title
attribute set is also relevant to this element. Setting the attribute
overrides this, explicitly stating that the advisory information of
any ancestors is not relevant to this element. Setting the attribute
to the empty string indicates that the element has no advisory
information.

In short
You must use both elements whenever possible, but there are some specifications and special rules you should follow
Answer: I disagree on the title element. I believe the case you state where it would  take the title attribute of the nearest ancestor HTML element with a title attribute is not common. The best solution in this case would be to remove the title attribute from the nearest ancestor as well.
Drawbacks of the title element:

Only available to visual users
Not available to tablet/mobile users
If an alt attribute (for images) is in place or text is used in other places like links or buttons then the information is redundant
Title texts don't work with keyboard navigation
Title texts require users to guess whether it needs to be hovered over


strange iphone os4.0 error while quitting application

Question: I have updated to xcode 3.2.3 iphone os sdk 4.0. now when application enters in background state and when i double tap home screen to quit the bg running app. I receive Kill in gdb.
Does some one knows about it ?
Answer: If your quit app app it's no longer running, so GDB get KILL signal, nothing wrong..
Comment: Thanks Nyxem. Now i got another problem I have Added "UIApplicationExitsOnSuspend" key into the info.plist but the app doesn't exit do you know how to quit app when user presses home button in iOS 4.0 ?


Dark Souls Upgrade to "Prepare To Die"-Edition (PS3)

Question: I own the PS3-version of Dark Souls and have already played it for some time. Now I would like to get the DLC "Artorias of the Abyss", but instead of downloading it, I would like to purchase the "Prepare To Die"-Edition, mainly for its extra content.
The questions are:
Does the "Prepare To Die"-Edition install seperately from the original game or does it integrate?
Does the PtD-Edition install a seperate trophy set?
And most importantly: Can I still use the saves that I already have in the game?
Thanks in advance for any answers.
Answer: From the information I have seen,  the Prepare to Die edition creates a new save that does not access the old save.  This means it does not delete old save but does not access the old save either.  You best bet for continuing from your save data is just to download the DLC.
But here is a forum where they are asking the same question.
Do save files and trophies carry over to 'Prepare to Die' Edition?
Comment: well, most of the answers in the forum thread you linked say that it's not working so they oppose what you're saying, but they may not be reliable. Do you have experience with this yourself? Also, I have the German USK-version if that makes any difference.
Comment: Yeah the more digging I did it seems there are mixed results depending on the region of the game.  In my experience the save did transfer over.  I am unsure what region though mine was because it was a while ago.  But a lot of places are just saying if you download the DLC that it definitely is ok and can continue off your same save.  So maybe that would be the safer route for you?
Comment: yes, I knew that downloading the DLC should work, but that's not really what I wanted to do. The PtD-Edition has become quite cheap and includes things I'd like to have such as an artbook and the soundtrack, so it seems more worth the money than just downloading. That aside, I have a UK-PSN-account which makes it likely that it won't work with my disc version. Did you have both disc versions when you transferred your saves or the downloaded DLC?
Comment: I just went back and checked my discs and I was mistaken, I had re-bought the original disc and downloaded the DLC.  From what I was reading on some other reviews is that the Prepare to Die edition doesn't access the same save.  So it won't overwrite the old save from the original but it will not transfer to the Prepare to Die edition.  Edited my answer to include what we have discussed.
Comment: Yes, I searched some more as well and for most people it doesn't seem to work. It seems I'll have to download it then. Thanks for taking the time to help me, anyway. I'll keep this as unanswered for people to confirm it who tried it themselves.


How to send values from inputs to AutoLogin class in Liferay

Question: I am developing a LinkedIn login hook following this example but I got stuck at passing parameters from my .jsp file to the .java class implementing AutoLogin.
If I write a portlet, the values are sent correctly to a processAction method, however here the same approach is not working.
In my linkedin.jsp file i have the following (simplified) structure.
<%
PortletURL linkedInRegiserURL = renderResponse.createActionURL();
linkedInRegiserURL.setParameter(ActionRequest.ACTION_NAME, "linkedInRegister");
%>

<form id="linkedInForm" action="<%= linkedInRegiserURL.toString() %>" method="post"
        name='<portlet:namespace/>linkedInForm'>
    <input type="hidden" name='<portlet:namespace/>email' id="email" />
</form>

And then inside a javascript method, based on the LinkedIn API, I populate my input and then submit the form.
document.getElementById('email').value = member.emailAddress;
document.getElementById('linkedInForm').submit();

Everything is fine here. The problems start inside the login() function in my LoginHook implements AutoLogin class. If I do a print test, the following results are shown:
@Override
public String[] login(HttpServletRequest request,
        HttpServletResponse response) throws AutoLoginException {

    String email1 = ParamUtil.getString(request, "email");
    String email2 = request.getParameter("email");
    String email3 = request.getAttribute("email").toString();

    System.out.println("email1 : " + email1); //empty value
    System.out.println("email2 : " + email2); //null
    System.out.println("email3 : " + email3); //null

    //etc.
}

I guess that the problems start here <form id="linkedInForm" action="<%= linkedInRegiserURL.toString() %>", but I am not sure and I don't know how should I pass my email parameter.
PS: I am working with Liferay 5.2.3, so writing a class extending BaseStrutsPortletAction is out of the question.
Comment: Is linkedin.jsp your custom jsp? Where is it placed? Is it part of jsp hook or entirely new custom portlet?
Comment: Yes, it is my custom jsp, part of my authentication-hook. It is included in `navigation.jspf` like this : `

     <%@include file="/html/portlet/login/linkedIn.jsp" %>

`
Comment: Ok, can you try this. Can you manually hit the URL in browser something like this and see if your AutoLogin class gets it. The format would be something like this http:/firstname.lastname@example.com
Answer: Params Inside login hooks in Liferay are a bit tricky, you can try 2 things:
Use the following function  to retrive the "real" request wich may contains your parameter (Although I´´m not really sure if it´s available in liferay 5.2.3, in Liferay 6 its works):
PortalUtil.getOriginalServletRequest((javax.servlet.http.HttpServletRequest request)
Try with a GET call , instead a POST.
Another way to do it is to save the email as a cookie( in javascript) and then recover it in the autologin hook.
Hope it do some help...


Jquery/Javascript - add a callback to my small function, apply that specific callback only when i choose to

Question: When i launch the scrollMyScreen function, i want to be able to SOMETIMES call a callback(which i want to be my flashArrow function), which i thought would look something like: scrollMyScreen(flashArrow()), but obviously that doesn't work. my flashArrow function will actually be bigger than just an alert, this is just for example.
function scrollMyScreen() {
    $('body').delay(600).animate({scrollTop: $(target).offset().top}, 1000, callback)
}

function flashArrow () {
    alert('FLASHING ARROW!')
};

So, what can I do to make this work? I want to call scrollMyScreen, and then sometimes add the function flashArrow() as it's callback, or, to happen once scrollMyScreen is done.
example case:
case "header":
    scrollMyScreen()
    break
case "wrapper":
    scrollMyScreen(flashArrow())
    break

Answer: You need to pass a reference to flashArrow, not the result of calling flashArrow():
case "header":
    scrollMyScreen();
    break;
case "wrapper":
    scrollMyScreen(flashArrow);   // change here
    break;

(and don't forget to declare the callback parameter to scrollMyScreen() too!)
Comment: thanks man, hey, could what i'm asking for also be accomplished if i turned scrollMyScreen and flashArrow into variables instead of functions?
Comment: A variable can only be "called" if it's value is a reference to a function.  So you still have to declare them just like you have now.
Answer: var callback = null;

switch(something) {
    case "wrapper":
        callback = flashArrow;
        break;
    case "somethingElse":
        callback = flashSomethingElse;
        break;
}

scrollMyScreen(callback);

function scrollMyScreen(callback) {
    $('body').delay(600).animate({scrollTop: $(target).offset().top}, 1000, callback);
}

Answer: function scrollMyScreen(callback) {
$('body').delay(600).animate({scrollTop: $(target).offset().top}, 1000,
                              typeof(callback) == "function" ? callback : null);
}

You can then call:
scrollMyScreen(someFunction);

or:
scrollMyScreen();

Update: Fixed callback null issue
function scrollMyScreen(callback) {
if (typeof(callback) == "function")
    $('body').delay(600).animate({scrollTop: $(target).offset().top}, 1000, callback);
else
    $('body').delay(600).animate({scrollTop: $(target).offset().top}, 1000);
}

Comment: Hey, can you explain why the `typeof(callback)...` part is needed? if i just have `scrollMyScreen();` it doesn't work, i need to add null: `scrollMyScreen(null);` in my code now i have a callback and a yoffset: `scrollMyScreen(yOffset, callback)`, i tried your code but it didn't keep me from having to add Null if i don't declare the callback or yoffset.
Comment: I fixed the problem. The typeof(callback) will return "function" if a function is passed and "undefined" if nothing is passed. The logic in scrollMyScreen ensures that the correct jQuery call is made based on the presence or absence of the callback parameter.


Java - inheritance

Question: class Base
{
        int x=1;
    void show()
    {
        System.out.println(x);
    }
}
class Child extends Base
{
    int x=2;
    public static void main(String s[])
    {
        Child c=new Child();
        c.show();
    }
}

OUTPUT is 1.
The method show is inherited in Base class but priority should be given to local variable and hence the output should have been 2 or is it that the compiler implicitly prefixes super before it??
Comment: Polymorphism does not apply to fields.
Answer: No, it's because the Child didn't override the show() method.  The only one available is the one from Base, which displays its version of x.
Try it this way - it'll display 2:
class Base
{
        int x=1;
    void show()
    {
        System.out.println(x);
    }
}
class Child extends Base
{
    int x=2;
    public static void main(String s[])
    {
        Child c=new Child();
        c.show();
    }
    void show()
    {
        System.out.println(x);
    }
}

Answer: With one Show Method
class Child extends Base
{
    public Child(int x)
    {
        super(x); // Assumes a constructor in the parent that accepts an int.
        // or
        super.x = x;
    }
}

Then you will only need the one show() method.
With Two Show Methods
You override the functionality of the superclass, in it's child classes, as follows:
class Child extends Base
{
    public void show()
    {
       // OVerrides the code in the superclass.
       System.out.println(x);
    }
}

Which should you prefer?
You're trying to override functionality, so you should favour the second option.
Answer: Since you are not overriding the show method in Child, the Base's version will be used. Therefore it cannot see the x variable you defined in Child. Your IDE (if you are using one) should give you a warning that you are "hiding a field".
You can achieve the expected functionality by setting the x of a Child object after instantiating it. Try:
class Base
{
    int x = 1;

    void show() {
        System.out.println(x);
    }
}

class Child extends Base
{
    public static void main(String s[]) {

        Child c = new Child();

        c.show();
        c.x = 2;
        c.show();
    }
}

This should yield 1 and then 2.
EDIT: Note this works only when the x field is accessible from the main function.
Answer: Base class doesn't know about Child class, so the show() method will never call the variable from it's subclass.
So, if you want to show the x from the subclass override the show() method by reimplementing it in the Child class.

Java - inheritance


Solar powered thermal ballast - is it feasible?

Question: My living room gets plenty of sun from big, west facing windows. As the cold weather is approaching, I wanted to make a device that leveraged this exposure to sunlight to store some energy and slowly release it through the night.
The initial idea was to have a solar panel, battery for electrical energy buffer, some sort of aquarium heater, and a water tank.
Water would be heated by the aquarium heater, which would be powered by the solar panel and battery through the night (as long as the battery lasts). This setup would slowly release the water's heat to the living room.
Will this be more efficient than having just a water tank painted black next to the window? The sun would heat it pretty well during the day, and the solar panel+battery+heater might not be much more efficient, if at all.
Comment: Trying to capture solar energy with photovoltaic panels and storing it in batteries will be so much less efficient than directly storing the energy in water. I'd think more along the lines of a solar water heater and then coupling the tank to a radiator.
Comment: @brhans but would that be reasonably compact and self-contained?
Comment: The amount of energy you'd store with PV in a small self-contained unit will be negligible. You would need a huge PV array and battery bank to store enough energy to power any sort of heater.
Comment: a tank has little surface area in which to absorb heat, no matter the color. it cannot be aimed to track either. electricity gets converted to heat at 100% efficiency, and PV cells can be easier to optimally place. all in all, it's a close call that depends on specifics instead of generalizations. Solar hot water would be much _cheaper_, but both could be (in theory) feasible.
Comment: @Steve: storing the energy thermally, no batteries or lossy DC conversion/controls needed...
Comment: @brhans he is not proposing to use PV to make heat, which is inherently moronic.  He is proposing to use it to circulate water, which he aims to use to store heat.
Comment: @Harper - "a **solar panel**, battery for electrical energy buffer, some sort of **aquarium heater**, and a water tank" - how is this *not* using PV to make heat?
Comment: @brhans it makes more sense if you're familiar with solar thermal systems.  The key element is the water tank.  If he's planning to electrically heat from PV, there'd be no reason for the water.  He means to use the water for the thermal storage not battery.
Comment: edited the question to better rephrase the idea.
Comment: The question is very unclear.  It specifically says "Water would be heated by the aquarium heater, which would be powered by the solar panel and battery...". Do you really mean to use a solar panel to generate electricity, which will be used to heat the water?  Or do you mean to use a solar water heater and use the solar panel just to power a pump to circulate the water. If it's the first option, it simply makes no sense.
Answer: Any dark colored mass would become a passive solar heater for when the sun goes away and the room begins to cool. The mass could be as simple as concrete blocks, tiles or as costly as eutectic tube solutions. Years ago,I was interested in solar systems  (I was years ahead in my imagination and thinking), and these were common ideas that were studied and written about. Before you give your brain an overload go to the local book store or library and read and study books on passive solar ideas. You will be amazed at the ideas people had to gather solar energy and use it at a later time. "Hope this helps".
Comment: When writing the question I started to think about these solutions..are there any specific web spots you can recommend?
Comment: "google" passive solar heating; www.WBDG.org; energy.gov; www.yourhome.gov-- just to name a few.
Comment: While you are at it, buy yourself the "Mother Earth News" DVD with their last 40 years of issues. Search for solar projects and read them. To make this worthwhile you will need a lot of panels and a lot of water depending on the size of your house. An aquarium heater is not going to get it. Check the wattage on one and convert that to BTU's and see what a small dent you will make in your heating load. A standard gas furnace puts out about 100,000 BTU's per hour. If you just want to warm some fish that might work.
Comment: Many years ago, I designed an air to air switching to air to water heat-pump system. The water would be used at night, be allowed to freeze,(144btu/lb. in conversion) and be reheated by solar collectors the next day. Geo-thermal systems shot that idea out the water. Radical thoughts can become the start of a better idea at a future time. The geo system is so much better and much more simple than my idea. Use your brain, try things, fail a few times and you may discover a great way enhance your life.
Comment: You'd want water, not some heavier object.  You'd think a hyper-dense slug of metallic uranium would be the most heat storage per cubic foot.  Actually, uranium is terrible compared to water. It's because of what heat is.  The energetic excitement of *atoms*.  Heat storage is loosely a function of the number of atoms present!   So a uranium atom has no particular advantage over a hydrogen atom, and water is the ideal heat storage because it fixes a lot of hydrogen in a dense, pumpable liquid.


Javascript closures with google geocoder

Question: i still have some problems with javascript closures, and input/output variables.
Im playing with google maps api for a no profit project: users will place the marker into a gmap, and I have to save the locality (with coordinates) in my db.
The problem comes when i need to do a second geocode in order to get a unique pairs of lat and lng for a location: lets say two users place the marker in the same town but in different places, I dont want to have the same locality twice in the database with differents coords.
I know i can do the second geocode after the user select the locality, but i want to understand what am i mistaking here:
// First geocoding, take the marker coords to get locality.
geocoder.geocode(
  {
    'latLng': new google.maps.LatLng($("#lat").val(), $("#lng").val()),
    'language': 'it'
  },
  function(results_1, status_1){
    // initialize the html var inside this closure
    var html = '';
    if(status_1 == google.maps.GeocoderStatus.OK)
    {
      // do stuff here
      for(i = 0, geolen = results_1[0].address_components.length; i != geolen)
      {
        // Second type of geocoding: for each location from the first geocoding,
        // i want to have a unique [lat,lan]
        geocoder.geocode(
          {
            'address': results_1[0].address_components[i].long_name
          },
          function(results_2, status_2){
            // Here come the problem. I need to have the long_name here, and
            // 'html' var should increment.
            coords = results_2[0].geometry.location.toUrlValue();
            html += 'some html to let the user choose the locality';
          }
        );
      }
      // Finally, insert the 'html' variable value into my dom...
      //but it never gets updated!
    }
    else
    {
      alert("Error from google geocoder:" + status_1)
    }
  }
);

I tryed with:
  // Second type of geocoding: for each location from the first geocoding, i want
  // to have a unique [lat,lan]
  geocoder.geocode(
    {
      'address': results_1[0].address_components[i].long_name
    },
    (function(results_2, status_2, long_name){
      // But in this way i'll never get results_2 or status_2, well, results_2
      // get long_name value, status_2 and long_name is undefined.
      // However, html var is correctly updated.
      coords = results_2[0].geometry.location.toUrlValue();
      html += 'some html to let the user choose the locality';
    })(results_1[0].address_components[i].long_name)
  );

And with:
  // Second type of geocoding: for each location from the first geocoding, i want to have
  // a unique [lat,lan]
  geocoder.geocode(
    {
      'address': results_1[0].address_components[i].long_name
    },
    (function(results_2, status_2, long_name){
      // But i get an obvious "results_2 is not defined" error (same for status_2).
      coords = results_2[0].geometry.location.toUrlValue();
      html += 'some html to let the user choose the locality, that can be more than one';
    })(results_2, status_2, results_1[0].address_components[i].long_name)
  );

Any suggestion?
EDIT:
My problem is how to pass an additional arguments to the geocoder inner function:
function(results_2, status_2, long_name){
    //[...]
}

becose if i do that with a clousure, I mess with the original parameters (results_2 and status_2)
Comment: First thing that comes to mind is to make sure the second set of callbacks are even being called by using console.log. Also, even though you are running the second set of geocodes in order, it's not guaranteed the function callbacks will run in order. If appending to the html variable worked, it could be out of order. Just something to think about.
Comment: Yes, i removed all console.log before posting the code.
Anyway, what you mean with the order issue? I know requests are asyncronous, but (i guess) the second geocode is into the first one, so it should never be executed before the first one. Am i mistaking?
Answer: If I'm understanding you correctly:
Your problem in the first example is that the second (innermost) geocode's callback function (which appends the string to html) will not have executed by the time you reach the line with the comment Finally, insert the 'html' variable value into my dom....
You are effectively launching the second geocode request, and then inserting html before the operation has completed.

Regarding passing an extra argument to the callback, you could always make a function that creates and returns a function:
eg.

function(my_argument)
{
return(function(cb1,cb2) { ... });
}(my_argument_value);

Then you can pass in whatever you want for my_argument_value, and the innermost code (...) will see it as well as the two callback args.
The return value of this function is what you pass as the callback to the geocode call.
Comment: No, the innermost geocode IS executed correctly, the problem is to let it populate the `html` variable that is outside it (and i do this with the clousure); But then, the problem is to pass it the `results_1[0].address_components[i].long_name` variable.
Comment: Ok - I edited the answer... hope this is what you're looking for.


How to validate a musical note with regex

Question: I am trying to validate user input that should be a valid note. In music, notes are letters A-G and can be either sharp(#) or flat(b). Notes don't have to be sharp or flat, they can be natural. Why is this regex not matching the # or b in any of the notes?  Here is a regex101 demo.
([A-G]{1})(\#|b{1})?

Here is a list of all inputs that should match:
A
A#
Ab
B
Bb
C
C#
Cb
D
D#
Db
E
Eb
F
F#
Fb
G
G#
Gb

P.S.  E# and B# don't exist in music, so I'll have to program that into my code.
Answer: Your regex:
([A-G]{1})(\#|b{1})?

Is correct.
To make your demo work, you need to remove the x modifier, as it affects # chars (it is a confusing modifier, actually). When you remove it, it shows your regex works (updated demo here).
About the x modifier:

x modifier: Ignore whitespace
This flag tells the engine to ignore all whitespace and allow for comments in the regex. Comments are indicated by a starting "#"-character.

Now, if I may, you can simplify it by removing those {1}, they are redundant (they default is match once already). Also, as noted by CSᵠ (see comment below), that # doesn't need escaping and then \#|b could become [#b]:
([A-G])([#b])?

Of course, if you don't need to match the note (the first group) or the sharp/flat symbols (the second group) individually, you can remove parentheses as well.
Other than that, you can add the gm modifiers to test multiple lines: DEMO here.

Bonus:
You don't have to program, you can not match E# and B# using regex only:
(?![EB]#)([A-G])([#b])?

This demo shows it working. The (?! ... ) is known as negative lookahead.
Comment: maybe also note that `#` doesn't need escaping and then `\#|b` could become `[#b]`
Comment: @CSᵠ yes, that's right! I completely overlooked that! Thanks!
Answer: You must need to include anchors and also you have to enable multiline modifier m.
^([A-G]{1})(\#|b{1})?$

or
^[A-G][#b]?$

DEMO
Comment: I am currently testing this in regex101.  I included a link to it.  They include the anchors for you.
Comment: enable `m` modifier. And no, they won't include anchors check https://regex101.com/r/oO8bU5/4


Does a block of coal or 9 pieces of coal last longer when smelting?

Question: Which item can be used to smelt more items, or are they the same? I know 1 piece can smelt 8 times, and 9 pieces can make one block. But is there a difference?
Answer: A block of coal lasts 80 items. It is therefore more efficient to use coal blocks compared to using 9 individual pieces, which would only yield 72 items.
For reference, a bucket of lava yields 100 items.
Comment: Reality is, you waste a LOT more coal unless you always remember to put in exactly 80 items.  If you accidentally drop in 81 to 99 items, you will burn two entire blocks of coal for only 99.  If you use coal pieces, at most you'll waste 7 charges.
Comment: note: You get your iron buckets back if you use lava.  They really are the best because it smelts the stack of 99 almost with no waste (1% wasted)
Answer: Even though a block of coal is more effective than a 9 pieces of coal, it is worth noting that it can smelt up to 80 blocks, which is more than one stack of items, and therefore more than you can fit in the top slot of the furnace.
You will need to put a hopper on top of the furnace to make sure everything gets smelted, unless you want to camp in front of it and manually add items.
A major difference is that fuel, once "ignited", will be used even if there is no item on top. Which means that if you want to cook 8 items, go somewhere, cook 8 more, leave again, cook 8, and so on, the pieces of coal are more efficient, since only one piece at a time will be consumed, whereas the block of coal would still burn when you're not smelting anything.


RIGHT FRONT BURNER DOESNT STAY LIT

Question: DELONGHI DEFSGG36SS GAS STOVE
THE right front burner does not ignite automatically when the knob is turned.
It will light with a lighter. However, it does not stay lit when the knob is released.
Comment: Please don't shout at us. Edit the question title.
Comment: so, what's your question?
Comment: Probably dirty and needs fixing.  Seeing it is gas, I would get the professionals in.
Comment: The reason it won't light is probably the same root cause as it going out sounds like the valve needs to be cleaned.
Answer: From the pictures in the manual, it looks like there is a flame-out detector next to each burner.  If the burner lights OK, but won't stay lit, then the detector may have failed.
Answer: Your gas valve is failing, depending on "type of gas" regulates the size orifice the gas comes out of.

RIGHT FRONT BURNER DOESNT STAY LIT