GameObject in SerializedField - OverRide - Apply All: Prefab Doesn't Update

Question: I added a script to my prefab. Then I put my prefab into my scene and drag/dropped the GameObjects into the appropriate fields within the inspector. I then clicked OverRides>>Apply All. (Which is common and I do this all of the time)
However, the game object I'm using for the Spawn Zone when the Game Object will be Instantiated will not apply to my Prefab. (The Prefab in the scene does have the Empty Game Object attached but not the main Prefab in the Project panel)
I'm using the same method that I use for Instantiating bullets but for some unknown reason the Project view prefab will say "None(GameObject)"
Here's the code:
[SerializeField]
private GameObject boss;
[SerializeField]
private float bossSpd;
[SerializeField]
private GameObject bossSpawnZone1; // This won't apply to my prefab in Project panel

private void Update()
{
    if(startBoss == true)//StartBoss occurs when a GameObject is touched by player on another script. Just OnTriggerEnter2D set var to true
    {
        GetTheBoss();
    }
}
void GetTheBoss()
{
    Instantiate(boss, bossSpawnZone1.transform.position, Quaternion.identity);
    startBoss = false;
}

I would include pics but I don't know how to upload them in here. Never used the IMG  URL before. But trust me, I inserted the empty gameobject(SpawnZone) into the field. I also used the override to apply all. Yet the spawn zone field remains empty.
What I've tried:
1) Removing the script and re-adding it then filling the fields again.
2) Made the spawn zone public static and tried using GameObject.Find("PirateSpawnZone") in another script pertaining to the player.
3) Changing the variable name and saving the script.
4) Restarting Unity / Restarted computer completely then open Unity back up.
Comment: @derHugo I put the prefab into the scene and I inserted the fields on that prefab. Then I applied the update. All fields are filled except the spawnzone. I use this technique all the time so I'm confused as to why all of a sudden it is refusing to accept the gameobject upon Override>>Apply All
Answer: You can not have Scene references in a prefab. It is not possible. It only works for GameObject reference that are themselves a prefab living in the asset or references within one and the same prefab hierarchy.
However some workarounds exist
dependency injection
using dependency injection (e.g. Zenject)
ScriptableObject references

a ScriptableObject for setting the reference on scene start and referencing the ScriptableObject instead.
[CreateAssetMenu(filename = "new GameObjectReference", menuName = "ScriptableObject/GameObjectReference")]
public GameObjectReference : ScriptableObject
{
    public GameObject value;
}

Create an Asset by right click in the Assets → Create → ScriptableObject → GameObjectReference
Then change your script field to
[SerializeField] private GameObjectReference bossSpawnZone1;

and everywhere where you use it use bossSpawnZone1.value instead.
This works now since the ScriptableObject instance itself lives in the Assets.
Then finally you need the setter component on the bossSpawnZone1 GameObject like
public GameObjectReferenceSetter : MonoBehaviour
{
    [SerializeField] private GameObject scriptableAsset;

    private void Awake()
    {
        scriptableAsset.value = gameObject;
    }
}

Singleton pattern
having only the setter and making a public static reference (only works if there is only exactly one of those reference in the entire scene/game
public class SpawnZoneReference : MonoBehaviour
{
    public static GameObject instance;

    private void Awake ()
    {
        instance = gameObject;
    }
}

And in your script instead use
Instantiate(boss, SpawnZoneReference.instance.transform.position, Quaternion.identity);

Or very similar using only a certain type like
public class BossSpawnZone : MonoBehaviour { }

On the GameObject and in your script do
bossSpawnZone1 = FindObjectOfType<BossSpawnZone>();

Comment: I'm going to accept this answer because you are 100% correct and not only that but very thorough with the explanation. However, my problem is that I forgot one key element... I was trying to instantiate the object on the movement script. So you were right in your first comment, it just took me awhile to figure it out. I fixed this by creating a "PirateSpawn" Script and put it on the object I wanted to trigger instantiation. Which allowed me to place the game objects into the fields. The bad part about all of this is that I know better than this, so I'm kinda embarrassed that I missed it!


Transfer software from another Ubuntu

Question: I and my friend has Ubuntu. I want to get a software from his lap to my lap. How can I copy the software?
Note: I couldn't download the software from net as the software is no longer available.
Answer: You can see all the files in a particular software package with dpkg -L packagename. You can find out which package an executable is in by typing dpkg -S $(type -p executable). If you installed "a software" with some method other than dpkg, apt-get, synaptic, etc, you are on your own.

Transfer software from another Ubuntu


Angular2 and social sharing crawlers

Question: As far as I understood, the social crawlers like the one of Facebook do not evaluate Javascript, therefore when you use Angular 1, if you wanted to let any pages of your site being properly shared on Facebook, you would have use services like prerender.io or follow tutorials like the following to implement the sharing of the content and not not rendered tags.

Enable Rich Social Sharing in Your AngularJS
App
How to support social sharing for AngularJS apps using Facebooks
Open Graph
tags

I'm asking myself if that side effect is maybe solved straight forward in Angular 2? Or do these solutions are still the one to apply?
Comment: [Angular Universal](https://universal.angular.io/) could be what you're looking for.
Comment: Thx for the idea gonna have a look. My site is directly served from nginx so I should check if universal is also applicable in that situation
Answer: I followed the advice of @federico-p and implemented a Angular universal app
Therefore I based my implementation on the following starter-app:
https://github.com/angular/universal-starter

Angular2 and social sharing crawlers


Stuck Screen Using NVIDIA GeForce GTX 970M on Ubuntu 16.04

Question: I'm facing a problem with NVIDIA driver on Ubuntu 16.04. I've been reading overwhelmingly of forums and blogs, although, nothing helped me at the moment.
I'm using a Clevo P650RE laptop, which there is the bellow configuration:
NVIDIA GeForce GTX 970M 3GB
Core i7-6700HQ Processor (6M Cache up to 3.50 GHz)
32GB DDR4 2400MHZ

After installation of Ubuntu 16.04, a popup is showed with the follow message: "Installation is complete, You need to restart the computer in order to use the new installation"
Thus, I click on the button "Restart Now", then the laptop get stuck and I'm obligated to hold the button power and force the restart.
When I get the Login Screen and type my password then the Ubuntu gets stuck,then once again I have to hold the power button.
I saw the bellow procedure:
To start Ubuntu into safe mode (Recovery Mode) and remove the NVIDIA driver type at terminal:
$ apt-get remove --purge nvidia*

After it, I could go through the login screen and I got able to use some applications such as Firefox and Terminal, however, when I click on System Settings, then the Ubuntu stuck again and the only way I have is holding the power bottom.
I tried to install the NVIDIA driver (NVIDIA-Linux-x86_64-367.35.run):
LINUX X64 (AMD64/EM64T) DISPLAY DRIVER
Version:    367.35
Release Date:    2016.7.15
Operating System:    Linux 64-bit
Language:    English (US)
File Size:    72.1 MB

Unfortunately, it doesn't work as well.
Does someone has an idea for this issue?
Thank you in advanced.
Comment: Have you tried solution from http://askubuntu.com/questions/760934/graphics-issues-after-installing-ubuntu-16-04-with-nvidia-graphics with switching to tty and installation of drivers from ppa:graphics-drivers/ppa repository ? Use `sudo apt-get install nvidia-367` instead of `sudo apt-get install nvidia-364`.
Answer: the problem is fixed, the solution is on the below link:
http://forum.notebookreview.com/threads/clevo-p650re-running-ubuntu-16-06-stuck-nvidia-geforce-gtx-970m.794709


PHP - How to handle same class in php wordpress

Question: Consider we have an SDK that will be included in wordpress with other plugins like freemius. So we have a class in our SDK.
class prefix__SdkClass
{

}

So suppose this SDK will be included in 2 plugins. There will be a fatal error because of the same classes in both plugins. So i will include some sort of versioning in my SDK so that when the SDK is installed in both plugins the SDK with the latest version should be used?
Answer: The Wordpress Best Practices recommends using either prefixes or namespaces to avoid such collisions. Also, keep in mind that the user may use different versions of your two plugins. If one plugin uses an outdated SDK and the other one has the newer SDK which removed funtions of the old SDK, as soon as you force using the newest SDK may break the older plugin.
In your case of using the same SDK in two different plugins, I would go for:
plugin 1
<?php
class prefix1_SdkClass
{

}

plugin 2
<?php
class prefix2_SdkClass
{

}

or using PHP namespaces:
plugin 1
<?php
namespace Plugin1;
class prefix_SdkClass
{

}

plugin 2
<?php
namespace Plugin2;
class prefix_SdkClass
{

}


Are there any missions besides the penultimate one that intel can be spent on?

Question: I've just finished my first playthrough and was surprised to note that when I prepared for the penultimate mission, the option to spend intel for various special effects was available - increase the squad size, better concealment, etc. I never noticed this on any other mission, but it seems a neat concept and it struck me as unlikely that there would only be one mission in the entire game where this is possible.
I am thinking that maybe the options were never presented the rest of the time because I tended to be running at very low intel, spending it immediately on things from the black market, but by chance I had intel at about 300 going into that mission (playing on normal). Was I just missing the options the rest of the time or is it really the case that this is the only mission you can spend intel on?
Answer: This really is the only mission you can spend intel on. (This mission will actually show all of its options regardless of how much intel you have. I used this to spend time to gather more intel in my first playthrough.)
At some level it make sense - the penultimate mission is a planned strike, that XCOM would have time to prepare for. The only other missions like that are the facility strikes and blacksite investigations, but those are all in remote areas that would be very difficult to perform recon on without being detected. The penultimate mission appears to take place in a city center, where one could presumably gather intelligence for some time prior to an assault.


Cannot step into the code while debugging a C DLL file in Visual Studio 2012

Question: I have a separate Visual Studio solution with the DLL written in C. I use it in another solution; in a console C++ project. While debugging the console project I step into a DLL function.
However, the page is opened reporting that There is no source code available for the current location with call stack location MyConsole.exe!_tailMerge_MyLibrary_dll(). I use delay loading of the DLL file in the console project. As the no source code page is displayed, I inspect the output window and find symbols loaded of the DLL line. Why does Visual Studio 2012 fail to step into this DLL code?
Comment: Is your dll is built with debug information ?
Comment: Generate Debug Info: Yes (/DEBUG)
Comment: I don't know for sure, but it sounds like VS is able to load the dll, but it doesn't know where (on your machine) to find the source files. The dll contains the binary it needs to link and compile, but it doesn't have the physical source files with it. I would suspect you need to import the files that make up the dll into your project and point it to the files in order for the debugger to be able to let you "step" through them.
Comment: I added dll project to test console solution without any result. the source code is still not found
Comment: @AlvinWong then it needs to add dll project to solution where c++ console is and add a project reference to the console project?
Comment: @AlvinWong I added dll project to test console solution and added reference to dll project in test console project. still can not locate the sources
Comment: I wonder if there are any bugs in Visual Studio 2012?
Answer: I had the same problem and the following solved mine. I set "Debugger Type" to "Mixed" on the properties page of the main project. My main project is managed code while the .dll is native.
Answer: It happens, when dealing with external projects that Visual Studio asks you if you have the code.  If you cancel the process, the requested file gets added to a list in the solution and it remembers NOT to ask for the file again.
Check your Solution Property Pages > Debug Source Files. First, make sure your file is NOT in Do not look for these source files: and then make sure you add the location of the sources in the Directories containing source code. This should help fix the problem.
Comment: I added the folder with dll sources without effect
Comment: there are no problems with c# console project
Comment: Did you generate the PDB for your DLL?
Comment: by all means, that would not have worked in c# test console project then
Comment: and browse to its sources with step into? that is not possible. be sure there is pdb generated in debug build
Comment: Isn't that what you're NOT able to do, to browse the sources? I'm not sure I understand your issue...
Comment: yes, I can not browse to sources of the c dll project from c++ console project. I can browse to sources from c# console however using the same step into while debugging


Setting up redis cluster on Mac OS X via create-cluster script

Question: I want to set-up a redis cluster on Mac via the create-cluster script as mentioned in Cluster tutorial. I am not able to locate the create-cluster script on Mac.
I am using redis 3.2.0 installed via brew on Mac OS X 10.11.6 (15G31).
Can someone let me know where create-cluster script is located in Mac?
Comment: https://redis.io/topics/chttps://redis.io/topics/cluster-tutorialluster-tutorial
Answer: I'm on Mac 10.15.5, have installed the Redis 6.0.5 via brew, and don't see create-cluster script too within such installation.
So, I followed the following steps:

Donwload the latest manual installation, i.e. redis-%version%.tar from the official site.
Copy the folder utils from dowloaded archive to my local redis destination folder, i.e. /usr/local/Cellar/redis/6.0.5 in my case.
Change create-cluster file. There are settings inside: BIN_PATH="../../src/" to BIN_PATH="../../bin/" in order this cluster script can find the related redis scripts.
Follow the guide https://redis.io/topics/cluster-tutorial

For me it works now.
Answer: I was not able to create cluster via the redis installed via brew. So I did the following:-

Downloaded the latest version from Redis from here. In my case Redis 3.2.5
Then followed the installation instruction as mentioned here.
create-cluster is located inside $DOWNLOAD/redis-3.2.5/utils/create-cluster where $DOWNLOAD is the location where I downloaded and untar the redis.
Comment: create-cluster should exist with brew installation
Comment: @K'' Where would that be found?
Comment: @wmute i'm on high sierra 10.13.4 and i can find it under /Users/username/opt/redis-4.0.2/utils/create-cluster
Comment: Interesting. I don't see that on high sierra. I ended up using a Docker container which was much easier.
Comment: FYI, to run through __creat-cluster__ use `sh create-cluster start`, more info go https://redis.io/topics/cluster-tutorial and navigate to __Creating a Redis Cluster using the create-cluster script__
Comment: Broken old redis tgz link. Use https://redis.io/download


Is this a P trap or a S trap?

Question: We bought a new dishwasher and it still leaves the dishes smelling like rotten eggs.
After some research I came across information that a ptrap is required to stop the smell from drain. The pipe connection behind the dishwasher looks like this. Pls can someone tell me whether this can be classified as a p trap or it is still a s trap
Comment: Looks like a S trap, but just need to get of the black elbows.  Rotten egg smell might be coming from your water itself.  The heat of the dishwasher making it worst than from the cold water.
Comment: Is the end of that flexible hose from the washer just loosely poked into the end of the vertical standpipe, or is it sealed somehow?
Answer: That's clearly an S-trap - or rather, a P-trap (white) converted to being an S-trap by the arrangement of black pipe fittings after it.
You'll need to lower the P-trap so the outlet is in line with (technically 1/4" per foot higher, so about 1/16" inch higher at a guess here) the pipe entering the wall, and change to an elbow coming out to the side to meet it, as opposed to the "up-and-over" that's making an S.
You might want to look into "hub-saver" or "socket-saver" tools to make re-using the fitting in the wall practical, rather than needing to tear the wall open to replace that fitting.
Comment: I can't understand your 2nd para. 1/16" wouldn't make that much difference, would it?
Comment: All "horizontal" Drain lines should (*i.e.* it's code) actually slope downhill to the drain. Looks like about 3", so 1/16 of an inch is the required 1/4" per foot or 2% slope.

Is this a P trap or a S trap?


How do you disconnect a TV cable that runs all along the walls throughout the house?

Question: Is it dangerous to disconnect it by myself, or is the standard protective gloves and shears sufficient?
The cable was installed by Time Warner Cable company, and now we no longer have their service.
Comment: Can you elaborate on some details? Where are you disconnecting it from? What is the end goal?  Depending on what you want to achieve, you may want to leave the cabling itself for other TV service to user later.
Answer: The co-ax TV cable in the house is considered "low voltage" and shouldn't pose a hazard to people (unless something is seriously wrong with the wiring, like it touching the mains somewhere).
First, I'd ensure that the cables in the house are disconnected from the cable service line. There should be a grounding block on the side of the house where the house's cable lines connect to the service lines. They may look something like:

Disconnect the "house" side cable from the block, and then cut or tear out whatever cable you'd like. After this disconnection, the line should not be energized at all. As GrecMac commented, it is a good idea to use a non-contact voltage detector to ensure that the cables do not carry a dangerous voltage.
Comment: I'm pretty anal about using a non-contact voltage sensor whenever I work on mains wiring, but unless the house is full of questionable wiring (junctions not in boxes, extensions cords used as interconnects, missing grounds, etc) it's generally pretty safe to work with. Usual caveats apply: if you're concerned, check it with your sensor. Don't work with any wiring during a lightning storm. Use common sense.


Update android SDK : install latest platform to implement new APIs such as "ShortcutManager"

Question: Here i am performing demo for Android Shortcuts introduces in android nougat App Shortcuts
I have used following code to create app shortcut
ShortcutManager shortcutManager;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
    shortcutManager = getSystemService(ShortcutManager.class);
    ShortcutInfo shortcut;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
        shortcut = new ShortcutInfo.Builder(this, "second_shortcut")
                .setShortLabel(getString(R.string.str_shortcut_two))
                .setLongLabel(getString(R.string.str_shortcut_two_desc))
                .setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
                .setIntent(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://www.google.co.in")))
                .build();
        shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
    }
}

But here i am getting compile time error cannot resolve symbol ShortcutManager.
Here is my build.gradle file
apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        ...
        minSdkVersion 9
        targetSdkVersion 24
        ...
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.2.1'
}

Comment: App Shortcuts were introduced in API 25+. They are not part of the support library yet.
Answer: You need to update your dependency because ShortcutManager is added in API 25 as mentioned here so you should update/install the below components for API 25

Build-Tools
Install API 25 platform
Android Support Respository
SDK Tools
SDK Platform Tools

and make the necessary changes in your build-gradle file as show in the image too :
Update your following project's values to 25

compileSdkVersion
buildToolsVersion

Follow the link to see the features updates provided in API 25 (v7.1)
And eventually it will look this, with succesful build using ShortcutManager

There are some other crucial packages you might want to update too

USB drivers   : For USB device debugging
Play service  : For latest APIs added in Google maps,google+ etc
System images : To practice with latest AVD devices
Android Support Repository : Support libraries for android devices,TV etc
Google Repository : For features Firebase, Google Maps, Games achievements and leaderboards
Comment: Ok, in that case i will update my sdk and let you know whether its working or not.


Prove that $\limsup_{n \rightarrow \infty} (f_n(x))^{1/n} \leq1 $

Question:
Suppose $f_n$ are nonnegative measurable functions on a measure space satisfying $$\int f_n\ \mathsf d\mu =1.$$ Prove that $$\limsup_{n \rightarrow \infty} (f_n(x))^{1/n} \leq1 $$ almost everywhere.

I'm considering to use either by contradiction or Borel- Cantelli lemma. For the first case, I assumed there exists an $n$ such that the conclusion is not true and then we have a contradiction with the integral being 1. But I think this should use Borel-Cantelli lemma which I'm not sure how to apply.
Answer: Hints:

Fix $\epsilon>0$. Show using Markov's inequality that $$\mu(\{x; f_n(x)^{1/n} \geq 1+\epsilon\}) \leq \frac{1}{(1+\epsilon)^n}.$$
Conclude from the Borel-Cantelli theorem that $$f_n(x)^{1/n} \leq 1+\epsilon$$ for all $n \geq N(x)$ sufficiently large for almost all $x$.
Conclude that $$\limsup_{n \to \infty} f_n(x)^{1/n} \leq 1+\epsilon$$ almost everywhere. Since $\epsilon>0$ is arbitrary, the claim follows.
Comment: I probably miss something, but it's it enough to notice that $f_n<\alpha <1$ due to the integral value for some constant $\alpha$, and hence the limit is 1.
Comment: @Alex $\int f_n \, d\mu = 1$ does not imply $f_n<\alpha<1$; just consider e.g. $f_n(x) := n 1_{[0,1/n]}(x)$.
Comment: Thanks, so the support is $[0,\frac{1}{n}]$. I guess I missed it.
Answer: If $\int f_n = 1$ for all $n,$ then
$$\sum (1/n^2)\int f_n = \sum \int f_n/n^2 =  \int (\sum f_n/n^2) < \infty,$$
where we used the monotone convergence theorem to get the second equality. Thus $\sum f_n(x)/n^2 < \infty$ for a.e. $x.$ Fix such an $x.$ Because the series converges, we have
$$f_n(x)/n^2 \to 0\implies f_n(x)/n^2 < 1 \ \text {for large}\  n \implies f_n(x)^{1/n} < (n^2)^{1/n} \ \text {for large}\ n .$$
Now take the $\limsup,$ recalling $(n^2)^{1/n} \to 1.$
Comment: It's hard for me to come up with $f_n /n^2$ though.
Comment: I'm not sure what you are saying there.


ImportError: MagickWand shared library not found[windows]

Question: Good morning,
After a lot of attemps running
from wand.image import Image

I get the following error:
    Traceback (most recent call last):
  File "C:\Users\XXXXX\PycharmProjects\PDF_convert\venv\lib\site-packages\wand\api.py", line 180, in <module>
    libraries = load_library()
  File "C:\Users\XXXXX\PycharmProjects\PDF_convert\venv\lib\site-packages\wand\api.py", line 135, in load_library
    raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: ['C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWandHDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWandHDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q16HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q16HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q16HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q16HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q8.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q8.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q8HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q8HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-Q8HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-Q8HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6.Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6.Q16.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6.Q16HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6.Q16HDRI.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\CORE_RL_wand_-6.Q16HDRI-2.dll', 'C:\\Program Files\\ImageMagick-6.9.9-Q8\\libMagickWand-6.Q16HDRI-2.dll']
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\xxxxx\PycharmProjects\PDF_convert\venv\lib\site-packages\wand\image.py", line 20, in <module>
    from .api import MagickPixelPacket, libc, libmagick, library
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 20, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\XXXX\PycharmProjects\PDF_convert\venv\lib\site-packages\wand\api.py", line 206, in <module>
    'Try to install:\n  ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
  http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows

I have tried everything:
1. Install the most recent binaries ImageMagick-6.9.9-40-Q8-x64-dll (1).exe (checking the required options)
2. Define MAGICK_HOME path as: C:\Program Files\ImageMagick-6.9.9-Q8
3. Restart computer
and still giving me this error.
I'm using windows 10,
Can someone help me with this error? I really need to use this library for scanned ocr pdf.
Thanks in advance!win
Comment: Possible duplicate of [Python doesn't find MagickWand Libraries (despite correct location?)](https://stackoverflow.com/questions/25003117/python-doesnt-find-magickwand-libraries-despite-correct-location)
Answer: Refer to this answer here. I had the same problem but I had a 32bit version of Python so I had to download the x86 version of ImageMagick.
Answer: For those who are in Linux
You also need to install magickwand from apt-get:
sudo apt-get install libmagickwand-dev

Answer: For those coming from Mac
After installing ImageMagick, MAGICK_HOME and PATH needs to be set
brew install freetype ImageMagick
export MAGICK_HOME=/opt/homebrew/opt/imagemagick
export PATH=$MAGICK_HOME/bin:$PATH

Now executing python from the same shell should pickup ImageMagick/MagickWand
Restart the shell if export statements are added to zshrc
Comment: Running `python3 -c "import wand.version;print(wand.version.MAGICK_VERSION)"` to confirm successful installation. It should print something like `ImageMagick 7.1.0-52 Q16-HDRI aarch64 20549 https://imagemagick.org`
Comment: I actually had to set `MAGICK_HOME` to this path (note `Cellar` instead of `bin`), unfortunately with a specific version number: `export MAGICK_HOME=/opt/homebrew/Cellar/imagemagick/7.1.0-53`
Answer: I faced the same issue on my Windows laptop to solve it I followed the following steps:
Run one of the following commands:
!conda install -c conda-forge/label/cf202003 imagemagick
!pip install install libmagickwand-dev
!pip install ImageMagick

After this implement the steps mentioned on the following link:
#Install ImageMagick on Windows by following this page: https://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-windows
I have downloaded and installed ImageMagick-7.1.0-2-Q16-HDRI-x64-dll.exe
Restarted the kernel of my jupyter notebook. It solved my issue.
Note:
I am keeping this answer on this post and I have removed a similar answer from the Error: MagickWand shared library not found. You probably had not installed ImageMagick library. (even though I have)
Comment: How do u run the above code to install libmagickwand-dev & ImageMagic? I tried on Anaconda Prompt and it doesn't work
Comment: Look at other post: https://stackoverflow.com/questions/68948617/how-to-install-libmagickwand-dev-for-magickwand
Answer: Don't get confused check for correct Python Version:
It is not the Windows architecture 32/64bit that matters; what matters is which Python architecture is installed – 32 or 64bit.
To find out the Python version and architecture you have installed:
python -VV
>>> Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)]
Find the correct version x64 for 64bit x86 for 32bit Python:
https://imagemagick.org/download/binaries/
Get -dll.exe version...

Note that you have to check Install development headers and libraries
for C and C++ to make Wand able to link to it.
Lastly you have to set MAGICK_HOME environment variable to the path of
ImageMagick (e.g. C:\Program Files\ImageMagick-6.9.3-Q16). You can set
it in Computer ‣ Properties ‣ Advanced system settings ‣ Advanced ‣
Environment Variables….

If you like to convert images like me you need to install Ghostscript in addition:
https://www.ghostscript.com/download/gsdnld.html
Answer: On windows, installing the 32bit version has worked for me, however, the link on wand's website is dead for some server reason.
I have been able to make it work by installing from the binaries list.
http://www.imagemagick.org/download/binaries/ImageMagick-6.9.10-4-Q16-x86-dll.exe
Answer: Even installing the correct version (32-bit / 64-bit) of ImageMagick 7.X.X, I still got the ImportError: MagickWand shared library not found error. For my version of Wand==0.4.5, what helped for me was uninstalling ImageMagick, then installing a 6.9.X version. You may find the list of releases here.
Answer: For Python v3 (64 bit),
try installing ImageMagick-6.9.10-2-Q16-x64-dll.exe from here then put installed directory file path in Path environment variable, ex - C:\Program Files\ImageMagick-6.9.10-Q16
then install wand pip install wand==0.4.4
this should fix the issue as there are compatibility issues with wand and ImageMagick


Mower lost power now won't restart

Question: While cutting grass I shut it down. I started it back up and it sounded like it it over surdged. When I engaged the blade the motor bogged down and had no power. I shut it down and tried to restart it but it wouldn't restart. It didn't smoke just lost power. Briggs motor.
Comment: Clean the under deck and try again.
Comment: Also check and clean the air filter.
Comment: Can not do much without model number
Comment: Out of gas, spark plug..others Look here https://www.briggsandstratton.com/na/en_us/support/manuals.html
Comment: Maybe it ran out of oil and you ruined the engine.
Answer: Check the air filter to see if it's dirty or clogged. A dirty air filter can restrict airflow to the engine, leading to poor performance. If the air filter is dirty, clean or replace it as necessary.

Mower lost power now won't restart


Regex String Get Data In Brackets

Question: I'm having a Regex issue that I'm hoping someone can help with.
I have the following type of string:
" name VARCHAR(11) NOT NULL, "

Of which I'm trying to extract only the length - in otherwords the numbers within the brackets.
I have looked at this: True regex for getting content from parentheses in square brackets but I'm just not figuring out how to make that work with my case.
I know that I could use str_replace to remove the unwanted data, but this is going to be messy and waste resources.
Can anyone help?
Answer: This should do it:
$matches = Array();
preg_match("/\w+\((\d+)\)/i", " name VARCHAR(11) NOT NULL, ", $matches);

$matches will now contain
Array
(
    [0] => VARCHAR(11)
    [1] => 11
)

Answer: If all you are looking for is some digits between the brackets, then you could use some code similar to this -
$str = " name VARCHAR(11) NOT NULL, ";
$matches = array();
$pattern = '/\((\d+)\)/';
preg_match_all($pattern,$str,$matches);

This code uses the preg_match() function, which performs a regular expression match.

If matches is provided, then it is filled with the results of search. $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.
Answer: Try this pattern:
/.*\(([0-9]+)\).*/

Regex String Get Data In Brackets


Xpath result vs. xs:assert result

Question: I am using oXygen XML Editor 16.1 using SaxonEE set for XML Schema 1.1 for these tests.
I want to insure that elements in a complexType that is a restriction of a base complexType, have the same number of enumerations. (Code below)
The sample complexType (bottom of post) should fail this assert:
<xs:assert test="count(//xs:element[@name='id-name']//xs:enumeration)
eq count(//xs:element[@name='issuer']//xs:enumeration)
and
count(//xs:element[@name='issuer']//xs:enumeration)
eq count(//xs:element[@name='assignor']//xs:enumeration)"></xs:assert>

because assignor has three enumerations and the other elements have two. Whether I put this in the base complexType or the restricted complexType it still shows the restriction as a valid schema.
If I execute this
count(//xs:element[@name='id-name']//xs:enumeration)
  eq count(//xs:element[@name='issuer']//xs:enumeration) and
count(//xs:element[@name='issuer']//xs:enumeration)
  eq count(//xs:element[@name='assignor']//xs:enumeration)

in the XPath editor it fails (returns false) as expected as well as passes (returns true) when all three have two enumerations.
Sample restriction:
 <xs:complexType name='mytype' xml:lang='en-US'>
<xs:complexContent>
  <xs:restriction base='myBaseType'>
    <xs:sequence>
        <xs:element maxOccurs='1' minOccurs='1' name='id-name'>
          <xs:simpleType>
            <xs:restriction base='xs:string'>
              <xs:enumeration value='URI'></xs:enumeration>
              <xs:enumeration value='ID Number'></xs:enumeration>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element maxOccurs='1' minOccurs='1' name='issuer'>
          <xs:simpleType>
            <xs:restriction base='xs:string'>
              <xs:enumeration value='Owner'/>
              <xs:enumeration value='Owner'/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element maxOccurs='1' minOccurs='1' name='assignor'>
          <xs:simpleType>
            <xs:restriction base='xs:string'>
              <xs:enumeration value='Owner'/>
              <xs:enumeration value='Owner'/>
              <xs:enumeration value='Owner'/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
      </xs:sequence>
    </xs:restriction>
  </xs:complexContent>
    </xs:complexType>

'myBaseType' is in another schema that is 'included' in this one. That complexType looks like this:
  <xs:complexType name="myBaseType">
<xs:complexContent>
  <xs:extension base="someType">
    <xs:sequence>
      <xs:element maxOccurs="1" minOccurs="0" name="id-name" type="xs:string"></xs:element>
      <xs:element maxOccurs="1" minOccurs="0" name="issuer" type="xs:string"></xs:element>
      <xs:element maxOccurs="1" minOccurs="0" name="assignor" type="xs:string"></xs:element>
    </xs:sequence>
    <xs:assert test="count(//xs:element[@name='id-name']//xs:enumeration) eq count(//xs:element[@name='issuer']//xs:enumeration) and
      count(//xs:element[@name='issuer']//xs:enumeration) eq count(//xs:element[@name='assignor']//xs:enumeration)
      "></xs:assert>
  </xs:extension>
</xs:complexContent>

What am I missing? Can't I establish asserts on a restriction complexType or do asserts only get evaluated for instance data? It seems to me that since 'mytype' is a restriction of 'myBaseType' then the assert should be applied.
Answer: As you anticipate at the end of your question, the scope for assertions is the XML document instance governed by the XSD, not the XSD itself.  If you wish to make assertions about the XSD itself, you'd have to create a meta-xsd that treated the original XSD as an XML document.
You could start with the XML Schema schema.  However, you should instead consider using Schematron assertions, which will probably work better for selective enforcement of constraints.  I've used Schematron over XSDs to enforce organizational conventions and found it to be a viable approach for checking compliance with adopted policy.

Update per OP comments

'If you wish to make assertions about the XSD itself, you'd have to
  create a meta-xsd that treated the original XSD as an XML document' --
  Yes, that is what I did.

No, that is not what you've done.  You're trying to make assertions against the XSD from the same XSD that is validating your XML document instance.  The fact that it's a separate XSD brought in via xsd:include changes nothing; it's still only a domain XSD, not a meta XSD of the domain XSD.  What I said was that you would have to have a meta XSD, meaning a separate XSD that validates your domain XSD.  You've underestimated the complexity involved in such a task.  If you're not starting from the XML Schema schema, you're not realizing what a meta XSD has to do.

I really prefer to not use schematron, if this can be done with XSD
  1.1 then why add another element of complexity?

Because the complexity of enforcing spot-constraints via Schematron or some other technique is actually lower than the complexity of validating all of XSD via XSD and then tacking on some assertions to cover the spot-constraints.  Further, XSD 1.1's assertion facilities are considerably more restricted than Schematron's assertions.
Comment: 'If you wish to make assertions about the XSD itself, you'd have to create a meta-xsd that treated the original XSD as an XML document'  --  Yes, that is what I did.  As I said, the complexType with the enumerations is a restriction of a complexType from the schema where I put the assert.  I really prefer to not use schematron, if this can be done with XSD 1.1 then why add another element of complexity? The goal is for users to be able to create restricted schemas from the base schema but be required to have the same number of enumerations for each element in the restricted type.
Comment: The original post has been updated to show the myBaseType from the included schema.
Comment: @TimCook It's important to understand that an XSD cannot validate itself - much in the same way as humans find it hard to eat themselves (apologies for this horrible analogy). If you understand XML in general and XPath in particular, Schematron is not a big deal - it's really easy to use. P.s. Oxygen has good support for Schematron, there are even some predefined scenarios.
Comment: Right, I understand that an XSD cannot be used to validate itself.  However, since the content of a complexType that is a restriction of a complexType from an included XSD is most certainly validated against the base type being restricted.  This only seems to not be working for asserts. I thought I might have made a mistake in setting the context in the assert. But couldn't find it. Sure Saxon and(presumably Xerces)has Schematron support. Can Schematron rules exist in same XSD file?I am using oXygen, but the result of this research must be more generally useful and not tied to specific tools.
Comment: Can Schematron rules exist in same XSD file? == Yes. So. I'll investigate adding Schematron.

Xpath result vs. xs:assert result


How can I leave General chat?

Question: I typed /help and read every command, and came across the /chat command. According to the info, /chat leave General should make me leave the channel, but it doesn't. How can I leave the General chat (but still have access to the other rooms, like LookingForGroup)?
Comment: [So antisocial](http://gaming.stackexchange.com/questions/71069/how-can-i-disable-automatically-joining-the-general-chat-when-i-log-in)
Comment: General chat in TSW is worse than D3 in that there are guilds(Cabals) spamming constantly for members :)
Answer: The easiest way is to turn off the subscription to General chat.
On your chat frame, you'll see several tabs, such as 'General', 'Combat' and 'Tell Messages'.
You can right click on these to change the channels and information feeds that each tab is 'Subscribed' to. You'll need to do this on every login for now, but a fix is supposedly 'coming soon'.

How can I leave General chat?


Preventing word-wrap for kendo dropdownlist

Question: I have an example of a KendoDropDownList jsFiddle
<code>var ds = [
    {label:"External Causes of Morbidity, Mortality"},
    {label:"Cardiovascular"},
    {label:"Circulatory System Diseases"},
    {label:"Codes of Special Purposes"},
    {label:"Congenital Anomalies"},
    {label:"Digestive System Diseases"},
    {label:"Easr and Mastoid Process Disease"},
    {label:"Endocrine, Metabolic, Immunity"}];

$("#dropdownlist").kendoDropDownList({
    dataTextField: 'label',
    dataSource: ds
});

var ddl = $("#dropdownlist").data('kendoDropDownList').list.width("auto");
</code>
As you can see, I have the list's width set to "auto" but the first item in the list still word-wraps. I thought the "auto" value caused the window to fit to the correct size of the largest item in the list or do I have to just figure out the correct width needed and hard-code the width to prevent word-wrapping?
Comment: Seems like some sort of bug.  Setting `list.width("auto")` does expand the list width but just not enough for that one item.  If you have Telerik support you might want to point them to your jsFiddle and see what they say.
Comment: I don't see anything in the docs about list.width("auto") - where did you find that?  Setting this width of the #dropdownlist element would make it wider, but I'm not sure about an auto method.
Comment: I found it [here](http://www.telerik.com/forums/dropdownlist-should-take-size-of-biggest-option)  I am also using it and it works for the most part but there are some times when an item wraps.
Comment: Thanks once again Rick.  I'll make sure to do that since I do have support.
Answer: You just need to tell the listitems to not wrap text as well as setting the width to auto:
<code>$("#dropdownlist").kendoDropDownList({
    dataTextField: 'label',
    dataSource: ds,
    dataBound: function(e) {
        e.sender.list.width("auto");
    }
});

.k-list-container .k-list .k-item
{
    padding-right: 25px;
    white-space: nowrap;
}
</code>

Updated FIDDLE

If you prefer to do it all in code:
<code>$("#dropdownlist").kendoDropDownList({
    dataTextField: 'label',
    dataSource: ds,
    dataBound: function(e) {
        e.sender.list.width("auto").find("li").css({"white-space": "nowrap", "padding-right": "25px"});
    }
});
</code>

FIDDLE

NOTE: the right padding leaves space for the vertical scrollbar.


Need for while True:

Question: I don't understand why "while True:" is needed in below example
  import os
  import sys
  import subprocess
  import time
  from threading import Thread
  from Queue import Queue

  def worker():
     while True:
          item = q.get()
          do_work(item)
          q.task_done()

  def do_work(item):
      time.sleep(item)
      print item

  q = Queue()
  for i in range(2):
       t = Thread(target=worker)
       t.daemon = True
       t.start()

  source = [2,3,1,4,5]

  for item in source:
      q.put(item)

  q.join()

Comment: I know what "while" does
Answer: Because otherwise the worker thread would quit as soon as the first job was processed from the queue. The infinite loop ensures that the worker thread retrieves a new job from the queue when finished.
Update: to summarize the comments to my (admittedly hasty) answer: the worker thread is daemonic (ensured by t.daemon = True), which means that it will automatically terminate when there are only daemonic threads left in the Python interpreter (a more detailed explanation is given here). It is also worth mentioning that the get method of the queue on which the worker operates blocks the thread when the queue is empty to let other threads run while the worker is waiting for more jobs to appear in the queue.
Comment: I think it worths to mention, that it doesn't fall into an infinite loop, because the worker thread is daemonic.
Comment: +1 Also worth adding that presumably `q.get()` blocks when the queue is empty thus avoiding running a busy loop
Comment: Thanks guys, I've extended my answer to include this.

Need for while True:


Need help to fix org.apache.hadoop.ipc.RemoteException - AWS EMR Spark Scala Application

Question: I am running a Spark/Scala App on AWS EMR - 12 node cluster. I have multiple transformations happening where i write to HDFS and read back from hdfs to complete transformations and finally write to S3.
During one of these transformations i recently started to get the following error"
<code>2018-08-10 20:05:31,106 [task-result-getter-2] WARN  org.apache.spark.scheduler.TaskSetManager:66 - Lost task 44.0 in stage 30.0 (TID 4300, IP-address-here, executor 5): org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /user/hadoop/working/xml/SD5256.20171030.5251246b-5475.xml.__temp could only be replicated to 0 nodes instead of minReplication (=1).  There are 11 datanode(s) running and no node(s) are excluded in this operation.
at org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.chooseTarget4NewBlock(BlockManager.java:1735)
at org.apache.hadoop.hdfs.server.namenode.FSDirWriteFileOp.chooseTargetForNewBlock(FSDirWriteFileOp.java:265)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:2561)
at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.addBlock(NameNodeRpcServer.java:829)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.addBlock(ClientNamenodeProtocolServerSideTranslatorPB.java:510)
at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:447)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:989)
at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:847)
at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:790)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1836)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2486)

at org.apache.hadoop.ipc.Client.getRpcResponse(Client.java:1489)
at org.apache.hadoop.ipc.Client.call(Client.java:1435)
at org.apache.hadoop.ipc.Client.call(Client.java:1345)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:227)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:116)
at com.sun.proxy.$Proxy38.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.addBlock(ClientNamenodeProtocolTranslatorPB.java:444)
at sun.reflect.GeneratedMethodAccessor239.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:409)
at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeMethod(RetryInvocationHandler.java:163)
at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invoke(RetryInvocationHandler.java:155)
at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeOnce(RetryInvocationHandler.java:95)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:346)
at com.sun.proxy.$Proxy39.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.DataStreamer.locateFollowingBlock(DataStreamer.java:1838)
at org.apache.hadoop.hdfs.DataStreamer.nextBlockOutputStream(DataStreamer.java:1638)
at org.apache.hadoop.hdfs.DataStreamer.run(DataStreamer.java:704)
</code>
Based on some articles and forum member comments, i updated the hdfs-site.xml by adding the following configuration:
<code>    <property>
    <name>dfs.client.use.datanode.hostname</name>
    <value>true</value>
  </property>
    <property>
    <name>dfs.datanode.use.datanode.hostname</name>
    <value>true</value>
  </property>
</code>
Can someone help me understand why i am getting this error? and what configuration do i need to update in hdfs-site.xml to address this issue. Any help is appreciated.
Answer: I think could be due to
1.Because of multiple transformation your job needs to open more files which might be exceeding the maximum number of open files specified in the ulimit.
2.your jobs are trying to write to the same HDFS file concurrently. HDFS does not allow concurrent writes to the same file.
Possible Solutions-
1. At any given point of time an HDFS file can have only one writer connection. you need ensure that your are not writing to same HDFS files.
2.consider increasing the ulimit maximum number of open files for the user runs the job on all nodes.
Comment: Thank you for your response and solution. Can you please let me know how can we increase the ulimit? Where can we configure it? hdfs-site.xml or hdfs-default.xml?


How do I remove the white bar under the content on 1440p monitors?

Question:
I am exploring CSS Grid and I am having trouble because the size doesn't use full height and my HTML and body is [width, height 100%]. I have a large white section how do I make it snap to whatever is top?
Any suggestion will be appreciated.
Here is my CSS.
*,** {
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
}
html{
    margin: 0;
    padding:0;
    width: 100%;
    height: auto;
}
.grid {
margin: 0;
display: grid;
grid-template-columns: 100%;
grid-template-rows: repeat(auto, 4);
/* grid-template-rows: 13% auto 20%; */
grid-template-areas:
"header"
"main";

@media screen and (min-width: 500px) {
    grid-template-columns: auto;
    grid-template-rows:   repeat(auto, 3);

    grid-template-areas:
    "header header"
    "main main"
    "main main";
}

@media screen and (min-width: 800px) {
    grid-template-columns: 30% auto;
    grid-template-rows:   repeat(auto, 3);

    grid-template-areas:
    "header header"
    "sidebar main"
    "sidebar2 main";
}

A concern is if I mess with positions it makes things fly left...
Comment: What if you set body height: `body{height:100vh}` and container to either 100vh or 100%?
Comment: @JakubMuda if i do body 100vh there is white space between header and main
Answer: You can use vh units, calc and min-height like:
header { grid-area: header; height: 80px; }
nav    { grid-area: sidebar;  }
main   { grid-area: main; min-height: calc(100vh - 80px); } /* subtract header height */
aside  { grid-area: sidebar2; }

Here is an example (I've changed the sizes a bit to work on stackoverflow):

*, ** {
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
}

.grid {
  margin: 0;
  display: grid;
  min-height: 100vh;
  grid-template-columns: 100%;
  grid-template-rows: repeat(auto, 4);
  /* grid-template-rows: 13% auto 20%; */
  grid-template-areas: "header"  "main";
}
@media screen and (min-width: 200px) {
  .grid {
    grid-template-columns: auto;
    grid-template-rows: repeat(auto, 3);
    grid-template-areas: "header header" "main main" "main main";
  }
}
@media screen and (min-width: 400px) {
  .grid {
    grid-template-columns: 30% auto;
    grid-template-rows: repeat(auto, 3);
    grid-template-areas: "header header" "sidebar main" "sidebar2 main";
  }
}

header {
  background: tomato;
  grid-area: header;
  height: 40px;
}

nav {
  background: gold;
  grid-area: sidebar;
}

main {
  background: olive;
  grid-area: main;
  min-height: calc(100vh - 40px);
}

aside {
  background: orange;
  grid-area: sidebar2;
}

  Header
  Sidebar
  Main
  Sidebar 2


GAE app consuming other GAE app services. Is that a good approach?

Question: I'm building an application on Google AppEngine (GAE). This app will serve rest services to be consumed by mobile devices or ordinary computers such as desktops.
Mobile devices will have native frontend. In other hand, desktops will access a web frontend through web browsers. So, I'm wondering if it's a good approach to build a web frontend
in a separate application hosted on GAE. This way, there will be two applications hosted on GAE. The first one (that with the rest services) will be consumed by the second one and also by mobile devices.
Would it be a good practice on GAE?
Answer: While technically possible, you might be breaking the TOS because its really the same app consuming quotas from 2 appengines. Some people do that to get extra free quotas thus google doesnt like it.
You should be able to put frontend and backend in the same appengine.
Comment: I got it. That's what I wanted to know.So, I'll put both app on same appengine. Thanks for your answer.
Comment: You are basically describing app engine modules: https://developers.google.com/appengine/docs/python/modules/


Opentimestamps - Java NullPointerException when trying to deserialize OTS file

Question: When I try to verify a timestamp using the Java library, I am running into a Java NullPointerException.
I'm following the examples in the README of https://github.com/opentimestamps/java-opentimestamps
This is my code:
byte[] originalFile = Files.readAllBytes(fileData.get("absoluteFilePath"));
byte[] originalBytes = new String(originalFile).getBytes("UTF-8");
String originalHex = DatatypeConverter.printHexBinary(originalBytes);

byte[] otsFile = Files.readAllBytes(fileData.get("otsFilePath"));
byte[] otsBytes = new String(otsFile).getBytes("UTF-8");
String otsHex = DatatypeConverter.printHexBinary(otsBytes);

// below is from the examples...

DetachedTimestampFile detached = DetachedTimestampFile.from( new OpSHA256(), originalFile );
DetachedTimestampFile detachedOts = DetachedTimestampFile.deserialize(ots);

HashMap<Chains, VerifyResult> result = OpenTimestamps.verify(detachedOts,detached);

And this the exception:
java.lang.NullPointerException: null
    at com.eternitywall.ots.Timestamp.doTagOrAttestation(Timestamp.java:101) ~[java-opentimestamps-1.16.jar:na]
    at com.eternitywall.ots.Timestamp.deserialize(Timestamp.java:89) ~[java-opentimestamps-1.16.jar:na]
    at com.eternitywall.ots.DetachedTimestampFile.deserialize(DetachedTimestampFile.java:107) ~[java-opentimestamps-1.16.jar:na]
    at com.eternitywall.ots.DetachedTimestampFile.deserialize(DetachedTimestampFile.java:120) ~[java-opentimestamps-1.16.jar:na]
    at com.fmr.ots.FileTimestampController.verifyDocument(FileTimestampController.java:110) ~[classes/:na]

Does anyone know how to correctly read the original file and ots file in order to correctly verify the file?
Comment: Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it)
Comment: Thanks Progman - though I don't see how it relates to my problem - the parameters I'm passing to the Opentimestamps class is not a null pointer.
Comment: Please edit your question to include a [MCVE](https://stackoverflow.com/help/mcve) which can be compiled and tested by others, which will throw the NullPointerException you get.
Answer: Ots file can be read as follows
Path pathOts = Paths.get(otsfilename);
byte[] byteOts = Files.readAllBytes(pathOts);
DetachedTimestampFile detachedOts = DetachedTimestampFile.deserialize(byteOts);

The normal file can be read and converted to DetachedTimeStamp as,
File file = new File(originalfilename);
DetachedTimestampFile detached = DetachedTimestampFile.from(new OpSHA256(), file);

Finally the verify method can be called using the detached and detachedOts file
HashMap<Chains, VerifyResult> result = OpenTimestamps.verify(detachedOts,detached);


I have a fan/light in my room area & I want to add 6 can lights to the switch the fan runs off of I just want to be able to run both at the same time

Question: So I'm trying to add recessed lighting to a ceiling fan with light.. I have an older home so my switch only has a black and white wire to the switch.. how would I wire the can lights to come on with the fan/light.. I want to be able to run the fan and fan light with the recessed lighting all at once or be able to turn off the fan light off and still have recessed lighting work with fan on..
Comment: Do you mind having fan speed/dimming control? Is the current fan just controlled by a plain switch and pull chains, or does it have a remote on it already?
Comment: It has just a plain switch
Comment: Fan has pull strings for fan and light on a plain switch
Comment: you just run the cans from the switched power to the fan, no big whoop.
Comment: So I ran a separate wire off the switch the fan is on and wired in the cam lights in parallel... The lights come on only if the fan light is on and when I turn the switch off cam lights go off and I have to pull the string light on the fan to turn the fan light off.. when I turn on the fan it doesn't want to spin to the speed I set it to it turns slowly... Without cam lights hooked up the fan and lights work just fine... Should I grab power for cam lights straight from the fan and wire them in parallel? Or is there a way to do it from the switch?
Comment: Here's an answer with a nice switch loop graphic, if you'd find that helpful. https://diy.stackexchange.com/a/159932/18078
Answer: You have to get power for the new lights at the fan location.
Your switch only has hot and switched hot (it's an old-fashioned, grandfathered arrangement called a switch loop.) Can't be installed in new work, but is acceptable if already installed when it was still a "to code" arrangement. {Which is what "grandfathered" means in this context.}
Your lights need to be connected to switched hot and neutral, and you'll only find the neutral at the fan location.
White at your switch is not neutral. (It should be "always hot", and it should be "re-marked" with tape or paint in any color other than white, gray, or green - and at the light, it should be connected to a black always-hot feed wire, which tends to freak out people who think that's "wrong." Things get worse when they "correct" it...)
Comment: Thank you so much, your the man!!! Just finished up and that was the exact problem...


Is it possible to replace a parent class?

Question: If I have a class that's inheriting from another, is it possible to replace the inherited class in the child? I've got a demo of what I'm trying to do below,  but I'm not sure the syntax.
<code>#include <iostream>

class singleNum
{
public:
    int m_a;
    singleNum(int a)
    {
        std::cout << "SETUP" << std::endl;
        m_a = a;
    }
    ~singleNum()
    {
        std::cout << "CLOSEDOWN" << std::endl;
    }
};

class inheritor : public singleNum
{
public:
    inheritor(int a) : singleNum(a) {};
    reset(int b)
    {
        singleNum::this = *singleNum(b);
    }

};

int main()
{
    inheritor z(5);
    std::cout << z.m_a << std::endl;
    z.reset(5);
    return 0;
}
</code>
Comment: What do you mean by "replace"? We cannot deduce that from code that, by your own admission, does not actually achieve your goal.
Comment: @BoundaryImposition deliberate slicing, if I understood correctly.
Comment: If I understand correctly you want want to change in the child class the properties of the parent class. I would implement this feature in a method of the parent class. Either a public method or a protected method that is then reimplemented as public by the child class.
Comment: At runtime, remove the parent implementation, and substitute a newly constructed one.
Comment: Seems like a design smell, but is there something wrong with `op=`?
Answer: No
You cannot exchange or reset the base class. If it had a reset method of it's own, you could call this, but you cannot call the constructor again.
If you want to do this, you should favor composition over inheritance. You can then create a completely new instance of the inner composition class and replace your existing instance.
Answer: Your current demo isn't hard to implement, but you'll need to modify the parent class:
<code>#include <iostream>

class singleNum
{
public:
    int m_a;
    singleNum(int a)
    {
        std::cout << "SETUP" << std::endl;
        reset(a);
    }
    ~singleNum()
    {
        std::cout << "CLOSEDOWN" << std::endl;
    }

    virtual void reset(int b)
    {
        m_a = b;
    }
};

class inheritor : public singleNum
{
public:
    inheritor(int a) : singleNum(a) {}
    void reset(int b) override
    {
        singleNum::reset(b);
    }

};

int main()
{
    inheritor z(5);
    std::cout << z.m_a << std::endl;
    z.reset(5);
    return 0;
}
</code>
But this is the closest you will get to "replacing the base class". If your case is different than the demo presented and you need to call the base class constructor on an already constructed derived object then no, this is not doable.


Uniform convergence, area of convergence and Weierstrass criteria

Question: I want to ask two questions:

Is there a relation between the area of convergence of a functional series and the uniform convergence and the convergence at all?
Can I prove that a functional series is not uniform convergent using the Weierstrass criteria? For example if the series which we majorate with is not convergent(the harmonic series for example). In this case does it mean that the functional series is not uniform convergent?

Thank you!
Answer: 1). You have to be careful how you ask this question. It doesn't make sense to say a functional series uniformly converges at a particular point. Rather, we talk about uniform convergence on a set. It's not the case that the functional series converges uniformly on the set of points where it converges. Of course it converges uniformly on some subsets of the set of points where it converges (e.g. a finite subset).
2).The Weierstrass criterion most certainly cannot be used to disprove uniform convergence (in the way you described). I can start with $\sum_{n=1}^\infty \frac{x}{n^2}$ which converges uniformly on $[0,1]$ but majorize each term by $\frac{x}{n^2} \le \frac{x}{n}$, and $\sum_{n=1}^\infty \frac{x}{n}$ of course doesn't converge.
Comment: Also, if $s \ge 1$, then $\sum_{n=1}^\infty \frac{1}{n^s} \ge \sum_{n=1}^\infty \frac{1}{n}$, which we know diverges.
Comment: I was showing that the sum does not converge, for any $x \ge 1$. In particular, it doesn't make sense to talk about whether it is uniformly convergent.
Comment: Yea, I guess the domain of the limit function is the set of convergence of the functional series
Comment: The uniform convergence is related to a limit function. The convergence area of a functional series has nothing to do with that limit function. So the two things doesn't have something in common. Am I right?
Comment: And how can I prove that a functional series is not convergent? For example $\sum_{n=1}^\infty \frac{1}{n^x}$ where x belongs to [1,+inf)
Comment: You seem to be confused. The limit function is only defined where the functional series converges. Let's say we have $f(x) = \sum_n f_n(x)$ for $x$ such that $\sum_n f_n(x)$ converges. Then for a set $A$ of $x$'s, we say that $\sum_n f_n$ converges uniformly to $f$ on $A$ if for all $\epsilon > 0$, there is some $N$ such that $|f(x)-\sum_{n \le N} f_n(x)| < \epsilon$ for all $x$ in $A$.
Comment: So if the series that we minorate with is divergent we can sat that the functional series is not uniformlt convergent?
Comment: And is it true that the domain of the limit function is the area of convergence of the functional series?
Comment: I think $\sum_{n=1}^\infty \frac{1}{n^x}≥\sum_{n=1}^\infty \frac{1}{n}$ is not true
Comment: @spyer Oh, you're absolutely right. I apologize. I was thinking $s < 1$. Let $f_n(x) = \frac{1}{n^x}$. Then $f(x) := \sum_{n=1}^\infty f_n(x)$ is well defined for $x \in (1,\infty)$. I don't think it's the case that $\sum_{n=1}^\infty f_n$ converges uniformly to $f$ on $(1,\infty)$. On the other hand, I think that $\sum_{n=1}^\infty f_n$ converges uniformly to $f$ on $[a,\infty)$ for any fixed $a > 1$.
Comment: And how  to prove that it is not uniform convergent over [1,+inf)
Comment: Suppose that there were some $N$ such that $|\sum_{n=1}^\infty \frac{1}{n^x}-\sum_{n=1}^N \frac{1}{n^x}| < 1$ for all $x \in (1,\infty)$ (I'm using the definition of uniform convergence with $\epsilon = 1$). So, $|\sum_{n=N+1}^\infty \frac{1}{n^x}| \le 1$ for each $x > 1$. But this clearly can't be true. The intuition is that as $x \to 1$, we'll have the harmonic series which diverges (note we can't plug in $x=1$ since we are looking at $(1,\infty)$). continued...
Comment: A way to make this rigorous would be to first take some positive integer $M \ge N+1$ such that $\sum_{n=N+1}^M \frac{1}{n} > 2$. We then have $|\sum_{n=N+1}^\infty \frac{1}{n^x}| = \sum_{n=N+1}^\infty \frac{1}{n^x} \ge \sum_{n=N+1}^M \frac{1}{n^x}$. And by taking $x$ really close to $1$, by continuity, we can make $\sum_{n=N+1}^M \frac{1}{n^x} > 1$ (since the limit as $x \to 1$ is $2$). This is a contradiction.


Bending text object in ThreeJS

Question: There is this repo for this example, which is almost 2 years old, and therefore does not work with the recent releases of the threeJS.
I am having the following error and warnings.
error: THREE.Matrix3.getInverse no longer takes a Matrix4 argument.
warning: THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0
Not sure if it is due to the error and warnings I am getting but the resulting bending is also not correct (screenshot).
I tried to change the bending axis but no luck.
How can I modify this libray to work with recent threeJS releases or is there any alternative way to bend the text as shown in the example of aforementioned repo?
Answer: There was a change in THREE.js but it is quite easy to adjust the BendModifier.js script.
Just change the lines
var InverseP =  new THREE.Matrix3().getInverse( P );
and
newVertices[i] = new THREE.Vector3(); newVertices[i].copy( geometry.vertices[i] ).applyMatrix3( InverseP );
to Matrix4 in both cases - so they will read:
var InverseP =  new THREE.Matrix4().getInverse( P );
and
newVertices[i] = new THREE.Vector3(); newVertices[i].copy( geometry.vertices[i] ).applyMatrix4( InverseP );
Just tried it with three.min.81.js and it works fine.
Comment: Example under [link](https://playingwithstuff.000webhostapp.com/bend/webgl_modifier_bend_my.html)

Bending text object in ThreeJS


Recursive function for sum

Question: I have this recursive function, and I try to pass the result in 's' variable.
However if I use *s=*s+v[i]; the function works.
But if I try to call sum(v,i+2,s+v[i],n); It doesn't work anymore.
Can someone tell me what is wrong?
Here is the code:
void sum(int v[], int i, int *s, int n)
{
    if (i < n)
    {
        if (v[i] < 0)
        {
            //*s = *s + v[i];
            //sum(v, i + 2, s, n);
            sum(v, i + 2, s + v[i], n);

        }
        else
            sum(v, i + 2, s, n);
    }

}

int main()
{
    int n = 7;
    int v[] = { -5,-8,4,4,3,9,-5 };
    int i = 0;
    int s = 0;
    sum(v, i, &s, n);
    printf("SUM IS: %d", s);
    return 0;
}

Comment: `s + v[i]` surely is wrong. Do you have warnings of your compiler turned on?
Comment: Please explain: sum of what?
Comment: Your function doesn't return anything, so if you change it so that it only calls itself and never writes to anything… what do you think `s + v[i]` does?
Comment: Negative numbers whose position in vector is multiple of 2
Comment: I have no errors, here is what i get
First value is v[i] and second is s
-5 ~ 0 /
4 ~ -858993460 /
3 ~ -858993460 /
-5 ~ -858993460 /
SUM IS: 0
Comment: When you don't pass a pointer, the variables in the caller do not change... in `bar = ; foo(bar); /*bar is still */` whatever `foo()` and `bar` are the value of `bar` before and after the function is the same.
Comment: If recall the function like this (sum(v, i + 2, *s + v[i], n);) I get this error: E0167 argument of type "int" is incompatible with parameter of type "int *"
Comment: I don't know how to recall the function without this part `*s = *s + v[i];`
I want to update the s variable right in the next call `sum(etc, s+v[i],etc);`
Answer: There is a major difference between to 2 ways.

The correct one:
*s = *s +v[i];             // increases the int object pointed to by s
sum(v, i + 2, s, n);       // still pass the same pointer to sum

The wrong one:
sum(v, i+2, s+v[i], n);

Here, the pointer is increased instead of the pointed object. It is equivalent to:
s = s +v[i];               // s is not dereferenced here!
sum(v, i + 2, s, n);       // pass an incorrect pointer to sum

Comment: so is not possible in this case to call the function in a similar way to `sum(v, i + 2, s + v[i] ,n);` ?
The only way is to add the array value to *s and then pass it to the function?
Answer: Looks like you have multiple problems that need correction.
First of all, the inner if is not needed. It is unclear what you wanted to do with this. Handling negative numbers separately? If so, it is not needed since the + operator can also handle addition of negative numbers.
Secondly, the s + v[i] adds the value in your array to the pointer to sum, which is not what you want. You need to use the * operator to dereference s here so that the number is added to the sum that the pointer points to. Your own commented-out code does this correctly.
Thirdly, using sum(v, i + 2, s, n); skips alternate elements so to sum the whole array properly, you need to use i + 1 instead of i + 2.
The following code fixes these issues.
void sum(int v[], int i, int *s, int n)
{
    if (i < n)
    {
        *s += v[i];
        sum(v, i + 1, s, n);
    }
}

int main()
{
    int n = 7;
    int v[] = { -5,-8,4,4,3,9,-5 };
    int i = 0;
    int s = 0;
    sum(v, i, &s, n);
    printf("SUM IS: %d", s);
    return 0;
}

Recursive function for sum


django fixed fontsize in tinymce

Question: I have used tinymce in my django project. In my base.html I have used it as

I wanto to make the fixed font size in my editor because the dafault one is too small.
From tinymce site I came to know that I should use content_css in order to make my fontsize fixed..
My static directory is in the root directory inside which I have made a directory named css and inside that folder I have "content_css"
Now what can I put the directory for "content_css".. Should I do like content_css:"static/css/content.css". I guess its only for django not the tinymce.. Confused in giving directory for content_css.. Thanks in advance
Answer: I finally found an easy solution assuming you are also using django-tinymce plugin?
Simply select the highcontract skin which does not include a font-size of 10px for the body. As a result the default font size of the outer (django) app applies.
'theme': 'advanced',
'skin': 'highcontrast',

Paul

django fixed fontsize in tinymce


Create a heatmap/punchcard Using Chart.js

Question: I have multiple charts on page, one of them is HeatMap.
I am using chartjs to create  my charts. I am unable to create a heatmap using chartjs. Also is it possible to get look like github punchcard with chartJS
punchcard example
Answer: Use bubble chart to draw chart. Below is the image for the same.

[Sample-code]
<code>var ctx = document.getElementById("myChart");
    var data = {
        datasets: [
            {
                label : "Monday",
                data: [
                    {
                        x: 2,
                        y: 5,
                        r: 12
                    },
                    {
                        x: 6,
                        y: 5,
                        r: 8
                    },
                    {
                        x: 10,
                        y: 5,
                        r: 8
                    },
                    {
                        x: 14,
                        y: 5,
                        r: 6
                    },
                    {
                        x: 18,
                        y: 5,
                        r: 6
                    },
                    {
                        x: 22,
                        y: 5,
                        r: 2
                    },
                    {
                        x: 26,
                        y: 5,
                        r: 2
                    },
                    {
                        x: 30,
                        y: 5,
                        r: 6
                    },
                    {
                        x: 34,
                        y: 5,
                        r: 8
                    },
                    {
                        x: 38,
                        y: 5,
                        r: 12
                    },
                    {
                        x: 42,
                        y: 5,
                        r: 12
                    },
                    {
                        x: 46,
                        y: 5,
                        r: 10
                    },
                    {
                        x: 50,
                        y: 5,
                        r: 12
                    },
                    {
                        x: 54,
                        y: 5,
                        r: 8
                    },
                    {
                        x: 58,
                        y: 5,
                        r: 8
                    }

                ],
                backgroundColor:"#444",
                hoverBackgroundColor: "#FF6384",
            },
            {
                label : "Tuesday",
                data: [
                    {
                        x: 2,
                        y: 15,
                        r: 12
                    },
                    {
                        x: 6,
                        y: 15,
                        r: 8
                    },
                    {
                        x: 10,
                        y: 15,
                        r: 8
                    },
                    {
                        x: 14,
                        y: 15,
                        r: 6
                    },
                    {
                        x: 18,
                        y: 15,
                        r: 6
                    },
                    {
                        x: 22,
                        y: 15,
                        r: 2
                    },
                    {
                        x: 26,
                        y: 15,
                        r: 2
                    },
                    {
                        x: 30,
                        y: 15,
                        r: 6
                    },
                    {
                        x: 34,
                        y: 15,
                        r: 8
                    },
                    {
                        x: 38,
                        y: 15,
                        r: 12
                    },
                    {
                        x: 42,
                        y: 15,
                        r: 12
                    },
                    {
                        x: 46,
                        y: 15,
                        r: 10
                    },
                    {
                        x: 50,
                        y: 15,
                        r: 12
                    },
                    {
                        x: 54,
                        y: 15,
                        r: 8
                    },
                    {
                        x: 58,
                        y: 15,
                        r: 8
                    }

                ],
                backgroundColor:"#444",

            },
            {
                label : "Wednesday",
                data: [
                    {
                        x: 2,
                        y: 25,
                        r: 12
                    },
                    {
                        x: 6,
                        y: 25,
                        r: 4
                    },
                    {
                        x: 10,
                        y: 25,
                        r: 4
                    },
                    {
                        x: 14,
                        y: 25,
                        r: 2
                    },
                    {
                        x: 18,
                        y: 25,
                        r: 6
                    },
                    {
                        x: 22,
                        y: 25,
                        r: 12
                    },
                    {
                        x: 26,
                        y: 25,
                        r: 12
                    },
                    {
                        x: 30,
                        y: 25,
                        r: 6
                    },
                    {
                        x: 34,
                        y: 25,
                        r: 8
                    },
                    {
                        x: 38,
                        y: 25,
                        r: 12
                    },
                    {
                        x: 42,
                        y: 25,
                        r: 12
                    },
                    {
                        x: 46,
                        y: 25,
                        r: 10
                    },
                    {
                        x: 50,
                        y: 25,
                        r: 12
                    },
                    {
                        x: 54,
                        y: 25,
                        r: 8
                    },
                    {
                        x: 58,
                        y: 25,
                        r: 8
                    }

                ],
                backgroundColor:"#444",

            }
        ]
    };
    var myBubbleChart = new Chart(ctx,{
        type: 'bubble',
        data: data,
        options: {
            scales : {
                xAxes : [{
                    display : false,
                    ticks : {
                        beginAtZero : true,
                        max : 70
                    }
                }],
                yAxes : [{

                    ticks: {
                        beginAtZero : true,
                        max : 40,
                        stepSize : 10
                    }
                }]
            }
        }
    });
</code>


Silicone and bathroom tile: how long is it viable?

Question: A few months ago we had a home inspector in who mentioned that some of our tile grout was starting to fail around our tub/shower, and that it should be replaced as soon as possible, preferably with a new tub surround in place of the tile.
I've been having a difficult time finding a contractor to do this work, so in the mean-time patched any hair-line cracks and missing grout with GE 100% White Silicone Caulk (I figured that actually trying to re-grout was going to be a losing battle, and I wasn't quite confident enough that I'd do it correctly).
My question is: how long does the silicone job give me to track down a contractor and have the work done? I've read that silicone is definitely a temporary solution, but will it actually hold for a lengthy period of time? And is it recommended to re-apply if necessary?
Answer: It CAN hold for quite some time - or not. Much depends on surface preparation (how clean things were) when applying it. Since it's not really a good solution, it's hard to say how long it might last - could be months, could be years.
If the only problem is the grout, sawing out the bad grout (yes, really, look for a grout saw) and re-grouting is a good deal less work than redoing the whole surround. If there are other problems (such as improper waterproofing behind the tile, or occupants [rather than a home inspector who does not live there] not liking the tile) that math changes.
Re-grouting is not terribly difficult to learn. Just protect the tub really well, as you will certainly drop some grout (and it needs protection when you are sawing out the old grout as well - or if you do remove the tile.)
Comment: It seems like you or the inspector are under the impression that this is a waterproofing issue. It is not. Tile and grout or caulk should not be considered waterproof. There should be some sort of waterproof structure BEHIND the tile to do this job, which should terminate at the tub flange to drain any water that gets behind the tile. I should say at least if the prepwork was done right, this should not be a waterproofing issue. If there is no waterproofing behind the tile, everything should be redone anyway (and there's a good chance the framing will be rotted and moldy).
Comment: If **any** of the grout is failing, you normally saw it **all** out and replace it **all** (since it's all suspect once one part of it fails.) If the tile is not falling off the wall and there are not other signs of problems with water getting behind the tile, there's no need to expand the problem beyond that...at 60 years old it was probably installed quite well, albeit not in the same way that it would be now.
Comment: 60 year old waterproofing is not up to modern standards, **but** if it hasn't failed, there's no innate reason to assume it will next week.
Comment: Thanks. I did learn to re-grout and bought the right tools, but the tile is about 60 years old and it looked like over time more and more of the grout was ready to fail. It caused me a bit of a grief as I wasn't sure how serious of an issue water damage to the wall could be. That led me to look into a new surround.


Implementation of DI in Asp.net Core

Question: This issue is different, I know what DI is, but I want to know how asp.net core use DI. We can configure custom logging in ASP.NET Core, but I do not know why it works.
Normally, we use the new keyword to instantiate a class, and then we can use it in the controller. In ASP.NET Core, we use a controller constructor with parameter like below:
public class HomeController : Controller
{
    private readonly ILogger _logger;
    public HomeController(ILogger<HomeController> logger)
    {
        _logger = logger;
    }
}

I know it is a design pattern called Dependency Injection, but I am wondering how this is implemented. How did the ASP.NET Core team realize this?
Comment: Possible duplicate of [What is dependency injection?](http://stackoverflow.com/questions/130794/what-is-dependency-injection)
Comment: Your question is unclear. You might want to rephrase your question. You are "wondering depth implementation of this"? What?
Comment: @Steven I am wondering when ILogger is initialized in public HomeController(ILogger logger), or when the logger get value?
Answer: In Dependency Injection and Inversion of Control jargon, what is injected is called a "service".
You register your services with an IoC container upon application startup, meaning: you tie concrete implementations and a lifetime to a certain type.
Now when a controller is required to serve an incoming request, MVC will use a controller factory to look up and instantiate the relevant controller. When that controller has constructor parameters, it'll ask the IoC container to resolve the required service parameters.
More information on learn.microsoft.com: Dependency injection into controllers.
Comment: You can put each of those search terms in your favorite web search engine. Explaining in detail how to build an IoC container would be too broad and not fit into a single answer. A relevant keyword is "reflection", used to inspect types and methods at runtime.
Comment: could you share me key code related with "a controller factory to look up and instantiate the relevant controller. When that controller has constructor parameters, it'll ask the IoC container to resolve the required service parameters". I am wondering how IoC container to resolve the required service parameters

Implementation of DI in Asp.net Core


Mail client that does NOT mark mails as read automatically?

Question: Problem is, that mails get marked as read when I select them and they are shown in the preview pane.
I tried Thunderbird, Claws Mail and Sylpheed and I didn't find an option that prevents this. I'm open for new mail clients (but no console or KDE, please).
Comment: ugh. it drives me nuts when they AREN'T automatically marked as read.  I don't want another step to explicitly have to mark them when they have already appeared.
Answer: Most clients have settings that allow the user to modify this behavior.  For example, in Thunderbird you can change these settings (under Edit | Preferences, then choose Advanced, and then the Reading and Display tab).  If "Automatically mark messages as read" is checked, you can uncheck it and the automatic marking won't happen, which sounds like what you want.
If you keep it checked, you can control the automatic marking with the two radio buttons beneath that line, either to mark a message as read immediately upon viewing (even in the preview pane), or to have it marked as read if you view the message - even in the preview pane - for a particular length of time.
I know Evolution has a similar setting, and I assume most other mail clients do, too, but I'm not familiar with Claws Mail and with Sylpheed.
In Claws Mail, the settings controlling this behaviour are in the Preferences, Display / Summaries. The relevant options on this tab are the "Open message when selected" combo, and the "Mark message as read" settings.
Comment: +1 on Claws - just did not see it. Even following instructions took me a while - selective blindness. Thanks!
Comment: In current Thunderbird versions (38.0.1 for me) I could not find this setting. You now have to edit it via the config editor (Tools->Options->Advanced->General tab->Config editor button on the lower right): set the key `mailnews.mark_message_read.auto` to `false`.
Answer: In Sylpheed, under the Configuration Menu -> Common Preferences choose the Details tab (right-most one), then under the Interface sub-tab uncheck Always mark as read when a message is opened.


Why is are button onclick event not working?

Question: I have an html page with two buttons. In my script I have functions for those button's onclick event, but when I click on those buttons, nothing happens. In the console I see the following error:
TypeError: document.getElementById(...) is null
on the line of my button function.
My Script:
var page = 0;
var panel = 0;
var panelNumber = [2,6,6,5];

window.addEventListener('load', findPage);

function findPage() {
    for (panel = 0; panel < panelNumber[page]; panel++) {
        var elem = document.createElement("img");
        elem.setAttribute("src", "../Images/" + page + "." + panel + ".jpg");
        elem.setAttribute("width", "100%");
        document.getElementById("chapter").appendChild(elem);
    }
};

document.getElementById("next").onclick = function () {
    if (page < panelNumber.length) {
        page++;
        findPage();
    }
};

document.getElementById("first").onclick = function () {
    if (page != 0) {
        page = 0;
        findPage();
    }
};

document.getElementById("previous").onclick = function () {
    if (page > 0) {
        page--;
        findPage();
    }
};

My HTML:

    <link href="../css/bootstrap-theme.css" rel="stylesheet" />
    <link href="../css/bootstrap.css" rel="stylesheet" />
    <link href="../css/MyStyle.css" rel="stylesheet" />

<button id="previous" class="btn btn-default">previous</button>

<button id="first" class="btn btn-default" >first</button>

<button id="next" class="btn btn-default">next</button>

I've already scrolled through a lot of the same question here, but the answer was window.addEventListener('load'), and I already did that.
Comment: You will need to include all the `document.getElementById("...").onclick` calls in your `findPage()` function.
Comment: Is this flagged as jQuery because if you actually used jQuery then you wouldn't have these problems?
Comment: @RichLinnell, No. It's flagged as jquery because I didn't know what jquery is, and that tag was suggested. i guess I'll take that tag off...
Answer: As of now the code is executed without page content be loaded in DOM. When you are adding event handler in statement
document.getElementById("next").onclick = function () {

You need to wait for DOM to build. You should use DOMContentLoaded event

The DOMContentLoaded event is fired when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.

document.addEventListener("DOMContentLoaded", function(event) {
    console.log("DOM fully loaded and parsed");
    //Your code to bind event handler

    document.getElementById("next").onclick = function () {
    }
});

Answer: Your code fails at this line
document.getElementById("next").onclick = function () {

Because the element can't be found at the time your script runs. Place your scripts at the end of your :

Comment: Great addition, haven't thought about that potential issue!