Thumbnail gallery wizard navigation on selection

Question: I have doubt on my design related to thumbnail gallery wizard. Wizard has few pages consist of thumbnail images (10 images per page), where each gallery page has a question, and the answer would be to select one of the gallery image to proceed to the next question.On selection, the selected image marked as a circle as in below sketch.

I found out my navigation on each page have lacking usability since most of the users had a confusion where to click after selecting the thumbnail image. My navigation buttons are underneath the gallery.I appreciate your expertise comments/feedback/opinion on how to improve this.
Current gallery wizard,

Some suggestions as in below,

Do an auto navigation whenever user selection happened
Make the Navigation buttons on side by side (As in image carousal)

Also, I have doubt on the images,does it need zoom functionality on each image?
Comment: What is the user trying to achieve by using this wizard? Are they trying to assemble a collection for purchase?
Comment: This is online survey to identify users' style (this is basically design to help user to identify what style they are, ex: Modern, Classic, Contemporary, Urban, etc..) This will also a part of online marketing campaign which will provide the better understanding about the users choice based on their style.
Answer: Be explicit with the selection, so users can focus on what they just selected, and what to do next.
In your current site, there's a lot of graphic elements competing with each other. Right now, the background is the dominant element, with diagonal lines leading off the pages.
The header can also be lost as well.
If you have a say in the visual design, you could desaturate the background when a user selects their choice. (you can do this with css filters)
You can also make the question text stand out a bit more. Right now it's lost in the background.
Make it clear what they just selected by visual focus.
At the same time, you can use labels on the buttons to indicate steps. Currently they look more like a carousel swipe button, which is usually reserved for passively viewing content, not selection like you need for your use case.

By reducing the visual elements upon selection:

the user can clearly see their choice
the 'Next' button could 'light up', drawing their attention once they select
the button label explicitly tells them what to do
you could also have an 'unselect' link if you hover over the item to discard the selected chair choice

If you're concerned about visible navigation: an option.
This is a just a sketch, but you could also put both the question and navigation in the same header area. You'll just have to try a couple approaches to see if it might help with visibility.
Comment: Hi Mike, thanks for your detailed explanation. Yes I agreed the background is busy and dominating. Our marketing team push me to use this backgrounds based on their campaign the colours they have used in the magazines should vividly reflect on the backgrounds. De-saturate  is good thing I can consider as well as the other points highlighted. Thanks for your answers Mike.


Separate icons for Chromium and Hangouts in Unity (Ubuntu 16.04)

Question: I installed the Hangouts extension, but both hangouts and Chromium share the same entry in the Unity launcher, which makes it very difficult to switch between Chromium windows and chat windows (see image below)

Alse, when ALT-tabbing, window thumbnails are not very helpful:

Is there any way to isolate the Hangouts extension icon from the Chromium windows icon in Unity launcher?
Note: There's a similar question in Ask Ubuntu, but the accepted answer doesn't apply here (the config file is not present).
Answer: If you use the extension (not the separate app), you can add the icon by yourself.
So in terminal copy this command:
gedit ~/.local/share/applications/chrome-hangouts.desktop

And now paste this code and change the values with whatever your extension id is:
#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=Hangouts
Exec=/opt/google/chrome/google-chrome --profile-directory=Default --app-id=*extension_id*
Icon=*use_your_icon_path_here*
StartupWMClass=crx_*extension_id*

You can find your extension id by going to Tools>Extensions and from
here.
And this is the end result.
Edit:
The guide was for Chrome (since that's the one I use on my machine). For chromium I guess you just need to change the Exec=/opt/google/chrome/google-chrome into Exec=/usr/bin/chromium-browser --profile-directory=Default --app-id=*extension_id*
 for chromium (use another .desktop entry from the same path).
And the extension id is usually the same, but sometimes they update it and change it, the reason why just copy/pasting earlier answers wouldn't work.


Adding Windows 10 to Grub

Question: I've had a look at a few other questions here (such as GRUB does not detect Windows), however, many of the options that have been voted up don't work.
Currently my 40_custom file looks like the below (after a few different attempts):
#8AEC5322EC5307B9
menuentry "Windows 10" --class windows --class os {
   insmod ntfs
   search --no-floppy --set=root --fs-uuid 88F44DC9F44DB9E8
   #chainloader +1
   ntldr /bootmgr
}

When using this this I get the error cannot find command ntldr. if i comment out the above and change to chainloader +1 i get the error invalid efi file path.
I suspect the problem is that when I installed Windows 10, it was "kind" enough to use a different storage device to one I installed Windows on for the System Reserved location. I won't lie, I wasn't frilled at it's choice, but nevermind. As a result the boot files are on /dev/sda1 (with the ID 88F44DC9F44DB9E8) and Windows 10 itself is on /dev/sdb1. Ubuntu is installed on a nvme device.
os-prober doesn't detect Windows 10 (yes, both the partitions are mounted in ubuntu when I run it) and update-grub doesn't detect it either.
I can still boot to Windows 10 at least, however, to do it I need to hit Esc in grub and then type exit in the command line. I'll then be greeted with the Windows 10 logo.
Anyone any ideas here? I'm guessing I need to use a command like set root='(hd0,1)', but I'm honestly not sure which values need to go in for the parameters.
PasteBin link for boot-repair logs.
Relevant boot-repair section:
=================== Suggested repair
The default repair of the Boot-Repair utility would purge (in order to unsign) and reinstall the grub2 of nvme0n1p2 into the MBRs of all disks (except live-disks and removable disks without OS).
Grub-efi would not be selected by default because: no-win-efi
Additional repair would be performed: unhide-bootmenu-10s   fix-windows-boot

=================== Blockers in case of suggested repair
GPT detected. Please create a BIOS-Boot partition (>1MB, unformatted filesystem, bios_grub flag). This can be performed via tools such as Gparted. Then try again.
Alternatively, you can retry after activating the [Separate /boot/efi partition:] option.

=================== Advice in case of suggested repair
EFI detected. You may want to retry after activating the [Separate /boot/efi partition:] option.
Do you want to continue?

=================== Final advice in case of suggested repair
Please do not forget to make your BIOS boot on nvme0n1 (WDS500G2X0C-00L350) disk!

=================== User settings
The settings chosen by the user will not act on the boot.

Comment: We want the report, not any fixes. Just post link to the Summary report it gives. Boot-Repair may suggest fixes, but until reviewed do not run any. Almost all fixes are for Ubuntu as most Windows fixes need your Windows repair flash drive.
Comment: Install and run boot-repair: https://askubuntu.com/questions/1104855/how-to-make-grub-menu-appear-instead-grub-minimal-bash-like-in-booting/1105737#1105737
Comment: Will that have an adverse effects on the Ubuntu install? What does the above actually do?
Comment: As @oldfred alludes you can run boot-repair to do a report only with no fixes. Run this option. I'm hoping the report will tell us why Windows 10 is not being added to grub menu. The report will also list the fixes it **would perform** if the option to fix grub (and other issues) was chosen.
Comment: Thanks both. @oldfred , you can find the logs on [PasteBin](http://paste.ubuntu.com/p/dPYJmhTFCv/)
Comment: I've updated your question with the relevant boot-repair recommendations. CC: @oldfred (a little above my paygrade :))
Comment: Report does not show NVMe drives yet, as completely as SATA drives. You show no Windows UEFI boot entry and sda looks like it was converted from gpt to MBR. Windows only boots from MBR with BIOS, and boot partition is on sda. But it looks like install is on sdb. Cannot tell what is on NVMe drive., possibly UEFI, but no UEFI entry.You booted Boot-Repair in BIOS mode, not UEFI mode. From Windows does it say if UEFI or BIOS (not sure how to ask in Windows). Perhaps: http://www.rodsbooks.com/refind/bootmode.html#windows
Comment: I'm afraid I really don't follow what you're saying there, @oldfred .
Comment: I think you have Windows in BIOS boot mode & Ubuntu in UEFI boot mode. They are not compatible. Once you start booting in one mode you cannot change, or grub can only boot other installs in same boot mode. Wanted to confirm if Windows is installed in the now 35 year old BIOS/MBR configuration, even though Microsoft has required vendors to install in UEFI/gpt since Windows 8 released in 2012. Ability to allow BIOS installs was for large users, who wanted all systems the same.
Comment: Windows installed however it wanted to install, @oldfred . I'm afraid this type of thing is miles away from my expertise, and why I'm asking how to get things working here.
Comment: If Windows is BIOS & Ubuntu UEFI, then you can only dual boot from UEFI boot menu. If you really want the old BIOS you can convert Ubuntu to BIOS by reinstalling grub-pc. But if on gpt drive must have a 1 or 2MB unformatted partition with bios_grub flag for grub to install correctly. Or you can reinstall Windows in UEFI boot mode. Both Windows & Ubuntu install in the mode UEFI or BIOS that you use to boot install media.
Answer: You should convert your Windows disk (sdb) to a GPT format. Here, Windows is using an MBR disk, which as it is, needs to run in Legacy BIOS. Ubuntu is running in your M.2 drive (nvme0n1) in a GPT format in UEFI mode (L.308 suggests this). UEFI is like the modern equivalent of the old BIOS system and has replaced it, but you can still switch to Legacy BIOS, except Windows will not support a computer running in UEFI mode with an MBR disk, which is the case here.
To convert your green SSD drive to GPT format is easy enough in Ubuntu, using Gparted. Except it will wipe everything on that drive so you would need to re-install Windows. You'd lose any data files on that disk too. Alternatively there is some free software, by EaseUs Partition Master which claims it can convert without loss of any files. I haven't used it so I cannot confirm whether it works OK, but it would save a lot of time and trouble if it does.
There's also the issue of your Windows MSR partition residing on sda. Why it's not on your main Windows sdb disk, I don't know, but for the time being I'd leave it where it is, but you will probably need to convert sda also to make everything UEFI compatible across the board. Just make sure you back-up all data files residing on sda/sdb first before converting said disks to GPT.
Comment: Reinstalling Windows is something i heavily want to avoid. Unfortunately internet speeds are terrible here, so to redown updates would mean i'd lose the best of a day to get things back to where they were. I have, however, managed a "work around".
Answer: This is how I "solved" the problem, but from the comments, there does appear to be an underlying issue with the way that Windows decided to install itself (if the fact that it nicely put the boot partition on a different disc wasn't obvious enough).
As i mentioned, in my question when I hit Esc and then typed exit the machine booted to Windows 10. As a result I added to following to the 40_custom file:
menuentry "Exit to Windows 10"{
    exit
}

I then ran update-grub. When I select the option, this then has grub "boot" to Windows.
Answer: Have you tried to install os-prober?
sudo apt-get install os-prober

reinstall your grub:
grub-mkconfig
grub-install
grub-mkconfig -o /boot/grub/grub.cfg

Comment: From my question *"**`os-prober` doesn't detect Windows 10** (yes, both the partitions are mounted in ubuntu when I run it) and `update-grub` doesn't detect it either."*

Adding Windows 10 to Grub


Handling an array received from mysql stored procedure in laravel controller

Question: I have an array from my mysql database using a stored procedure.
$data = DB::connection('mysql')->select("CALL sp_GetLink('y')");

If I do this
var_dump($data);

This is the output :
array(1) {
    [0]=> object(stdClass)#216 (1) {
        ["ORIGINAL"]=> string(22) "tttttttttttttttttttttt"
    }
}

If I do this
return $data;

This is the output :
[{"ORIGINAL":"tttttttttttttttttttttt"}]

This is what I want it to output :
tttttttttttttttttttttt
The things that I have tried but unsuccessful:
return $data->value["ORIGINAL"];
return (string)$data;
return $data->ORIGINAL;
return $data->row['ORIGINAL'];
return $data->ORIGINAL;

Answer: According to your output, you are getting an array result from your query response. Can you try return $data[0]["ORIGINAL"]; or  return $data[0]->ORIGINAL; ?


Postgres select distinct based on timestamp

Question: I have a table with two columns a and b where a is an ID and b is a timestamp.
I need to select all of the a's which are distinct but I only care about the most up to date row per ID.
I.e. I need a way of selecting distinct a's conditional on the b values.
Is there a way to do this using DISTINCT ON in postgres?
Cheers
Comment: `select distinct on (a) a,b from the_table order by a, b desc`?
Comment: @JMzance: the order is _used_ to find the distinct values. It is essential for `distinct on ()` to work properly. Have a look at all the other questions tagged with [greatest-n-per-group](http://stackoverflow.com/questions/tagged/greatest-n-per-group+postgresql) for Postgres.
Comment: Most up to date: `select * from ztable t where not exists (select * from ztable x where x.a = t.a and x.b > t.b);`
Comment: a_horse_with_no_name - will the ordering be applied before or after the DISTINCT? @joop could you explain how that works please and I'll mark it as accepted
Answer: Like @a_horse_with_no_name suggests, the solution is
SELECT DISTINCT ON (a) a, b FROM the_table ORDER BY a, b DESC

As the manual says,

Note that the "first row" of a set is unpredictable unless the query
  is sorted on enough columns to guarantee a unique ordering of the rows
  arriving at the DISTINCT filter. (DISTINCT ON processing occurs after
  ORDER BY sorting.)
Answer: As posted by the upvoted answers, SELECT DISTINCT ON (a) a, b FROM the_table ORDER BY a, b DESC works on Postgre 12. However, I am posting this answer to highlight few important points:

The results will be sorted based on column a; not column b.
Within each result row, the most recent (highest value) for column b would be picked.
In case, someone wants to get the most recent value for column b on the entire result set, in sql, we can run : SELECT MAX(b) from (SELECT DISTINCT ON (a) a, b FROM the_table ORDER BY a, b DESC).


What non fish items can you get from fishing?

Question: I am trying to find if/what items you can get from fishing other than standard fish but I can't find it. Is it possible to fish up gear, gems, etc? If so, where can I find a list of fish able items?
Answer: Yes, you can get gear, special ingredients and more from fishing spots. Special ingredients also include fish whichupon their main purpose is not pet-food (for transformation). There are several lists out there on what you can get.
Here are some of the fishing spot catches:

Shimmering Fish Scale (socketable 3 health regeneration. Recover 3 HP per second)
Gold Fish (wealthy non-food item)
The Tasty Fish Meat (600 health recovery)
Sushi Grade Fish Meat (1200 health recovery) may be fed to your pet in the same manner as potions. The Sushi Grade Fish Meat is also used in the creation of a Sushi Helm. Sidenote: The sushi helmet is suberb for fishing as it increases fishing luck.
Blank's Teeth Necklace (1 socket, +15% to all damage, Random properties,
Dungeons are 50% more random)
Lefferts' Hands (65 armor, 1 socket, +8-10 defense, 7 mana stolen on hit
+33 all elemental resistances, Increases left-handedness)
Unidentified boots (Identify to find out!)

There are other type of fish that are only available in specific locations. One must fish everywhere a hole is found, to make sure all fish are found.
Each town (Estherian Enclave, Zeryphesh and Imperial Camp) contains an infinite fishing hole. In other areas of the world, there are Secret Fishing Holes and Promising Fishing Holes. These contain better loot than the fishing hole in town, but only allow a limited number of attempts.
Dynamite can also be used with fishing holes, but yields fewer results / less loot. Dynamite can only be used at fishing holes with a limited number of "attempts," not on the infinite fishing hole in town.
There are three main types of fishing holes:

Fishing Hole (Unlimited casts, located in the main town of each act)
Promising Fishing Hole (Usually located in an overland area)
Secret Fishing Hole (Usually located in an overland area, contains special fish, items, tags, and collars)

 While the Gold Fish is indeed a fish, you can sell it instead for a
  nifty price.

The lists of what you can get are very, very long. Have a look at these sources for possible catches.

http://www.runicgamesfansite.com/showwiki.php?title=Fishing
http://strategywiki.org/wiki/Torchlight/Fish#Other_items_and_equipment
http://torchlight.wikia.com/wiki/Fishing_Hole
http://torchlight.wikia.com/wiki/Fishing_Hole
Comment: Much of this answer doesn't seem to apply to Torchlght 2.
Comment: Two comments: 1) Gold Fish are handy for transferring gold between two of your own characters as you cannot otherwise "stash" gold. 2) Last I checked, fishing luck was a bugged attribute that did nothing, sadly.
Comment: Also, according to your link, the secret horse level is for Torchlight 1, not 2.
Comment: Removed section regarding The Secret Horse level as it was indeed in TL1, not TL2. Also updated answer regarding where the fishing holes are and types of reward.


Java Netbeans circular dependency in included project

Question: I am using Netbeans 8.0, Java 1.7 and Excelsior Jet 9. I have a project dependency issue with an existing project. Project A (main project) has some extendable classes while Project B is extending some of these classes. I am dynamically loading classes of Project B from Project A. But, I have to copy the project B dependencies in class path (fair enough though Project A has all the dependencies resolved in its own ../lib folder).
Problem is that complete Project A jar file is required to be in the the class path as well. I am using Excelsior JET to compile Project A to native code (to avoid code forgery) and trying to use Project B (just compiling with Java compiler and using its jar file in class path)as sort of a driver framework.
With this scheme i may not have to compile the complete project every time after addition of new drivers.
But with this circular dependency i can't use this scheme (can't expose my ProjectA.jar file). Am I doing something wrong or is this a Java/ classpath limitation?
Answer: To answer the only question you actually asked, yes you are doing something wrong and this is not a Java/classpath limitation.
B is trying to extend classes from A, and A is also trying to load classes from B. This cannot be done.
You need to either

Combine A and B into one project
Remove the shared code from one of the projects (e.g. the classes from A that B needs) and put them in another project, C, on which both A and B depend.
Comment: Thanks for a quick reply. Actually I have only one Project i.e. Project A in production but I always have to compile Project A when a new driver class is added which is the problem. Project A has the class loader which dynamically loads classes from Project B. Project A also has classes which Project B needs to extend to write new Driver classes. How can this be managed with Project C? Can you please elaborate.
Comment: Sounds like you need to do number 2 from my answer. "Project A also has classes which Project B needs" - you need to move these classes into Project C to avoid the circular dependency. Make sure C does not depend on A or B. Now you are free to have A and B depend on C.
Comment: I think i am understanding what you are saying. Let me check and will get back. Bundle of thanks.


Laravel reset password link

Question: I have set up reset password method, so everything works fine so I receive link which address is:

localhost/dashboard/password/reset/11bb83ff2815781dfebwef5060aa15706bad6a02a5d22328615bwef28fcfwefwef51a47

But after clicking on that link i am getting 404 Not Found.
When i attached a port number after localhost it works.

localhost:8000/dashboard/password/reset/11bb83ff2815781dfebwef5060aa15706bad6a02a5d22328615bwef28fcfwefwef51a47

Why is this happening ?
I am using php -S localhost:8000 -t public as server, but it was same when using artisan web server.
Comment: The URL is generated based on the `APP_URL` value in your `.env`, update it so that it contains `http://localhost:8000`.
Comment: @sam 'url' => env('APP_URL', 'http://localhost'),
Answer: In your config/app.php you will have a url setting which will no doubt be set to just localhost. You should add your port there so Laravel is able to generate the correct URL.
Of course, the best way to do this in a development environment is to set an APP_URL in your .env file.
APP_URL=http://localhost:8000

Check out the Illuminate\Auth\Notifications\ResetPassword class to see how Laravel generates the password reset email.
Comment: @jonathan, How can i modify reset password link without change in vendor file?

Laravel reset password link


Interposing on Java Class Methods (without interfaces)

Question: I'd like to interpose between class methods to dynamically extends an object.
I already know about the java.lang.reflect.Proxy stuff, but it's way too limited to do real interposing.
From Using java.lang.reflect.Proxy to Interpose on Java Class Methods, the first limitation is :

(...) the method must be called through an instance of the proxy class. So nested methods calls, for instance, would not be intercepted.

And the worst one :

(...) the method must have been defined in an Interface that is implemented by the object being proxied. It can not be called through an instance of a class that does not implement an interface.

The object I'd like to extends at run-time doesn't implement any interface, and worst, the methods I need to override are nested and private.
I know this is fairly easy in Python & C, and the article cited above says that it could be possible :

The next article in this series will illustrate some techniques for overcoming these limitations.

Unfortunately, I'm unable to find this article.
Comment: That article is from 2001. It's *11 years old*. You may want to try and find something less prehistoric to base your experiments on.
Comment: This sort of changes are usually considered very bad programming practices.  It can lead to unmaintainable and unsupportable code.  What you suggest usually has a better way of being done. I suspect you have a particular solution to a problem in mind. Would you consider other solutions to the same problem?
Comment: Sometimes, hacking is the only way to do it. If you're interested in the (long) story, send me a PM =)
Answer: Try using CGLIB:
Here is a tutorial I wrote a couple of years ago, its quite simple introduction to CGLIB: CGLIB intro
If you need even more power, consider to use AspectJ
Hope this helps
Comment: I forget to precise it was related to Android. Is AspectJ compatible with Android ?


Complex number $i^{{i^{i^{.^{.^.}}}}}$

Question: If $A+iB=i^{{i^{i^{.^{.^.}}}}}$
Principal  values only being considered,
Prove that
(a)tan $ \frac {\pi}{2} $A= $\frac{B}{A}$
(b) $A^2 + B^2 = e^{-\pi B}$
I tried the concept A+iB= $y=i^y$
$i= e^{ \frac{i\pi}{2}}$
$\ln(A+iB)=i \frac{\pi}{2}$(A+iB)
After this step not able to proceed
Comment: First things first: how the map $f:z\mapsto i^z$ is really defined? Second: why $z\mapsto f(z)\mapsto f(f(z)) \mapsto \ldots $ converge?
Comment: @D'Aurizio Question modified, I was modifying the question when your comment was posted
Answer: Assume that the heuristic statement "$A+iB=i^{i\,\cdots \text{infinity times}}$" as written in the OP is rigorously described by the limit, if it exists, of the equation
$$\begin{align}
z_{n+1}&=i^{z_n}\\\\
&=e^{z_n\log(i)}\\\\
&=e^{i\pi z_n/2}\\\\
\end{align}$$
subject to the initial condition $z_0=i$.
If $\lim_{n\to \infty}z_n=A+iB$ exists, then
$$\begin{align}
A+iB&=e^{i\pi (A+iB)/2}\\\\
&=e^{-\pi B/2}\cos(\pi A/2)+ie^{-\pi B/2}\sin(\pi A/2)\tag1
\end{align}$$
Taking the modulus on both sides of $(1)$, we obtain
$$A^2+B^2=e^{-\pi B}$$
Taking the ratio of the imaginary and real parts of both sides of $(1)$, we obtain
$$\frac{B}{A}=\tan(\pi A/2)$$
Answer: Whatever the value of $x = i^{i^{i^\cdots}}$ (if it exists), it should satisfy the equation
$$
x = i^x.
$$
But what is the definition of $i^x$ ? Since it is ambiguous, we must loosen the constraint even further: Whatever the value of $x$, it should satisfy
$$
x = e^{x \log i} \text{ for } \textit{some} \text{ value of } \log i
$$
Now, the set of logarithms of $i$ (the set of $y$ such that $e^y = i$) is $\{2 \pi i k + \tfrac{\pi i}{2} \}_{k \in \mathbb{Z}}$.
So our condition is now
$$
x = \exp\left(2 \pi i k x + \frac{\pi i}{2} x\right) \tag{1}
$$
Letting $x = A + Bi$, we get
\begin{align*}
A + Bi
&= \exp\left[ (A + Bi)\left(2 \pi i k x + \frac{\pi i}{2} x\right)\right] \\
&= \exp\left[ (-B + Ai)\left(2 \pi k + \frac{\pi}{2} \right)\right] \\
&= \underbrace{\exp\left[ (-B)\left(2 \pi k + \frac{\pi}{2} \right)\right]}_{\text{magnitude}}
   \underbrace{\exp\left[ A \left(2 \pi k + \frac{\pi}{2} \right) i \right]}_{\text{direction}} \\
\end{align*}
Equate the magnitude squared of both sides and the slope (tangent of the angle) of both sides. For magnitude squared we get:
$$
A^2 + B^2 = e^{- \pi B  + 4 \pi k B}. \tag{2}
$$
For tangent of the angle we get
$$
\frac{B}{A} = \tan \left((2 \pi k + \pi / 2) A\right). \tag{3}
$$
Your desired results follow from (2) and (3) if we assume $k = 0$.
This corresponds to taking the principal logarithm in defining $i^x$.
For $k = 0$:
\begin{align*}
A^2 + B^2 &= e^{- \pi B} \\
\frac{B}{A} &= \tan \left(\pi A / 2\right)
\end{align*}
Comment: Still, we might be talking about nothing, since nobody proved or disproved the existence of the limit of $f^{(n)}(i)$ with $f(z)=\exp\left(\frac{\pi}{2}iz\right)$. What about studying $f'(z)$ for settling such (pretty relevant) point?
Comment: @JackD'Aurizio Yes, definitely, I didn't show that such a number $A + Bi$ exists. That sounds like a good approach

Complex number $i^{{i^{i^{.^{.^.}}}}}$


Finding an isomorphism between an infinite tree and a subgraph of $\mathbb{Z}^3$

Question: I was wondering if there exists a construction of an infinite tree, with some properties, that is isomorphic to subgraph of $\mathbb{Z}^3$.
Notation
Let $\Gamma_n$ denote the tree's vertices at distance $n$ from the root.
Let $\partial B(n)$ denote the vertices of $\mathbb{Z}^3$ at distance $n$ from the origin, according to $\ell_1$ metric.
I first describe a family of trees $\mathcal{F}$,
where a tree is in this family if and only if it satisfies the following properties.

For all $i\in\mathbb{N}$, all vertex at distance $i$ from the root, have the same number of children at distance $i+1$ from the root.
Every vertex has either one or two children.
There exists an isomorphism $\varphi$ from the tree vertices to $\mathbb{Z}^3$, where
$$
    \forall i\in\mathbb{N},\quad \varphi(\Gamma_i)\subseteq \partial B(i)
$$
For all $i\in\mathbb{N}$, $|\Gamma_i|\geq i^2/ c$ for some positive constant $c$ (the constant $c$ is absolute constant belonging to $\mathcal{F}$).

Question
Is $\mathcal{F} = \emptyset$? Or perhaps it is not empty, and someone can give me a hint on showing it is not empty?
I would also be happy with seeing proof of the existence of a tree satisfying all properties, where $4$ is weakened to $|\Gamma_i|\geq i^{1+\epsilon}/ c$ for some positive absolute constant $\epsilon$.
Thanks for reading the long explanation.
Answer: Let show this in the simpler case where we take $\mathbb{N}^2$ instead of $\mathbb{Z}^3$. We will show that we can find $\mathcal{F}$ with $|\Gamma_i| \geq \frac{i}{c}$. Let $\partial_pB(2^n-2)$ be the vertices of $\mathbb{N}^2$ where both coordinates are even ($\partial B(2^n-2)$ is a diagonal, we take one vertex over two). We have $|\partial_pB(2^n-2)| = 2^{n-1}$ We see easily that no two elements of $\partial_pB(n)$ share a common neighbor. Suppose we found a tree for which $\varphi(\Gamma_{2^n-2}) = \partial_pB(2^n-2)$. At next step, we give each vertex two children (so $|\Gamma_{2^n-1}| = 2^n$), then we find a $2^n$ disjoint paths from the vertices of $\varphi(\Gamma_{2^n-1})$ to the vertices of $\varphi(\Gamma_{2^{n+1}-2})$ (quite easy to find).
$|\Gamma_{2^n-2}| = 2^{n-1} \geq \frac{2^n-2}{2}$, so $|\Gamma_i| \geq \frac{i}{2}\; \forall i$ .
Because $\partial B(n)$ is only 4 times bigger in $\mathbb{Z}^2$ than in $\mathbb{N}^2$, we have  $|\Gamma_i| \geq \frac{i}{8}\; \forall i$ when considering $\mathbb{Z}^2$. (but we could get a better constant by growing the tree in all directions).
The same reasoning works with $\mathbb{Z}^3$, it is always possible to find  a subset $\partial_p B(n)$ of $\partial B(n)$ with $|\partial_p B(n)| \geq \frac{|\partial B(n)|}{2}$ such that we can split each vertices in two at the next step (Take the subset where the first coordinate is even). It should be even possible to reach a constant of $c = \frac{3}{2}$ by selecting a better subset.


How to remove gap between Toolbar and layout underneath

Question: Tried implementing a toolbar for my layout but a gap keeps appearing underneath it. What is the correct way to eliminated that gap? I believe android:fitsSystemWindows="false" or android:fitsSystemWindows="true" but I'm not entirely sure which code needs to be used as I've heard several different solutions. Also I'm not sure where it needs to go.

Fragment XML code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include layout="@layout/my_toolbar"/>

    <com.packagename.SlidingTabLayout_DarkTabStrip
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_height="0dp"
        android:layout_width="match_parent"
        android:layout_weight="1"/>

</LinearLayout>

Toolbar XML code
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar_2lines"
    android:layout_width="match_parent"
    android:layout_height="?actionBarSize">

    <LinearLayout
        android:id="@+id/dualline_text_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#00FFFFFF"
        android:gravity="center_vertical"
        android:orientation="vertical">

        <TextView
            android:id="@+id/toolbar_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"/>

        <TextView
            android:id="@+id/toolbar_subtitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle"/>
    </LinearLayout>
</android.support.v7.widget.Toolbar>

SlidingTabLayout_DarkTabStrip.java
public class SlidingTabLayout_DarkTabStrip extends HorizontalScrollView {

    public interface TabColorizer {
        int getIndicatorColor(int position);
    }

    private static final int TITLE_OFFSET_DIPS = 24;
    private static final int TAB_VIEW_PADDING_DIPS = 16;
    private static final int TAB_VIEW_TEXT_SIZE_SP = 12;

    private int mTitleOffset;

    private int mTabViewLayoutId;
    private int mTabViewTextViewId;
    private boolean mDistributeEvenly;

    private ViewPager mViewPager;
    private SparseArray<String> mContentDescriptions = new SparseArray<>();
    private ViewPager.OnPageChangeListener mViewPagerPageChangeListener;

    private final SlidingTabStrip_Dark mTabStrip;

    public SlidingTabLayout_DarkTabStrip(Context context) {
        this(context, null);
    }

    public SlidingTabLayout_DarkTabStrip(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SlidingTabLayout_DarkTabStrip(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        // Disable the Scroll Bar
        setHorizontalScrollBarEnabled(false);
        // Make sure that the Tab Strips fills this View
        setFillViewport(true);

        mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density);

        mTabStrip = new SlidingTabStrip_Dark(context);
        addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    }

    public void setCustomTabColorizer(SlidingTabLayout_DarkTabStrip.TabColorizer tabColorizer) {
        mTabStrip.setCustomTabColorizer(tabColorizer);
    }

    public void setDistributeEvenly(boolean distributeEvenly) {
        mDistributeEvenly = distributeEvenly;
    }

    public void setSelectedIndicatorColors(int... colors) {
        mTabStrip.setSelectedIndicatorColors(colors);
    }

    public void addOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
        mViewPagerPageChangeListener = listener;
    }

    public void setCustomTabView(int layoutResId, int textViewId) {
        mTabViewLayoutId = layoutResId;
        mTabViewTextViewId = textViewId;
    }

    public void setViewPager(ViewPager viewPager) {
        mTabStrip.removeAllViews();

        mViewPager = viewPager;
        if (viewPager != null) {
            viewPager.addOnPageChangeListener(new SlidingTabLayout_DarkTabStrip.InternalViewPagerListener());
            populateTabStrip();
        }
    }

    protected TextView createDefaultTabView(Context context) {
        TextView textView = new TextView(context);
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
        textView.setTypeface(Typeface.DEFAULT_BOLD);
        textView.setLayoutParams(new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
                outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
        textView.setAllCaps(true);

        int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
        textView.setPadding(padding, padding, padding, padding);

        return textView;
    }

    private void populateTabStrip() {
        final PagerAdapter adapter = mViewPager.getAdapter();
        final View.OnClickListener tabClickListener = new SlidingTabLayout_DarkTabStrip.TabClickListener();

        for (int i = 0; i < adapter.getCount(); i++) {
            View tabView = null;
            TextView tabTitleView = null;

            if (mTabViewLayoutId != 0) {
                // If there is a custom tab view layout id set, try and inflate it
                tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
                tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
            }

            if (tabView == null) {
                tabView = createDefaultTabView(getContext());
            }

            if (tabTitleView == null && TextView.class.isInstance(tabView)) {
                tabTitleView = (TextView) tabView;
            }

            if (mDistributeEvenly) {
                LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
                lp.width = 0;
                lp.weight = 1;
            }

            assert tabTitleView != null;
            tabTitleView.setText(adapter.getPageTitle(i));
            tabView.setOnClickListener(tabClickListener);
            String desc = mContentDescriptions.get(i, null);
            if (desc != null) {
                tabView.setContentDescription(desc);
            }

            mTabStrip.addView(tabView);
            if (i == mViewPager.getCurrentItem()) {
                tabView.setSelected(true);
            }

            tabTitleView.setTextColor(Color.parseColor("#000099"));
            tabTitleView.setTextSize(14);
        }
    }

    public void setContentDescription(int i, String desc) {
        mContentDescriptions.put(i, desc);
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();

        if (mViewPager != null) {
            scrollToTab(mViewPager.getCurrentItem(), 0);
        }
    }

    private void scrollToTab(int tabIndex, int positionOffset) {
        final int tabStripChildCount = mTabStrip.getChildCount();
        if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
            return;
        }

        View selectedChild = mTabStrip.getChildAt(tabIndex);
        if (selectedChild != null) {
            int targetScrollX = selectedChild.getLeft() + positionOffset;

            if (tabIndex > 0 || positionOffset > 0) {
                // If we're not at the first child and are mid-scroll, make sure we obey the offset
                targetScrollX -= mTitleOffset;
            }

            scrollTo(targetScrollX, 0);
        }
    }

    private class InternalViewPagerListener implements ViewPager.OnPageChangeListener {
        private int mScrollState;

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            int tabStripChildCount = mTabStrip.getChildCount();
            if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) {
                return;
            }

            mTabStrip.onViewPagerPageChanged(position, positionOffset);

            View selectedTitle = mTabStrip.getChildAt(position);
            int extraOffset = (selectedTitle != null)
                    ? (int) (positionOffset * selectedTitle.getWidth())
                    : 0;
            scrollToTab(position, extraOffset);

            if (mViewPagerPageChangeListener != null) {
                mViewPagerPageChangeListener.onPageScrolled(position, positionOffset,
                        positionOffsetPixels);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {
            mScrollState = state;

            if (mViewPagerPageChangeListener != null) {
                mViewPagerPageChangeListener.onPageScrollStateChanged(state);
            }
        }

        @Override
        public void onPageSelected(int position) {
            if (mScrollState == ViewPager.SCROLL_STATE_IDLE) {
                mTabStrip.onViewPagerPageChanged(position, 0f);
                scrollToTab(position, 0);
            }
            for (int i = 0; i < mTabStrip.getChildCount(); i++) {
                mTabStrip.getChildAt(i).setSelected(position == i);
            }
            if (mViewPagerPageChangeListener != null) {
                mViewPagerPageChangeListener.onPageSelected(position);
            }
        }

    }

    private class TabClickListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            for (int i = 0; i < mTabStrip.getChildCount(); i++) {
                if (v == mTabStrip.getChildAt(i)) {
                    mViewPager.setCurrentItem(i);
                    return;
                }
            }
        }
    }
}

SlidingTabStrip_Dark.java
public class SlidingTabStrip_Dark extends LinearLayout {

    private static final int DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS = 0;
    private static final byte DEFAULT_BOTTOM_BORDER_COLOR_ALPHA = 0x26;
    private static final int SELECTED_INDICATOR_THICKNESS_DIPS = 3;
    private static final int DEFAULT_SELECTED_INDICATOR_COLOR = 0xFF33B5E5;

    private final int mBottomBorderThickness;
    private final Paint mBottomBorderPaint;

    private final int mSelectedIndicatorThickness;
    private final Paint mSelectedIndicatorPaint;

    private int mSelectedPosition;
    private float mSelectionOffset;

    private SlidingTabLayout_DarkTabStrip.TabColorizer mCustomTabColorizer;
    private final SlidingTabStrip_Dark.SimpleTabColorizer mDefaultTabColorizer;

    SlidingTabStrip_Dark(Context context) {
        this(context, null);
    }

    SlidingTabStrip_Dark(Context context, AttributeSet attrs) {
        super(context, attrs);
        setWillNotDraw(false);

        final float density = getResources().getDisplayMetrics().density;

        TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(android.R.attr.colorForeground, outValue, true);
        final int themeForegroundColor =  outValue.data;

        int mDefaultBottomBorderColor = setColorAlpha(themeForegroundColor,
                DEFAULT_BOTTOM_BORDER_COLOR_ALPHA);

        mDefaultTabColorizer = new SlidingTabStrip_Dark.SimpleTabColorizer();
        mDefaultTabColorizer.setIndicatorColors(DEFAULT_SELECTED_INDICATOR_COLOR);

        mBottomBorderThickness = (int) (DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density);
        mBottomBorderPaint = new Paint();
        mBottomBorderPaint.setColor(mDefaultBottomBorderColor);

        mSelectedIndicatorThickness = (int) (SELECTED_INDICATOR_THICKNESS_DIPS * density);
        mSelectedIndicatorPaint = new Paint();
    }

    void setCustomTabColorizer(SlidingTabLayout_DarkTabStrip.TabColorizer customTabColorizer) {
        mCustomTabColorizer = customTabColorizer;
        invalidate();
    }

    void setSelectedIndicatorColors(int... colors) {
        // Make sure that the custom colorizer is removed
        mCustomTabColorizer = null;
        mDefaultTabColorizer.setIndicatorColors(colors);
        invalidate();
    }

    void onViewPagerPageChanged(int position, float positionOffset) {
        mSelectedPosition = position;
        mSelectionOffset = positionOffset;
        invalidate();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        final int height = getHeight();
        final int childCount = getChildCount();
        final SlidingTabLayout_DarkTabStrip.TabColorizer tabColorizer = mCustomTabColorizer != null
                ? mCustomTabColorizer
                : mDefaultTabColorizer;

        // Thick colored underline below the current selection
        if (childCount > 0) {
            View selectedTitle = getChildAt(mSelectedPosition);
            int left = selectedTitle.getLeft();
            int right = selectedTitle.getRight();
            int color = tabColorizer.getIndicatorColor(mSelectedPosition);

            if (mSelectionOffset > 0f && mSelectedPosition < (getChildCount() - 1)) {
                int nextColor = tabColorizer.getIndicatorColor(mSelectedPosition + 1);
                if (color != nextColor) {
                    color = blendColors(nextColor, color, mSelectionOffset);
                }

                // Draw the selection partway between the tabs
                View nextTitle = getChildAt(mSelectedPosition + 1);
                left = (int) (mSelectionOffset * nextTitle.getLeft() +
                        (1.0f - mSelectionOffset) * left);
                right = (int) (mSelectionOffset * nextTitle.getRight() +
                        (1.0f - mSelectionOffset) * right);
            }

            mSelectedIndicatorPaint.setColor(color);

            canvas.drawRect(left, height - mSelectedIndicatorThickness, right,
                    height, mSelectedIndicatorPaint);
        }

        // Thin underline along the entire bottom edge
        canvas.drawRect(0, height - mBottomBorderThickness, getWidth(), height, mBottomBorderPaint);
    }

    /**
     * Set the alpha value of the {@code color} to be the given {@code alpha} value.
     */
    private static int setColorAlpha(int color, byte alpha) {
        return Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
    }

    /**
     * Blend {@code color1} and {@code color2} using the given ratio.
     *
     * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
     *              0.0 will return {@code color2}.
     */
    private static int blendColors(int color1, int color2, float ratio) {
        final float inverseRation = 1f - ratio;
        float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
        float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
        float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
        return Color.rgb((int) r, (int) g, (int) b);
    }

    private static class SimpleTabColorizer implements SlidingTabLayout_DarkTabStrip.TabColorizer {
        private int[] mIndicatorColors;

        @Override
        public final int getIndicatorColor(int position) {
            return mIndicatorColors[position % mIndicatorColors.length];
        }

        void setIndicatorColors(int... colors) {
            mIndicatorColors = colors;
        }
    }
}

Activity java code
public class TBarActivity extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_withtbar);

        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

        final String actionBarColor = "#66CCCC";

        Toolbar customToolbar = (Toolbar)findViewById(R.id.toolbar_2lines);
        setSupportActionBar(customToolbar);
        customToolbar.setBackgroundColor(Color.parseColor(actionBarColor));

        //add back arrow to toolbar
        if (getSupportActionBar() != null){
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
        }

        //Declaring 'title' text view & applying marquee effect to 'title' text view
        TextView mTitle = (TextView) this.findViewById(R.id.toolbar_title);
        mTitle.setText(getString(R.string.toolbar));
        mTitle.setTextColor(Color.parseColor("#000099"));
        mTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        mTitle.setMarqueeRepeatLimit(-1);
        mTitle.setSingleLine(true);
        mTitle.setSelected(true);

        //Declaring 'subtitle' text view & applying marquee effect to 'subtitle' text view
        TextView mSubtitle = (TextView) this.findViewById(R.id.toolbar_subtitle);
        mSubtitle.setText(getString(R.string.toolbars_are_awesome));
        mSubtitle.setTextColor(Color.parseColor("#000099"));
        mSubtitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        mSubtitle.setMarqueeRepeatLimit(-1);
        mSubtitle.setSingleLine(true);
        mSubtitle.setSelected(true);

        if (savedInstanceState == null) {
            FragmentwithTBar newFragment = new FragmentwithTBar();
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.detail_container, newFragment);
            transaction.commit();
        }
    }
}

Fragment java code
public class FragmentwithTBar extends android.support.v4.app.Fragment {

    public FragmentwithTBar() {
        // Required empty constructor
    }

    // Declaring views and variables
    ViewPager pager;
    TBarViewPagerAdapter adapter;
    SlidingTabLayout_DarkTabStrip tabs;
    int Numboftabs = 4;

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_with_tbar, container, false);
        super.onCreate(savedInstanceState);

        return v;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        View v = getView();

        // Creating the ViewPagerAdapter and passing the Fragment Manager, titles for the Tabs and Number of Tabs.
        adapter =  new TBarViewPagerAdapter(getChildFragmentManager(), Numboftabs, getActivity());

        // Assigning ViewPager View and setting the adapter
        assert v != null;
        pager = (ViewPager) v.findViewById(R.id.pager);
        pager.setAdapter(adapter);

        // Assigning the Sliding Tab Layout view
        tabs = (SlidingTabLayout_DarkTabStrip) v.findViewById(R.id.tabs);
        tabs.setDistributeEvenly(false);

        // Setting Custom color for the scroll bar indicator of the Tab View
        tabs.setCustomTabColorizer(new SlidingTabLayout_DarkTabStrip.TabColorizer() {
            @Override
            public int getIndicatorColor(int position) {
                return Color.parseColor("#000099");
            }
        });

        // Setting the ViewPager for the SlidingTabsLayout
        tabs.setViewPager(pager);

        super.onActivityCreated(savedInstanceState);
    }
}

Comment: What is the black part? Check in design whether it is a toolbar or layout?
Comment: Background of toolbar or linear layout?
Comment: Post toolbar code.
Comment: Try to change your toolbaar linearlayout height to wrap_content and add an attribute in toolbar : >android:minHeight="?attr/actionBarSize"
Comment: What is the code for `com.packagename.TabLayout`?
Comment: @BenP. This code represents the tabs: 'Item A', 'Item B', 'Item C', and 'Item D'
Comment: @MacaronLover the precise implementation matters here. First of all, I cannot reproduce your problem if I don't have your tab code. Second of all, when I use the standard `` tag I do not see any issues.
Comment: @BenP. The tab code is now within my question
Comment: @MacaronLover we'll also need `SlidingTabStrip_Dark`
Comment: @BenP. Just added that
Comment: @MacaronLover this is getting very annoying. Every time you post code there is more code that I have to request. Your fragment references `TBarViewPagerAdapter` which I do not have the source for. Perhaps you have a github link with your entire project?
Comment: This might help you to solve this issue https://stackoverflow.com/a/52824937/4964308
Answer: Short answer
Delete this line from your layout:
<include layout="@layout/my_toolbar"/>

Long answer
I took your layout and put it in my project, along with your SlidingTab... classes. My MainActivity.java was quite simple; I just populated the ViewPager with an adapter that created a handful of "hello world" fragments.
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ViewPager pager = (ViewPager) findViewById(R.id.pager);
        pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));

        SlidingTabLayout_DarkTabStrip tabs = (SlidingTabLayout_DarkTabStrip) findViewById(R.id.tabs);
        tabs.setViewPager(pager);
    }

    private static class MyPagerAdapter extends FragmentPagerAdapter {

        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public int getCount() {
            return 5;
        }

        @Override
        public Fragment getItem(int position) {
            return new MyFragment();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return "Item: " + position;
        }
    }
}

This is what I saw when I ran it:

That empty space between the actionbar and the tab strip is the <android.support.v7.widget.Toolbar> included in the layout. Essentially, I have two toolbars: the system actionbar and the Toolbar in the layout... but the second one isn't populated.
I assume you're setting your navigation icon, title, and subtitle to the system actionbar. If I add these lines to my onCreate():
    getSupportActionBar().setTitle("Toolbar");
    getSupportActionBar().setSubtitle("Toolbars are awesome");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

I now see:

That's exactly what you have in your screenshot. So just delete the <include> tag.
Comment: @MacaronLover but the **Activity** has a toolbar too.
Comment: Your posted activity makes no reference to `R.id.tabs` or `R.id.pager`, and it does reference `R.id.detail_container`. Meanwhile, your fragment **does** reference `R.id.tabs` and `R.id.pager`, but does not reference the toolbar in any way. Are you 100% sure that there's not just an extra toolbar in your fragment's layout?


Website notifications

Question: I am kicking around the idea of putting in place a new design pattern for notifications. These notifications would contain important/very useful information for the user but I don't want to block the user from interacting with the site...so no modal popups. I want to do something like a toast (slide-down/up overlapping window) display but I am having trouble finding best practice information. Anyone know of any resource or having opinions of your own?
One of my main questions is where on the screen are they the most effective?
Thanks!
Comment: This question is pretty broad. What would be most effective for your needs would depend mostly on the specific needs of your users and the specifics of the UI that's being built.
Comment: Some interesting ideas: http://tympanus.net/Development/NotificationStyles/bar-slidetop.html
Answer: As @DAO1 said its a very broad question. First of all you need to decide importance of the notifications. Like are they need to be shown to the user without any delay or they are related to some tasks etc. If they are time critical message which needs to be shown right away on occuring some event then @KK's solution won't work as we don't have any assurance that whether user will check the notification or not.
In that case you can show a notification div on page somewhere (may be on left bottom like facebook does on every new notification) and apply a timout function on it so it gets fade and removed by itself after 4-5 seconds and adds the number of un-read notifications on the top bar somewhere.
Another solution may be you can add a notification bar on top having number of notifications and a short message on it with the 'X' button to close it. So whenever a new message arrives , a bar is added to the top of page (same like kibana UI) and user can either close it or can click on it for futher information. if you have multiple messages then you can also show the number of notification on the bar.
it should look something like following
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
(2) server is down right now                                         X
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
showing a message with (2) more pending notifications. When you close it , the other notification will be visible.
Hope you can get some idea from these.
Answer: You can have a look the UI of the notifications here:
https://almsaeedstudio.com/themes/AdminLTE/pages/examples/blank.html

You can implement this UI. It doesn't block the user interaction. And also it doesn't bother user too.
Comment: I have a notification system like this. The important thing is the notifications must automatically dismiss themselves somehow. If 10 notifications becomes 20, 30, 100, 1000 the users won't view them.

Website notifications


If I update an object, will it update it everywhere?

Question: If I update an object in my code, does it update it everywhere, or will I have to refresh it?
For example:
An arraylist contains the object Cat
ArrayList<Cat> cats = new ArrayList<Cat>();
Cat Abbie = new Cat("Abbie");
cats.put(Abbie);

If I then change Abbie outside of this, would I have to refresh Abbie in the arraylist? For exmaple:
Abbie.setName("Putter");
if(cats.get(0).getName().equals(Abbie.getName()){
     //Are their names the same?
}

Comment: You shall test the code before posting it here.
Comment: +0 -0 Yes, learn to experiment on your own. You've already written the code :)
Comment: This is not a behavior your code should rely on.  It's very confusing for human readers of your code.
Comment: @Gilbert depends entirely on the program. For example physics object in a game instinctively makes sense to be changed everywhere it can be refered to and those changes to be seen everywhere (e.g. physics engine moves it but your code applys external forces)
Answer: When you pass object to method you actually pass reference to this object by value. So, when you change content of object you refer to it by reference and therefore all other places that refer to the same reference will see the changes.
BTW list does not have method put(), it has method add()
Answer: Yes, references point to the object original created using new. So when you change the object through one reference, other references will point to the same object still, so when you access the object properties through them, of course it will return the same thing.
You can experiment and discover the answer yourself :) Functions that do deep copying will not exhibit the same behavior of course!


Move rooftop air conditioner condenser: Drill through tar-like blanket?

Question: On a single story flat roof private home I need to move a rooftop air conditioning condenser 20 cm for a solar panel install. Fortunately the sloppy original install left enough electrical cable and refrigerant hose dangling whereas I do not need to concern myself with them. All I need to do is remove the four bolts in the roof, remount in the new location, and seal the original holes.
The house was constructed in 2017. The roof is concrete with a tar-like blanket on top. I do not know how thick the blanket or roof are.
Is it enough to simply drill through the tar-like blanket, into the concrete, and place anchors there?
Comment: Frame challenge: if the situation (physical dimensions etc.) allows it (and the aesthetics won't bother you) you could also leave the original bolts and install a bracket, onto the bolts, that holds the AC 20cm away.
Advantages: No additional roof penetration, no risk of drilling into a pipe or cable
Detriments: Somehow sloppy
Comment: do you happen to know the thickness of the roof concrete and the weight of the AC
Comment: Far too many questions in one.
Comment: @FreeMan I've reasked each question individually. Thank you.
Comment: Vote retracted. Thank _you_!
Comment: @knowitall I do not know the thickness of the roof concrete, but this is a recent (2017) construction. The AC unit is a one horsepower single-room unit, but I could not find online what are typical weights for that type of unit. My guess from having carried on once would be on the order of 50 kilograms. If I find the exact weight I'll post it. Thank you.
Comment: Why the downvote? How could I improve the question? I think that I included all relevant information, and I addressed the issue that FreeMan brought up.
Comment: *rooftop air conditioning radiator* - I hope you mean a *condenser*... that's on a roof. A *roof-top* unit goes into the roof through a *curb*; those don't 'move' w/o re-doing the curb (and the duct work). Condensers generally just sit on a pad (if even); I wouldn't be penetrating the roof if I didn't have to. And there *should* be enough line to move it so you can fix the roof regularly.
Comment: @Mazura Thank you, yes, the unit on the roof _condenses_ the refrigerant and _radiates_ the heat away. I will update the question with the proper English terminology, thank you very much.
Comment: @Martin Thank you, that might actually be a viable solution. I might add a single additional bolt at the end for stability, but I actually do like this idea.
Answer: Remove one of the screws and you'll have a good idea of the depth and size of the new holes and maybe the type of anchors used.. Take the screw to your home store and pick out the appropriate anchors for that screw. I prefer lag bolts and lag shields. To fill in the old holes pick up some wet or dry roof patch, also available at your home store. 20 cm  is a good distance between holes. Whether you upgrade your roof with an additional blanket would be opinion based and would depend on the condition of your roof and the age.
If you don't have the tools to drill the holes, you might be able to get the solar panel installers to do it.
Comment: Terrific, thank you. You're 100% correct, with one old bolt in hand the home store should know what I need. I do have a proper drill and bits.


Using Net::SSH::Perl with public key

Question: I want to gain access to an AWS Instance using Perl. I can access the instance from commandline like this:
ssh -i my-key-pair.pem ubuntu@ec2-**-***-***-***.us-west-2.compute.amazonaws.com

but my code doesn't work:
#! usr/bin/perl
use Net::SSH::Perl;

$user = "ubuntu";
$host = "ec2-**-***-***-***.us-west-2.compute.amazonaws.com";
@KEYFILE = "my-key-pair.pem";
$ssh = Net::SSH::Perl->new($host, debug=>1, identity_files=>\@KEYFILE);
$ssh->login($user);

As I mentioned I'm new to this concept, it might be a simple solution, I couldn't find a solution online, hopefully you can help me.
the output is this:
atakanarikan@atakanarikanhplaptop:~/Desktop$ perl remotecomp
atakanarikanhplaptop: Reading configuration data /home/atakanarikan/.ssh/config
atakanarikanhplaptop: Reading configuration data /etc/ssh_config
atakanarikanhplaptop: Connecting to ec2-**-***-***-***.us-west-2.compute.amazonaws.com, port 22.
atakanarikanhplaptop: Remote version string: SSH-2.0-OpenSSH_6.6p1 Ubuntu-2ubuntu1

atakanarikanhplaptop: Remote protocol version 2.0, remote software version OpenSSH_6.6p1 Ubuntu-2ubuntu1
atakanarikanhplaptop: Net::SSH::Perl Version 1.37, protocol version 2.0.
.takanarikanhplaptop: No compat match: OpenSSH_6.6p1 Ubuntu-2ubuntu1
atakanarikanhplaptop: Connection established.
atakanarikanhplaptop: Sent key-exchange init (KEXINIT), wait response.
atakanarikanhplaptop: Algorithms, c->s: 3des-cbc hmac-sha1 none
atakanarikanhplaptop: Algorithms, s->c: 3des-cbc hmac-sha1 none
atakanarikanhplaptop: Entering Diffie-Hellman Group 1 key exchange.
atakanarikanhplaptop: Sent DH public key, waiting for reply.
atakanarikanhplaptop: Received host key, type 'ssh-dss'.
atakanarikanhplaptop: Host 'ec2-**-***-***-***.us-west-2.compute.amazonaws.com' is known and matches the host key.
atakanarikanhplaptop: Computing shared secret key.
atakanarikanhplaptop: Verifying server signature.
atakanarikanhplaptop: Waiting for NEWKEYS message.
atakanarikanhplaptop: Send NEWKEYS.
atakanarikanhplaptop: Enabling encryption/MAC/compression.
atakanarikanhplaptop: Sending request for user-authentication service.
atakanarikanhplaptop: Service accepted: ssh-userauth.
atakanarikanhplaptop: Trying empty user-authentication request.
atakanarikanhplaptop: Authentication methods that can continue: publickey.
atakanarikanhplaptop: Next method to try is publickey.
atakanarikanhplaptop: Trying pubkey authentication with key file 'my-key-pair.pem'
atakanarikanhplaptop: Will not query passphrase for 'my-key-pair.pem' in batch mode.
atakanarikanhplaptop: Loading private key failed.
Permission denied at remotecomp line 8.

Comment: Please define "doesn't work." What error messages or other symptoms are you experiencing?
Answer: These two lines
atakanarikanhplaptop: Will not query passphrase for 'my-key-pair.pem' in batch mode.
atakanarikanhplaptop: Loading private key failed.

seem to point to the issue. Your private key is protected by a passphrase, and when you try to use it, it wants to ask you for it, but can't in batch mode.
I think you're going to have to remove the passphrase from your private key to use this module. There are many tools, including OpenSSL, that can do that for you. Just search the documentation for removing a passphrase from a key.
Comment: yes, this seemed to work. thank you for your answer!

Using Net::SSH::Perl with public key


Should I insulate my attic with a hot or cold roof?

Question: I'm turning my 3rd floor attic into a usable space.  It's a hip roof, 25' x 23', with one dormer.  We just had new asphalt singles put on it and it was about 12 foot of ridge vent on the dormer / peak. The rafters are 6 inch actual.
Should I build a hot or cold roof?
If I go cold, I would have to install soffit vents (circular ones), baffles, and drill through a lot of rafters to make air ways to the ridge vent. (I didn't know about hip roof ridge vents before we had the roof re-shingled). Then I would only have room for 4 or 5" insulation.
If I go hot, I could get 2 layers of 3" 4x8 rigid foam board cut to size and seal the gaps with great stuff. This seems much easier than the spray foam kits and easier than the cold roof option.
This project is all DIY, and I don't want to add depth to the rafters and lose attic space. I've heard a cold roof can add lifetime to your shingles, but I've also heard that it doesn't matter. For energy savings I've heard that sealing and more R value is the way to go.
Comment: Typically a cold roof is to mitigate dealings with snow such as ice dams, slide offs, etc. in places that get large amounts of snow and ice. (usually in the measure of feet, not inches)  With no mention of such things my question would be why go through the trouble of a cold roof otherwise?  BTW life time of shingles is probably linked reducing freeze thaw cycles.
Answer: Oh what a shame you already did the roof. That would have been a perfect opportunity to add rigid foam insulation boards above the roof sheathing.
A vented roof is definitely better from the perspective of shingle life and moisture resistance, but with such shallow rafters and an unwillingness to lose any ceiling height, that's not an option. If you go with a vented roof, you will need to use 3-4" or so of rafter depth for the ventilation channels (depending on roof pitch; lower pitch requires deeper channels), giving you not much room to work with for insulation between the rafters. If you are unwilling to reduce the ceiling height by installing foam or mineral wool boards across them, then the room will be very uncomfortable as a result.
Your best bet at this point is to get someone to apply a full 6 inches of closed-cell spray foam to the underside of the roof deck between the rafters. This stuff is R-7, so you'd wind up with nominal R-42 between the rafters, which isn't bad. Taking into account the thermal bridging of the rafters, the actual performance would be more like R-37--not terrible, but not great. If you go the spray foam route, hire it out. The DIY kits wind up being about as expensive as hiring out the job in most locales. If you thought the upcharge to add foam to the roofing job was high, wait till you see what the spray costs. Expect $9-14 per square foot of attic space.
You can try doing this yourself with cut-to-size foam and Great Stuff filling the entire faster bays; this is referred to as "cut-and-cobble." You will definitely save money, but it is a messy, time-consuming, un-fun, thankless job, and it is more difficult to get a perfect air seal (which is absolutely required) with this approach than with spray foam. Furthermore, the R-value you'll achieve will be lower because there is no R-7 rigid foam commonly available. XPS is R-5 (yielding a whole-roof R-value of R-26) and polyiso is R-6.5 when it's hot but R-4.5 when it's cold (yielding a whole-roof R-value of between R24 and R-34 depending on the temperature).
I strongly recommend accepting a 3" loss in ceiling height and putting polyiso under the rafters. If you can live with that, you can detail the polyiso as your air barrier by taping all the seams with housewrap tape. Then then fill the whole rafter bays with cheap cellulose, which is hydroscopic so it will help wick water away from the roof deck if it does get wet. This should yield you a whole-roof R-value of R-39. Then cover that in drywall. You can do it all yourself and it won't break the bank. To improve the R-value, just add more inches of polyiso under the rafters; each extra inch will add another R-6.5. The cost difference between this and 6" of spray foam should be dramatic--maybe 5x cheaper or more.
Comment: A perfect air seal is important because it prevents humid air inside the house from touching the roof decking, which will get cold enough in the winter to make water vapor condense into liquid water. This liquid water will rot the entire assembly with no air movement to evaporate it. That's why a vented roof is more robust against this risk. But without ventilation to carry away such moisture, you need to make absolutely sure that those components stay dry in the first place.
Comment: Got the project done and feel really good about it.  Spray foam FTW.
Comment: Thanks for the quick answer!  Would I really need 4" of vent space?  Baffles are only 1 or 2" deep... Yeah adding foam above the roof was too expensive on an already expensive job.
Comment: Can you say why a perfect air seal is important?
Comment: Depends on the pitch. 6:12 would need 4" to effectively move enough air. 1" won't do much. Regardless, even if you could only get away with 2" channels, that only leaves you with 4" for insulation. Even closed-cell spray foam wouldn't be good enough with that little space to work with. You'd be looking at R-24 whole-roof, which is pretty bad.


shellscript to read log files of a docker containerised application on a remote VM is not working

Question: I have an application running on VM 100.111..* . I can use the below commands to connect to the VM and get into the docker bash to read the log file which are available at path /logs/MTServices/applogs/application.log.
Steps are :

Do ssh to VM
ssh -i ~/.ssh/dev_rsa firstname.lastname@example.com.**.***

Once connected, run the docker command sudo docker exec -it MTWLS bash

Now I am in the docker bash and I can use the command to change the directory to read the logs.

So far so good. Now When I create a shell script for the above commands and I run it, it doesn't seem to work. Below the is script.
#!/bin/bash

echo "starting"
VM_Host="100.111.**.***"
echo $VM_Host
pattern="Performing asynchronous operation for tenant"
echo $pattern
WLSType="MTWLS"
echo $WLSType

echo "running ssh"
ssh -i ~/.ssh/devus1_rsa opc@${VM_Host}
if [ "$?" -eq "0" ]
then
    echo "last command was success"
    sudo docker exec -it ${WLSType} bash
    echo $(pwd)
fi
if [ "$?" -eq "0" ]
then
    cd /logs/ETLServices/applogs
    echo $(pwd)
fi
grep -s "$pattern" application_structured.log

Answer: I cannot try it myself, but I think the problem is here
sudo docker exec -it ${WLSType} bash

Right there you're starting a new process, interactive, and pass the control to it: I think that the following lines of your script will be executed only after you close the docker process
Comment: I need to read the logs from docker bash only. when I run ```sudo docker exec -it MTWLS bash```  it prompts a different user on the same VM. then I can navigate to the dir where logs are


Unable to focus on a Mat card using viewchildren Angular

Question: I am trying to focus on a specific card from a list of mat cards
But I keep getting error

Cannot read property 'focus' of undefined

Stackblitz code
Should add a gold outline on click of button
import { Component, OnInit, QueryList, ElementRef, ViewChildren } from '@angular/core';

/**
 * @title Basic cards
 */
@Component({
  selector: 'card-overview-example',
  templateUrl: 'card-overview-example.html',
  styleUrls: ['card-overview-example.css'],
})
export class CardOverviewExample implements OnInit {

  comments: number[];
  @ViewChildren("commentCard") commentCardList: QueryList<ElementRef>;

  ngOnInit() {
    this.comments = [1, 2, 3, 4, 5, 6, 7, 8];
  }

  focus() {
    const elementRef = this.commentCardList.find((item, index) => index === 4);
    elementRef.nativeElement.focus();
//this.commentCardList[4].nativeElement.focus();

  }

}

Comment: are you using template reference or Id for your comment card?
Comment: @AjayReddy check stackblitz i put wrong link before
Answer: First, you have to assign view id to show which elements you want to query
<mat-card #commentCard *ngFor="let comment of comments" tabindex="0">Comment {{comment}}</mat-card>

Next: MatCard has not nativeElement so you have to fetch element reference
@ViewChildren("commentCard", { read: ElementRef })

And you are done
https://stackblitz.com/edit/angular-gu5kpe-bbsmbu?file=app%2Fcard-overview-example.ts
Comment: I think it came with angular2 but idk for sure as i started with 4 :)
Answer:
The "commentCard" in @ViewChildren("commentCard") should reference something, so you need to put either a component/directive type or a template variable. A template variable means that you add #name in a html-tag, like this:
<mat-card #commentCard *ngFor="let comment of comments" tabindex="0">Comment {{comment}}</mat-card>
You also need to tell @ViewChildren that you want to get the DOM element and not the Angular component, like this @ViewChildren("commentCard", { read: ElementRef }) commentCardList: QueryList<ElementRef>;

https://stackblitz.com/edit/angular-gu5kpe-dqua65?file=app%2Fcard-overview-example.ts


Android Espresso 3.0 Accessibility check

Question: I have installed new Android 3.0 and trying to add accessibility checks to my tests.
According to the documentation here https://developer.android.com/training/testing/espresso/accessibility-checking.html one is supposed to add the @BeforeClass annotation and everything will be great.
The thing is that when I run the tests now with AccessibilityChecks.enable(); I get "Empty test suite" when I actually have tests there and they are running correctly when I do not have this AccessibilityChecks.enable() included.
Somebody experienced the same behaviour?
Comment: I am seeing the same issue.  I am using 3.0.1 and Kotlin.  I created a companion object (static method) and only get the error "Empty test suite" when i try running the tests with it included.
Answer: I had exactly the same issue.  When I switched to deprecated:
AccessibilityChecks from import android.support.test.espresso.contrib.AccessibilityChecks; my tests's started and it's showed accessibility errors.
I know that's not the long-term solution...
Comment: you found any solution for this ??


Syncing contents in instances in Auto scaling group under load balenecer

Question: I have EC2 instances with WordPress in an auto scaling group behind a load balancer. It is created from my customized AMI with everything done. Suppose a new user in WordPress writes a post or uploads photos. How can I sync those content in all my instances in the ASG?
Answer: It depends on where your data is being stored. For example, if the WordPress posts are stored in RDS and the photos are stored in S3 (a pretty robust setup), the EC2 instances would always be looking at the same data, so they would always be in sync.
Comment: thx tom......so if i sync the html contents to s3 and back using cron tab...whether it will cause too much latency....or is it enough?
Comment: Ideally your WordPress site would just be storing and retrieving things like photos in S3, and not at all in the local file system (same for posts: all in RDS, nothing stored locally). If you have no option but to store locally for some reason, you could consider [AWS EFS](https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html) so that what appears to be a local directory to WordPress is actually an NFS mount that provides all EC2 instances with the same data.
Comment: thx tom for your reply....How could i use EFS as i have multiple autoscaled instances and the number of instances increases as cpu utilization increases(rule that i had given in asg).
Comment: After creating an EFS file system, you'd probably want to configure the EC2 instances to mount it automatically on start-up (with [cloud-init](https://docs.aws.amazon.com/efs/latest/ug/mount-fs-auto-mount-onreboot.html#mount-fs-auto-mount-on-creation), for example). Then you could configure WordPress to save things to whatever directory EFS is mounted as. Keep in mind that all the instances will be accessing the same file system simultaneously, which could cause file locking and race condition issues depending on how you're accessing it.
Comment: Thx Tom for your solution.


Drupal, CKEditor: custom formatting options issue

Question: For some reasons the checkboxes in "custom formatting options" are always selected. Even if I unselect them and save them, they remain selected.
Screenshot: http://dl.dropbox.com/u/72686/customFormattingOptions.png
Could you explain me why ?
thanks
Answer: Sounds like the form is not submitting properly, and just keeps using the old values. As a temporary fix, you can either:

Debug the module's PHP code and fix the form submission yourself
Or look in the database and manually make the necessary changes to the configuration (might be in the variable table or in a custom table created by the module itself)

As a more permanent solution, I'd file a bug in the module issue queue for the module you're using to integrate CKEditor on your site. If you tell us what version of Drupal and what module (and its version) you're using to integrate CKEditor with Drupal, someone here might be able to debug the code as well.


How important is soffit ventilation with tiled roofs?

Question: While attempting to install a security camera in the soffit of my bungalow home, I noticed that there is wood paneling beneath (above) the soffit. The soffits are aluminum, and it looks as though there are breathable soffit panels every 12' or so. The wood appears to be solid, I assume where the breathable panels are there is a gap in the wood.
EDIT: My brick bungalow is approx. 1100sq/ft, My roof pitch is 8/12. Just before the peak on one side there are 4 roof vents, evenly spaced. In addition, there are gable vents close to the top of the brick at either side of the house.
My roof tiles appear to be in good condition, but I am concerned that I do not have enough ventilation intake. Is it still recommended to have wood above soffits? Am I risking damage to my roofing tiles by leaving this for a couple of years, or is it recommended to deal with this asap (if ventialtion is indeed inadequate)?
Comment: You have a lot of doubt in your first paragraph about what's up there actually ventilating your attic. You need to get into you attic and find out these answers before you decide you have a problem.
Comment: Your question is really about ventilation, not soffits. You should revise to describe your ventilation situation more thoroughly. It could be that you have other ventilation mechanisms that preclude the need for soffit vents.
Comment: Thanks for the feedback. I don't believe there is another method of air intake though, so I'm not sure how to revise.
Comment: Soffit vents require ridge vents (or at least gable vents) to be effective. Any ventilation loop needs an in and an out. Find out what your situation is and get back to us. If you don't have a question in the meantime, maybe just delete this one.
Comment: Many thanks - I have made the suggested edits, and revised the question to be more specific.
Comment: The question is still a bit off kilter. You _assume_ that there are openings in the wood soffit, but that's key to this discussion. You need to know how much area is open. Also, it's common to find plywood (old) soffits covered with metal. That in itself is not a concern. What's maybe concerning is that no (or not enough) openings were cut through it before covering it up.
Answer: Attic Ventilation shall be "cross ventilation " and shall be 1/150th the area that is to be vented. (See ICC R806 Vents.)
However, there is one exception: The attic ventilation can be reduced to 1/300th the area to be vented provided one of the following items are met:
1) a Class I or II vapor retarder is installed on the "warm-in-winter" side of the ceiling, or
2) not less than 40% and not more than 50% of the ventilation is located in the upper portion of the attic. The upper portion is defined as: "Upper ventilation shall not be lower than 3' below the ridge or highest point of the roof. "  (See ICC R806.1.2.)
Also, the Code says you'll maintain a 1" clearance between attic insulation and framing.
So, you can see there is clearly a benefit to having ridge vents, gable vents, etc. , but in a proportion that allows COMPLETE CROSS-VENTILATION to the attic....and cross ventilation is best with soffit vents.
Remember, you're venting the attic to remove condensation. Condensation damages wood, not your tile roofing. I'd act quickly.


Restriction of smooth map to open domain calculus

Question: Suppose $f: \mathbb{R}^n\rightarrow \mathbb{R}^m$ is $C^{\infty}$ at a (continuous and has continuous partial derivatives of all order). Let $U$ be an open set containing $a$.
Then, $f|_U: U\rightarrow \mathbb{R}^m$ is $C^{\infty}$ at a.
My idea was to note that $f|_U$ is continuous since we are restricting the the subspace, and for sufficiently small $t\rightarrow 0$, the partial derivatives of f are the partial derivatives of $f|_U$.
Is this reasoning correct?
Comment: Yes, it is correct.
Comment: Written differently, we have that the partial derivatives all satisfy $\partial_i(f|_{U}) =(\partial_if)|_U$. From this, the claim can easily be deduced.
Answer: Differentiability is a pointwise question that requires local statement. $f$ is said to be differentiable at $x$ if there exists a linear map $u_x : \mathbb{R}^n\to \mathbb{R}^m$ such that for small $h$, $f(x+h) = f(x) + u_x(h) + o(\|h\|)$. It is $\mathcal{C}^1$ if it is differentiable everywhere (pointwise statement) and if $x \mapsto u_x$ is continuous (local statement again).
Recursively, you can define what $\mathcal{C}^n$ and thus $\mathcal{C}^{\infty}$ mean.
So if the definitions are true for $f$ over $\mathbb{R}^n$, they are still true for an open subset $U \subset \mathbb{R}^n$!


Why is mat-checkbox inside *ngFor not getting the latest [checked] value from model?

Question: <ng-container *ngFor="let item of items">
     >>>>>>>>LINE 2>>>>>>>>>> {{item.checkedOrUnchecked}}
     <mat-checkbox [checked]="item.checkedOrUnchecked"></mat-checkbox>

LINE 2 in above code is always in sync with changes done else-where.
However, mat-checkbox is not updated with true/false. Its losing the context here. Even if *ngFor is creating a child-context for every iteration, when LINE 2 is able to pick the latest updates why is mat-checkbox not able to be in sync.
One thing I noticed is, if the initial value of item.checkedOrUnchecked is false and if it is changed to true, mat-checkbox is checked. But, further toggling of item.checkedOrUnchecked from true-to-false or false-to-true doesn't have any affect.
Issue can be replicated here https://stackblitz.com/edit/angular-material2-checkbox-issue-zyjhd3
Plz can someone advise.
Answer: Change this :
[checked]="item.checkedOrUnchecked"

to
[(ngModel)]="item.checkedOrUnchecked"

Here is the working example of it, please have a look :
https://stackblitz.com/edit/angular-material2-checkbox-issue

Your demo with issue : https://stackblitz.com/edit/angular-material2-checkbox-issue-zyjhd3
Issues :
1) Missing let i =index; from *ngFor="let property of properties;let i =index;"
2) So was not passing correct value from here saveProperty($event, i)
3) this.properties[index][key] = property[key] , property[key] is string not boolean , so need to be converted to boolean
Solved : https://stackblitz.com/edit/angular-material2-checkbox-issue-tbutvp
Comment: @nsk, I have also created a demo, please check updated answer.
Comment: Updated question with my demo where am facing actual issue with EventEmitters etc.


How do I remove painted knockdown texture?

Question: We scraped our popcorn ceilings and had somebody do knockdown texture in the whole house. Problem is, that when the guy went to prime over the texture, some of the texture started peeling off on the roller in the master bedroom and living room. There may have then several issues that caused this... Including mixing The Home Depot Tuf-Tex bag incorrectly, possibly the ceiling still had some popcorn dust on it, we're because we're in Florida, the humidity may have gotten to it.
I really believe the problem lies in the mixture or application... Because the guy inspected the ceiling, said we did a really good job, and even though we're in Florida by the water, the temperature has been low and relatively dry during this whole process. he tried to blame it on everything else but himself, but it didn't add up.
Anyhow, he went back and patched the parts that peeled off, but when we went to go paint over it with a sprayer using a pretty light coat, with in just a couple of hours it started spider cracking everywhere. All this is besides the point though...
I really fear just patching again because it could crack in other areas after we did the next layer of paint... And besides, especially in the living room, the cracking is bad all over the place... So we're considering taking it all down, and redoing everything from scratch, possibly using somebody else, and possibly priming prior to texturing.
At any rate... The texture comes off fairly easily on about 30% of this 14x22 ft ceiling. The issue is the other 70%, where removal seems fairly difficult even with water.
What I'm considering doing he is using a sander with a back attachment or something to try to at least get through some of the paint and primer before trying to wet scrape again. I've read about skim coating... But the ceiling, being 14 X 22, seems like a huge job to tackle that way properly.
Can anyone please recommend a decent sander to use? Hopefully one thats affordable since we've already spent so much money on this remodel.
Either that, or please offer an alternate method or tips to tackle this issue.
Please note that hanging new drywall underneath the old drywall is probably not an option because some of the walls have mirrors going all the way up to the ceiling and other trim that gets in the way. We could possibly replace the ceiling all together, if that seems like a huge daunting task... Let alone expensive.
Thanks in advance for any advice given!
Comment: Think about a small tapered edge molding for the ceiling with the thin edge toward the walls, and then 1/4" drywall overall.
Comment: There are no bare walls. :( Theres a rough plaster wall, a mirrored wall, a stone wall, and the 4th side is open with a wooden beam across the ceiling.
Comment: The molding is meant to make a frame on the ceiling to surround a new thin drywall application. It doesn't even have to go exactly to the edge, just serve as a transition from the thicker middle to the old level.
Answer: I don't know that replacing the drywall for that little a space wouldn't be the best route.  Seems the cleanest.  Removing trim isn't hard.  I don't know about the mirrors, though. Renting a drywall jack is cheap and makes it a ton easier to hang.  A bit of demo and hanging a new ceiling sounds easier than messing around with something that isn't working out.
Beyond that, I don't know about knockdown texture, but sanding down a ceiling without a drywall sander sounds like it sucks and trying to water/scrape it sounds like it sucks and is super messy.  Demoing drywall is quick.
No expert here.  I'd just replace it.  Seems the surest, which is the direction I like to steer.
Answer: You can buy or rent a drywall sander that has abrasive pads and a vacuum attachment that collects the dust. This is what I had to do when I experienced the same issue with my bathroom ceiling.
Answer: I had the same issue as I described here
I completely got rid of the texture by scraping it off. I used a Black and Decker matrix sander attachment (that's what I had) with 80 grit sandpaper.
To answer your question about the sander, this is what I used:

Black & Decker


How to use a string value as param in function using string pointer variable as input parameter

Question: This is the function I am coding now-
insertobjectnames(std::string clsname, std::string objname)

Now within the above function I have to invoke another function that takes as input the same parameters as above 2, but first one as string and second one as string pointer variable
The declaration for the second function is given below-
 int  analyse(const std::string key, std::string * key2)

How do I use the objname parameter from the first function to invoke the second function above? The second function (within itself) extracts the value of key2 from the parameters and then uses them as per requirements.
Comment: First, there's usually no good reason for `analyse` to expect a pointer for `key2`. It should take a reference (or a const reference, if it's not going to modify key2). Similarly, using `const reference` parameters instead of passing strings by value is preferable.
Answer: The & operator in C++: its the address-of operator: basically a variable to pointer converter! Ex:
int a = 0;
int *pointertoa = &a;
//So
std::string s;
std::string *ps = &s; //Extracting the "key" ps is a pointer to s
analyse(key, &objname); //should be the right way to pass the parameter as a pointer

Comment: @awesomeyi- AFAIK SO asks for answers- hence please post the answer otherwise I cannot accept your hint as the answer.(And I have understood what you mean- thanks a  lot :) )


How to best explain to users how their details will be used?

Question: What would be the best approach to explain to users that their information will be used to:
1- help authenticate them if they do get locked out of their account.
2- Communicate with them regarding products and services.
The main difficulty i am facing is that we are attempting to capture:

2 emails ; both Primary and Recovery
Mobile and landline numbers

In addition we also need to be able to verify those details.
I would like your opinion on:
How best can this be achieved via language and UI so as to provide a seamless experience?
What are UX best practices when capturing and verifying user details particularly when it comes to UI?
Comment: Basically, don't do it all in one form. Walk them through a series of steps and provide a concise explanation of why you need info X, Y, and Z. If you need to verify stuff then do it in the step where it's relevant.
Answer: look at how for example facebook handles this:
first they show you what the website can and might access
and under that it shows you what it cant do.
this order is important so the user understands what he accepts when giving you his information and what he doesnt need to worry about when accepting the form.
https://i.stack.imgur.com/VXj43.png
sorry this is in german but im sure you know this form


Youtube search API always consuming 100 units

Question: I use the Youtube V3 Search API to get only 1 video ID:
<code>https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=skating&fields=items%2Fid%2FvideoId&key=my-key
</code>
The result of this call is:
<code>{
    "items": [
        {
            "id": {
                "videoId": "rYEDA3JcQqw"
            }
        }
    ]
}
</code>
The problem is that this is costing me 100 units!
Does anyone have any idea on how to fix this?
Answer: If you know the videoId, don't use the search API, but the videos API instead
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=u6ZSgqS37kM&maxResults=1&key=[YOUR_API_KEY]
This costs only 3 units instead of 100.
If you really want to search, there is no way to go under 100 units, that's the normal quota for search. However, you can set maxResults to 50, so you will get 50 results for the same 100 units.
You can use the quota calculator to find out the exact numbers: https://developers.google.com/youtube/v3/determine_quota_cost
Comment: Thanks. I don't know the ID, so I really need to search. I have BTW just abandoned a side project because of this ridiculous request costs.
Comment: One possible solution I use is to open a youtube page with the search from your page and scraping the results page. It has many drawbacks though, on the first place it's quite complicated to put together.
Comment: It's such a high cost. Truly ridiculous.
Comment: Agreed, I had to abandon it in a project as well as the limit makes the API useless.


Tankless Water Heater with Natural Gas Line possibly too small?

Question: Inspector thinks flex appliance gas line being only a 1/2" line approx 30" in length may not be sufficiently allowing enough gas to flow for the amount of BTUs the tankless water heater can
demand.
This specific tankless water heater can do 160,000 BTU/H
Model: RUCS75i → REU-KCM2528FFU-US
EDIT: Added a chart table from manufacture's guide for further clarification.
Comment: The heater comes with a 3/4" connection. That the table they include for Natural Gas (as opposed to Propane) does *not* include 1/2" connection is another indication that 1/2" is not such a great idea. Based on some rough calculations (since this is far out of my usual domain) including looking at charts from other places, it looks like 1/2" would be *marginal*. Given all of that, and the easy access and short distance, upgrading to 3/4" would make a *lot* of sense.
Comment: What does the manufacturer's technical literature say? If they put a 1/2" port on their equipment and provided a 1/2" hose, then it's probably fine. To minimize the phone calls after each inspector expresses this same reservation, I expect that a manufacturer would specifically name the 1/2" hose as sufficient in its documentation.
Comment: Are you supplying natural gas or propane? Who did the hookup, you or a licensed plumber? Why does there not appear to be a gas shut-off valve?
Comment: There seems to be a reducer on the line so going up a size should be easy.  Those tankless heaters do take a lot.  Surprise the inspector is only thinking/guessing it is not big enough, they should have charts showing exactly what is needed for the BTUs.
Comment: @popham I uploaded a screenshot of gas pipe sizing and approach from the manufacturer's guide. Not too sure how to read it, maybe that further clarifies for you?
Comment: In our house one 3/4" line splits into two 1/2" lines to supply both a 120 kBTU/h Bosch Aquastar NG tankless and a 100 kBTU/h NG furnace.  Neither one shows signs of low gas flow. Your short length of 1/2" will be no problem if your gas pressure is OK. Ours is supposedly 0.25 psig or about 7" WC. You should have a shutoff valve on the solid gas pipe before the flex line. When you have the valve installed they could change to 3/4" all the way. I do not think you need it, but if your gas pressure would drop maybe you would. also later someone might want a 199 kBTU/h tankless.
Comment: You would probably not see any change in performance by changing to a 3/4" flex line. But if you want to measure performance before you change you could set output temp high (say 140 F) and measure flow rate at an unrestricted faucet like a tub spout or a laundry room hot faucet on full open.
Answer: I grabbed the spec sheet for your unit and based on that information, 1/2" gas line is okay.  Though a shut off valve needs to be located in the same room as the appliance the line serves, so that should be addressed.  Also, I guess it's a "no no" to use teflon tape on the flex connection as it relies on pressure against the tapered fitting.  (based on what I've read)
Comment: Personally, I'd go by whatever size the inlet is.  Where the flex line attaches, is there an adaptor on the bottom of the unit that increases the 1/2" to something larger?  For the cost and time it would take to switch out the 1/2" flex to 3/4" to make everyone happy, I'd just do it and be done with it.  I ran 3/4" to a Mr. Heater even though it steps down at the unit.
Comment: I saw that too. So far I'm getting kind of mixed messages. On another plumbers forum the response I received was that it was undersized. The spec sheet says 1/2 compatible. The Owner's guide (attached in the OP) doesn't include 1/2 pipe size in the table.
Comment: With no gas appliance knowledge, but while wearing my "marketing-speak decoder ring", I would read "½ in. compatible" as meaning no more than that it is safe to use, and will "work" (but not necessarily at full capacity).


How many positive integers $<1{,}000{,}000{,}000$ consist of 1's and 2's only?

Question: My understanding is that there are 9 "places" to be filled-in with 1's and 2's and the numbers $111{,}111{,}111$ and $222{,}222{,}222$ should be discarded.
Hence my answer is $2^9 -2$ but the book says $2^{10}-2$. What am I missing?
Comment: You forgot about numbers 1122,1221,112
Comment: Why should $000,000,000$ be discarded? Did you include it in your count of $2^9$? And why should $111,111,111$ be discarded?
Comment: My apologies. I meant 111,111,111 and 222,222,222 should be discarded. As far as I understood the number must have both 1's and 2's. I'm I right?
Answer: I don't understand why you're discarding 111,111,111 (or counting 000,000,000 in the first place).
There are $2^9$ $9$-digit numbers consisting only of $1$s and $2$s, but then you need to include the $8$-digit numbers (of which there are $2^8$), and so on down to the $1$-digit numbers. What do you get when you add all those possibilities up?
Comment: Due to the fact he wrote 000,000,000 instead of 0, I'm confused as to whether a number such as 000,121,212 would count as per his example. The book's answer agrees with you, however.
Comment: Ah now I see.  I was mistakenly discarding numbers such as 000,121,212.
Answer: Let

$f(n)::=$ the number of positive integers, of which the length is equal to n, and consisting of 1's and 2's only.

What you want is $f(1)+f(2)+\cdots+f(9)$.
Then,

$$f(1)=2$$

because only $1,2$ is legal.
Then (think about it :),

$$f(2) = 2f(1)$$

Then,

$$f(n)=2f(n-1)=2^2f(n-2)=\cdots=2^{n}$$

Therefore, the answer should be $2^{10}-2$.

Thanks for pointing out my mistakes by @Jaap Scherphuis and @Evargalo.
Comment: This is wrong. Your $f(n)$ counts numbers of any length up to n, but you can only extend the ones of exactly length $n$ to length $n+1$. Your recursion should really be $f(n) = 2(f(n-1)-f(n-2)) + f(n-1)$, but it is easier to just count those of length exactly $n$.
Comment: The recurrence rule is not valid. From the number $12$, smaller than $10^3$, you're building the number $2012$, smaller than $10^4$ but that doesn't fit the exercise.
Comment: @JaapScherphuis Yes, you are right.