missing /bin folder inside conda environment

Question: I created a conda environment using following command:
conda create -p D:\batch\tasks\shared\test-condaenv-users python=3.7 pip -y

But noticed that when I activate the environment then try to pip install a new package I get Access Denied (as if it was trying to install in ProgramData instead of inside the environment)
Then I noticed that the /bin/ folder is missing (see documentation that clearly states there should be a bin folder in a conda environment). Any idea why?
EDIT:
I also tried where pip
before activating environment,
it gives
C:\Anaconda3\Scripts\pip.exe

After activating the environment, it gives (in this order)
D:\batch\tasks\shared\test-condaenv-users\Scripts\pip.exe
C:\Anaconda3\Scripts\pip.exe

Environment Information
conda info

     active environment : D:\batch\tasks\shared\test-condaenv-users
    active env location : D:\batch\tasks\shared\test-condaenv-users
            shell level : 1
       user config file : D:\Users\_azbatchtask_14\.condarc
 populated config files :
          conda version : 4.6.11
    conda-build version : 3.17.8
         python version : 3.7.3.final.0
       base environment : C:\Anaconda3  (read only)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Anaconda3\pkgs
                          D:\Users\_azbatchtask_14\.conda\pkgs
                          D:\Users\_azbatchtask_14\AppData\Local\conda\conda\pkgs
       envs directories : D:\Users\_azbatchtask_14\.conda\envs
                          C:\Anaconda3\envs
                          D:\Users\_azbatchtask_14\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.6.11 requests/2.18.4 CPython/3.7.3 Windows/10 Windows/10.0.14393
          administrator : False
             netrc file : None
           offline mode : False

conda list --show-channel-urls

# packages in environment at D:\batch\tasks\shared\test-condaenv-users:
#
# Name                    Version                   Build  Channel
ca-certificates           2019.5.15                     0    defaults
certifi                   2019.6.16                py37_0    defaults
openssl                   1.1.1c               he774522_1    defaults
pip                       19.1.1                   py37_0    defaults
python                    3.7.3                h8c8aaf0_1    defaults
setuptools                41.0.1                   py37_0    defaults
sqlite                    3.28.0               he774522_0    defaults
vc                        14.1                 h0510ff6_4    defaults
vs2015_runtime            14.15.26706          h3a45250_4    defaults
wheel                     0.33.4                   py37_0    defaults
wincertstore              0.2                      py37_0    defaults

Find below the structure I have
Directory of D:\batch\tasks\shared\test-condaenv-users

06/27/2019  04:29 AM    <DIR>          .
06/27/2019  04:29 AM    <DIR>          ..
04/20/2018  01:28 PM            19,208 api-ms-win-core-console-l1-1-0.dll
04/20/2018  01:28 PM            18,696 api-ms-win-core-datetime-l1-1-0.dll
04/20/2018  01:28 PM            18,696 api-ms-win-core-debug-l1-1-0.dll
04/20/2018  01:28 PM            18,696 api-ms-win-core-errorhandling-l1-1-0.dll
04/20/2018  01:29 PM            22,280 api-ms-win-core-file-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-file-l1-2-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-file-l2-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-handle-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-heap-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-interlocked-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-core-libraryloader-l1-1-0.dll
04/20/2018  01:37 PM            21,256 api-ms-win-core-localization-l1-2-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-memory-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-namedpipe-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-core-processenvironment-l1-1-0.dll
04/20/2018  01:37 PM            20,744 api-ms-win-core-processthreads-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-processthreads-l1-1-1.dll
04/20/2018  01:37 PM            18,184 api-ms-win-core-profile-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-rtlsupport-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-string-l1-1-0.dll
04/20/2018  01:37 PM            20,744 api-ms-win-core-synch-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-synch-l1-2-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-core-sysinfo-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-timezone-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-util-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-crt-conio-l1-1-0.dll
04/20/2018  01:37 PM            22,792 api-ms-win-crt-convert-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-crt-environment-l1-1-0.dll
04/20/2018  01:37 PM            20,744 api-ms-win-crt-filesystem-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-crt-heap-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-crt-locale-l1-1-0.dll
04/20/2018  01:37 PM            27,912 api-ms-win-crt-math-l1-1-0.dll
04/20/2018  01:37 PM            26,888 api-ms-win-crt-multibyte-l1-1-0.dll
04/20/2018  01:37 PM            71,432 api-ms-win-crt-private-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-crt-process-l1-1-0.dll
04/20/2018  01:37 PM            23,304 api-ms-win-crt-runtime-l1-1-0.dll
04/20/2018  01:37 PM            24,840 api-ms-win-crt-stdio-l1-1-0.dll
04/20/2018  01:37 PM            24,840 api-ms-win-crt-string-l1-1-0.dll
04/20/2018  01:37 PM            21,256 api-ms-win-crt-time-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-crt-utility-l1-1-0.dll
11/13/2018  04:56 PM           329,368 concrt140.dll
06/27/2019  04:29 AM    <DIR>          conda-meta
06/27/2019  04:29 AM    <DIR>          DLLs
06/27/2019  04:29 AM    <DIR>          include
06/27/2019  04:29 AM    <DIR>          Lib
06/27/2019  04:29 AM    <DIR>          Library
06/27/2019  04:29 AM    <DIR>          libs
03/25/2019  08:21 PM            12,769 LICENSE_PYTHON.txt
11/13/2018  04:56 PM           625,808 msvcp140.dll
11/13/2018  04:56 PM            31,896 msvcp140_1.dll
11/13/2018  04:56 PM           195,248 msvcp140_2.dll
04/24/2019  08:30 PM            95,232 python.exe
04/24/2019  08:30 PM           438,272 python.pdb
04/24/2019  08:30 PM            51,712 python3.dll
04/24/2019  08:30 PM         3,745,792 python37.dll
04/24/2019  08:30 PM         9,523,200 python37.pdb
04/24/2019  08:30 PM            93,696 pythonw.exe
04/24/2019  08:30 PM           438,272 pythonw.pdb
06/27/2019  04:29 AM    <DIR>          Scripts
06/27/2019  04:29 AM    <DIR>          tcl
06/27/2019  04:29 AM    <DIR>          Tools
04/20/2018  01:37 PM         1,016,584 ucrtbase.dll
11/13/2018  04:56 PM           386,720 vccorlib140.dll
11/13/2018  04:56 PM           155,280 vcomp140.dll
11/13/2018  04:56 PM            87,200 vcruntime140.dll
              56 File(s)     18,091,625 bytes
              11 Dir(s)  69,282,779,136 bytes free
"\Lib"
 Volume in drive D is Temporary Storage
 Volume Serial Number is 2AF3-E29E

 Directory of D:\batch\tasks\shared\test-condaenv-users\Lib

06/27/2019  04:29 AM    <DIR>          .
06/27/2019  04:29 AM    <DIR>          ..
03/25/2019  08:21 PM             5,580 abc.py
03/25/2019  08:21 PM            32,814 aifc.py
03/25/2019  08:21 PM               477 antigravity.py
03/25/2019  08:21 PM            95,103 argparse.py
03/25/2019  08:21 PM            12,575 ast.py
03/25/2019  08:21 PM            11,328 asynchat.py
06/27/2019  04:29 AM    <DIR>          asyncio
03/25/2019  08:21 PM            20,118 asyncore.py
03/25/2019  08:21 PM            20,380 base64.py
03/25/2019  08:21 PM            31,489 bdb.py
03/25/2019  08:21 PM            13,954 binhex.py
03/25/2019  08:21 PM             2,557 bisect.py
03/25/2019  08:21 PM            12,410 bz2.py
03/25/2019  08:21 PM            24,826 calendar.py
03/25/2019  08:21 PM            34,549 cgi.py
03/25/2019  08:21 PM            12,018 cgitb.py
03/25/2019  08:21 PM             5,435 chunk.py
03/25/2019  08:21 PM            14,860 cmd.py
03/25/2019  08:21 PM            10,619 code.py
03/25/2019  08:21 PM            36,287 codecs.py
03/25/2019  08:21 PM             5,994 codeop.py
06/27/2019  04:29 AM    <DIR>          collections
03/25/2019  08:21 PM             4,064 colorsys.py
03/25/2019  08:21 PM            13,649 compileall.py
06/27/2019  04:29 AM    <DIR>          concurrent
03/25/2019  08:21 PM            54,283 configparser.py
03/25/2019  08:21 PM            23,774 contextlib.py
03/25/2019  08:21 PM               129 contextvars.py
03/25/2019  08:21 PM             8,815 copy.py
03/25/2019  08:21 PM             7,017 copyreg.py
03/25/2019  08:21 PM             5,805 cProfile.py
03/25/2019  08:21 PM             3,346 crypt.py
03/25/2019  08:21 PM            16,180 csv.py
06/27/2019  04:29 AM    <DIR>          ctypes
06/27/2019  04:29 AM    <DIR>          curses
03/25/2019  08:21 PM            48,508 dataclasses.py
03/25/2019  08:21 PM            86,298 datetime.py
06/27/2019  04:29 AM    <DIR>          dbm
03/25/2019  08:21 PM               320 decimal.py
03/25/2019  08:21 PM            84,387 difflib.py
03/25/2019  08:21 PM            19,888 dis.py
06/27/2019  04:29 AM    <DIR>          distutils
03/25/2019  08:21 PM           104,284 doctest.py
03/25/2019  08:21 PM             2,815 dummy_threading.py
06/27/2019  04:29 AM    <DIR>          email
06/27/2019  04:29 AM    <DIR>          encodings
06/27/2019  04:29 AM    <DIR>          ensurepip
03/25/2019  08:21 PM            34,778 enum.py
03/25/2019  08:21 PM             9,830 filecmp.py
03/25/2019  08:21 PM            14,568 fileinput.py
03/25/2019  08:21 PM             4,056 fnmatch.py
03/25/2019  08:21 PM            15,143 formatter.py
03/25/2019  08:21 PM            23,639 fractions.py
03/25/2019  08:21 PM            35,257 ftplib.py
03/25/2019  08:21 PM            32,441 functools.py
03/25/2019  08:21 PM             4,756 genericpath.py
03/25/2019  08:21 PM             7,489 getopt.py
03/25/2019  08:21 PM             5,994 getpass.py
03/25/2019  08:21 PM            21,967 gettext.py
03/25/2019  08:21 PM             5,638 glob.py
03/25/2019  08:21 PM            20,338 gzip.py
03/25/2019  08:21 PM             9,534 hashlib.py
03/25/2019  08:21 PM            23,017 heapq.py
03/25/2019  08:21 PM             6,517 hmac.py
06/27/2019  04:29 AM    <DIR>          html
06/27/2019  04:29 AM    <DIR>          http
06/27/2019  04:29 AM    <DIR>          idlelib
03/25/2019  08:21 PM            53,292 imaplib.py
03/25/2019  08:21 PM             3,795 imghdr.py
03/25/2019  08:21 PM            10,536 imp.py
06/27/2019  04:29 AM    <DIR>          importlib
03/25/2019  08:21 PM           117,615 inspect.py
03/25/2019  08:21 PM             3,517 io.py
03/25/2019  08:21 PM            75,072 ipaddress.py
06/27/2019  04:29 AM    <DIR>          json
03/25/2019  08:21 PM             2,245 keyword.py
06/27/2019  04:29 AM    <DIR>          lib2to3
03/25/2019  08:21 PM             5,312 linecache.py
03/25/2019  08:21 PM            78,027 locale.py
06/27/2019  04:29 AM    <DIR>          logging
03/25/2019  08:21 PM            12,983 lzma.py
03/25/2019  08:21 PM             6,123 macpath.py
03/25/2019  08:21 PM            78,654 mailbox.py
03/25/2019  08:21 PM             8,104 mailcap.py
03/25/2019  08:21 PM            20,880 mimetypes.py
03/25/2019  08:21 PM            23,035 modulefinder.py
06/27/2019  04:29 AM    <DIR>          msilib
06/27/2019  04:29 AM    <DIR>          multiprocessing
03/25/2019  08:21 PM             5,566 netrc.py
03/25/2019  08:21 PM            43,088 nntplib.py
03/25/2019  08:21 PM            22,340 ntpath.py
03/25/2019  08:21 PM             2,584 nturl2path.py
03/25/2019  08:21 PM            10,244 numbers.py
03/25/2019  08:21 PM             5,824 opcode.py
03/25/2019  08:21 PM            10,863 operator.py
03/25/2019  08:21 PM            60,371 optparse.py
03/25/2019  08:21 PM            37,756 os.py
03/25/2019  08:21 PM            49,389 pathlib.py
03/25/2019  08:21 PM            62,544 pdb.py
03/25/2019  08:21 PM            57,837 pickle.py
03/25/2019  08:21 PM            91,220 pickletools.py
03/25/2019  08:21 PM             8,916 pipes.py
03/25/2019  08:21 PM            21,461 pkgutil.py
04/24/2019  07:46 PM            47,067 platform.py
03/25/2019  08:21 PM            29,885 plistlib.py
03/25/2019  08:21 PM            14,964 poplib.py
03/25/2019  08:21 PM            15,772 posixpath.py
03/25/2019  08:21 PM            20,884 pprint.py
03/25/2019  08:21 PM            22,046 profile.py
03/25/2019  08:21 PM            27,313 pstats.py
03/25/2019  08:21 PM             4,763 pty.py
03/25/2019  08:21 PM            15,137 pyclbr.py
03/25/2019  08:21 PM           106,731 pydoc.py
06/27/2019  04:29 AM    <DIR>          pydoc_data
03/25/2019  08:21 PM             8,001 py_compile.py
03/25/2019  08:21 PM            11,359 queue.py
03/25/2019  08:21 PM             7,254 quopri.py
03/25/2019  08:21 PM            27,557 random.py
03/25/2019  08:21 PM            15,192 re.py
03/25/2019  08:21 PM             5,267 reprlib.py
03/25/2019  08:21 PM             7,097 rlcompleter.py
03/25/2019  08:21 PM            11,959 runpy.py
03/25/2019  08:21 PM             6,442 sched.py
03/25/2019  08:21 PM             2,038 secrets.py
03/25/2019  08:21 PM            18,561 selectors.py
03/25/2019  08:21 PM             8,527 shelve.py
03/25/2019  08:21 PM            12,956 shlex.py
03/25/2019  08:21 PM            41,329 shutil.py
03/25/2019  08:21 PM             2,123 signal.py
06/27/2019  04:29 AM    <DIR>          site-packages
03/25/2019  08:21 PM            21,649 site.py
03/25/2019  08:21 PM            34,711 smtpd.py
03/25/2019  08:21 PM            44,210 smtplib.py
03/25/2019  08:21 PM             7,086 sndhdr.py
03/25/2019  08:21 PM            27,363 socket.py
03/25/2019  08:21 PM            26,922 socketserver.py
06/27/2019  04:29 AM    <DIR>          sqlite3
03/25/2019  08:21 PM            26,872 sre_compile.py
03/25/2019  08:21 PM             7,177 sre_constants.py
03/25/2019  08:21 PM            39,305 sre_parse.py
03/25/2019  08:21 PM            45,432 ssl.py
03/25/2019  08:21 PM             5,038 stat.py
03/25/2019  08:21 PM            20,651 statistics.py
03/25/2019  08:21 PM            11,564 string.py
03/25/2019  08:21 PM            12,917 stringprep.py
03/25/2019  08:21 PM               257 struct.py
03/25/2019  08:21 PM            69,966 subprocess.py
03/25/2019  08:21 PM            18,375 sunau.py
03/25/2019  08:21 PM             2,131 symbol.py
03/25/2019  08:21 PM             7,274 symtable.py
04/24/2019  07:46 PM            24,649 sysconfig.py
03/25/2019  08:21 PM            24,317 sysconfig.py.orig
03/25/2019  08:21 PM            11,408 tabnanny.py
03/25/2019  08:21 PM            92,617 tarfile.py
03/25/2019  08:21 PM            23,135 telnetlib.py
03/25/2019  08:21 PM            26,710 tempfile.py
06/27/2019  04:29 AM    <DIR>          test
03/25/2019  08:21 PM            19,494 textwrap.py
03/25/2019  08:21 PM             1,003 this.py
03/25/2019  08:21 PM            48,104 threading.py
03/25/2019  08:21 PM            13,444 timeit.py
06/27/2019  04:29 AM    <DIR>          tkinter
03/25/2019  08:21 PM             3,763 token.py
03/25/2019  08:21 PM            27,030 tokenize.py
03/25/2019  08:21 PM            28,543 trace.py
03/25/2019  08:21 PM            23,438 traceback.py
03/25/2019  08:21 PM            17,076 tracemalloc.py
03/25/2019  08:21 PM               879 tty.py
03/25/2019  08:21 PM           143,602 turtle.py
06/27/2019  04:29 AM    <DIR>          turtledemo
03/25/2019  08:21 PM             9,897 types.py
03/25/2019  08:21 PM            54,602 typing.py
06/27/2019  04:29 AM    <DIR>          unittest
06/27/2019  04:29 AM    <DIR>          urllib
03/25/2019  08:21 PM             6,816 uu.py
03/25/2019  08:21 PM            29,449 uuid.py
06/27/2019  04:29 AM    <DIR>          venv
03/25/2019  08:21 PM            20,242 warnings.py
03/25/2019  08:21 PM            18,229 wave.py
03/25/2019  08:21 PM            20,689 weakref.py
03/25/2019  08:21 PM            23,097 webbrowser.py
06/27/2019  04:29 AM    <DIR>          wsgiref
03/25/2019  08:21 PM             5,913 xdrlib.py
06/27/2019  04:29 AM    <DIR>          xml
06/27/2019  04:29 AM    <DIR>          xmlrpc
03/25/2019  08:21 PM             7,535 zipapp.py
03/25/2019  08:21 PM            80,379 zipfile.py
03/25/2019  08:21 PM             1,801 _bootlocale.py
03/25/2019  08:21 PM            26,424 _collections_abc.py
03/25/2019  08:21 PM             8,749 _compat_pickle.py
03/25/2019  08:21 PM             5,340 _compression.py
03/25/2019  08:21 PM             5,117 _dummy_thread.py
03/25/2019  08:21 PM            14,598 _markupbase.py
03/25/2019  08:21 PM            19,138 _osx_support.py
03/25/2019  08:21 PM           228,535 _pydecimal.py
03/25/2019  08:21 PM            91,166 _pyio.py
03/25/2019  08:21 PM             6,186 _py_abc.py
03/25/2019  08:21 PM             3,115 _sitebuiltins.py
03/25/2019  08:21 PM            25,504 _strptime.py
03/25/2019  08:21 PM             7,214 _threading_local.py
03/25/2019  08:21 PM             5,679 _weakrefset.py
03/25/2019  08:21 PM             5,101 __future__.py
03/25/2019  08:21 PM                64 __phello__.foo.py
06/27/2019  04:29 AM    <DIR>          __pycache__
             172 File(s)      4,330,005 bytes
              34 Dir(s)  69,282,762,752 bytes free
"\Lib\site-packages"
 Volume in drive D is Temporary Storage
 Volume Serial Number is 2AF3-E29E

 Directory of D:\batch\tasks\shared\test-condaenv-users\Lib\site-packages

06/27/2019  04:29 AM    <DIR>          .
06/27/2019  04:29 AM    <DIR>          ..
06/27/2019  04:29 AM    <DIR>          certifi
06/20/2019  10:54 PM             2,990 certifi-2019.06.16-py3.7.egg-info
04/23/2019  01:18 AM               126 easy_install.py
06/27/2019  04:29 AM    <DIR>          pip
06/27/2019  04:29 AM    <DIR>          pip-19.1.1-py3.7.egg-info
06/27/2019  04:29 AM    <DIR>          pkg_resources
03/25/2019  08:21 PM               119 README.txt
06/27/2019  04:29 AM    <DIR>          setuptools
06/27/2019  04:29 AM    <DIR>          setuptools-41.0.1-py3.7.egg-info
06/27/2019  04:29 AM    <DIR>          wheel
06/27/2019  04:29 AM    <DIR>          wheel-0.33.4-py3.7.egg-info
06/28/2018  10:27 PM             5,788 wincertstore-0.2-py3.7.egg-info
10/23/2013  07:30 AM            11,873 wincertstore.py
06/27/2019  04:29 AM    <DIR>          __pycache__
               5 File(s)         20,896 bytes
              11 Dir(s)  69,282,762,752 bytes free

"\Library"
     Volume in drive D is Temporary Storage
     Volume Serial Number is 2AF3-E29E
 Directory of D:\batch\tasks\shared\test-condaenv-users\Library

06/27/2019  04:29 AM    <DIR>          .
06/27/2019  04:29 AM    <DIR>          ..
06/27/2019  04:29 AM    <DIR>          bin
05/29/2019  06:11 PM               412 ct_log_list.cnf
05/29/2019  06:11 PM               412 ct_log_list.cnf.dist
06/27/2019  04:29 AM    <DIR>          include
06/27/2019  04:29 AM    <DIR>          lib
06/27/2019  04:29 AM    <DIR>          misc
05/29/2019  06:11 PM            10,909 openssl.cnf
05/29/2019  06:11 PM            10,909 openssl.cnf.dist
06/27/2019  04:29 AM    <DIR>          ssl
               4 File(s)         22,642 bytes
               7 Dir(s)  69,282,762,752 bytes free
"\Library\bin"
 Volume in drive D is Temporary Storage
 Volume Serial Number is 2AF3-E29E

 Directory of D:\batch\tasks\shared\test-condaenv-users\Library\bin

06/27/2019  04:29 AM    <DIR>          .
06/27/2019  04:29 AM    <DIR>          ..
04/20/2018  01:28 PM            19,208 api-ms-win-core-console-l1-1-0.dll
04/20/2018  01:28 PM            18,696 api-ms-win-core-datetime-l1-1-0.dll
04/20/2018  01:28 PM            18,696 api-ms-win-core-debug-l1-1-0.dll
04/20/2018  01:28 PM            18,696 api-ms-win-core-errorhandling-l1-1-0.dll
04/20/2018  01:29 PM            22,280 api-ms-win-core-file-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-file-l1-2-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-file-l2-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-handle-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-heap-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-interlocked-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-core-libraryloader-l1-1-0.dll
04/20/2018  01:37 PM            21,256 api-ms-win-core-localization-l1-2-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-memory-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-namedpipe-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-core-processenvironment-l1-1-0.dll
04/20/2018  01:37 PM            20,744 api-ms-win-core-processthreads-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-processthreads-l1-1-1.dll
04/20/2018  01:37 PM            18,184 api-ms-win-core-profile-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-rtlsupport-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-string-l1-1-0.dll
04/20/2018  01:37 PM            20,744 api-ms-win-core-synch-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-synch-l1-2-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-core-sysinfo-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-core-timezone-l1-1-0.dll
04/20/2018  01:37 PM            18,696 api-ms-win-core-util-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-crt-conio-l1-1-0.dll
04/20/2018  01:37 PM            22,792 api-ms-win-crt-convert-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-crt-environment-l1-1-0.dll
04/20/2018  01:37 PM            20,744 api-ms-win-crt-filesystem-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-crt-heap-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-crt-locale-l1-1-0.dll
04/20/2018  01:37 PM            27,912 api-ms-win-crt-math-l1-1-0.dll
04/20/2018  01:37 PM            26,888 api-ms-win-crt-multibyte-l1-1-0.dll
04/20/2018  01:37 PM            71,432 api-ms-win-crt-private-l1-1-0.dll
04/20/2018  01:37 PM            19,720 api-ms-win-crt-process-l1-1-0.dll
04/20/2018  01:37 PM            23,304 api-ms-win-crt-runtime-l1-1-0.dll
04/20/2018  01:37 PM            24,840 api-ms-win-crt-stdio-l1-1-0.dll
04/20/2018  01:37 PM            24,840 api-ms-win-crt-string-l1-1-0.dll
04/20/2018  01:37 PM            21,256 api-ms-win-crt-time-l1-1-0.dll
04/20/2018  01:37 PM            19,208 api-ms-win-crt-utility-l1-1-0.dll
11/13/2018  04:56 PM           329,368 concrt140.dll
06/27/2019  04:29 AM             6,548 c_rehash.pl
05/29/2019  06:11 PM         3,407,360 libcrypto-1_1-x64.dll
05/29/2019  06:11 PM        10,088,448 libcrypto-1_1-x64.pdb
05/29/2019  06:11 PM           681,472 libssl-1_1-x64.dll
05/29/2019  06:11 PM         2,322,432 libssl-1_1-x64.pdb
11/13/2018  04:56 PM           625,808 msvcp140.dll
11/13/2018  04:56 PM            31,896 msvcp140_1.dll
11/13/2018  04:56 PM           195,248 msvcp140_2.dll
05/29/2019  06:11 PM           542,720 openssl.exe
05/29/2019  06:11 PM         2,527,232 openssl.pdb
04/22/2019  06:33 PM         1,028,608 sqlite3.dll
04/22/2019  06:33 PM         1,303,552 sqlite3.exe
04/20/2018  01:37 PM         1,016,584 ucrtbase.dll
11/13/2018  04:56 PM           386,720 vccorlib140.dll
11/13/2018  04:56 PM           155,280 vcomp140.dll
11/13/2018  04:56 PM            87,200 vcruntime140.dll
              57 File(s)     25,601,052 bytes
               2 Dir(s)  69,282,762,752 bytes free
 Volume in drive D is Temporary Storage
 Volume Serial Number is 2AF3-E29E

 Directory of D:\batch\tasks\shared\test-condaenv-users\libs

06/27/2019  04:29 AM    <DIR>          .
06/27/2019  04:29 AM    <DIR>          ..
04/24/2019  08:30 PM           170,564 python3.lib
04/24/2019  08:29 PM           342,616 python37.lib
04/24/2019  08:30 PM             1,750 _tkinter.lib
               3 File(s)        514,930 bytes
               2 Dir(s)  69,282,762,752 bytes free

Comment: Did you ever manage to solve this?
Answer: not sure of how the -p flag works as I have never used it but using -n flag seems to fix the error.
To create an environment with a specific version of Python:
conda create -n myenv python=3.7

To create an environment with a specific package:
conda create -n myenv scipy

conda official docs to manage environments.
Comment: Is it also applicable for python 3.9, it performed the upper command through powershell, but still I have no bin folder under user/anaconda34 and I want to use 'base' environment of conda..
Comment: how this answer gets upvoted?! it is completely irrelevant. the question is about -p, which installs the env in a non-default directory. and yes, as i also experienced, there is no bin/python in the newly installed env.


Is there an intuitive explaination of the matrix $A^T A$

Question: Is there an intuitive explaination of the matrix $A^T A$? I have seen this in many field and it is also a matrix with a lot of good properties. Is there some intuitive explaination of it or a name for it?
Comment: [This post](https://math.stackexchange.com/q/2048577/81360) is relevant
Answer: These matrices are sometimes referred to as Gram matrices.
One way to think about it is to note that the $i,j$ entry of $A^TA$ is the dot-product of columns $i$ and $j$ from $A$.
Most of the "nice properties" come out of the fact that $A^TA$ is always positive semidefinite (and symmetric).  Conversely, every (symmetric) positive semidefinite matrix is a Gram matrix.
Comment: I assume here that $A$ has real entries.
Comment: "Every positive semidefinite matrix is a Gram matrix" holds if you are defining positive semidefinitness over $\mathbb C^n$. If you define it over $\mathbb R^n$, it is not true.
Comment: @MartinArgerami Fixed it, thank you


PyQt5 not adding items to List Widget in another function

Question: I have the following simple code, and for some reason addItem() does not add an item to the List Widget in the app's UI in the exec_all() function. add_item() works perfectly fine outside of that function. Ive added the smallest snippet of the relevant code below:
from PyQt5 import QtWidgets, uic
from time import sleep

app = QtWidgets.QApplication([])
dlg = uic.loadUi("Program.ui")

def exec_all():
    dlg.OutputConsole.addItem("Test")
    web_scrap()
    # etc...

# web_scrap(): A function in another file that
# scraps data from website. It needs to wait for
# HTML elements to fully load into DOM at times
# by using time.sleep()
def web_scrap(dlg):
    sleep(5)

dlg.RunAllButton.clicked.connect(exec_all)

dlg.show()
app.exec()

UPDATE: Ive discovered where the problem lies by updating code snippet above to reproduce the problem -- it seems like addItem() does not want to execute before sleep() is called later, which is very odd to me unless addItem() is an asynchronous function? Will i have to use another method other than sleep() in web_scrap() in order to get around this problem?
Comment: This is expected: operations such as `sleep()` or while/for loops are *blocking*, meaning that they prevent the event loop to properly process events, including requests for updates (aka: redraw widgets when required). If you add a `print(dlg.OutputConsole.count())` after `addItem()` you'll see that it will properly print the correct element count of the list widget. Note that using an arbitrary time to wait for another "process" to end is a terrible idea: on a fast computer, you'll be waiting too much, on a slow one it will resume while the process hasn't completed yet.
Comment: In any case, if a time consuming operation doesn't need any communication with the UI, the `threading` module will suffice, but for short operations you may even consider calling [`QApplication.processEvents()`](//doc.qt.io/qt-5/qcoreapplication.html#processEvents). If you instead *do* need to interact with the UI (for example, to notify a finished "job"), you **must** use Qt signals/slots, because UI elements are ***not*** thread-safe; this means using QThread (either by subclassing, or to manage a QObject "worker" subclass) or eventually a QRunnable with a QObject "proxy" to emit signals.
Comment: Sorry but that code is completely insufficient. Please provide an appropriate [mre].
Comment: Ive updated the code snippet that reproduces the problem. By doing so, ive discovered that the problem lies when calling sleep(). That is, addItem() only updates the UI AFTER sleep(), and not before
Comment: I strongly suggest you to take your time and do some proper research on *all* the above topics, because there are plenty of related resources even here on StackOverflow, as you can see from the list of posts (which is just a partial compendium) for which I marked your question as duplicate.
Comment: Thanks for your strong suggestion, I couldn't have known my problem with addItems() had to do with threads. I read you in your respondes as not recommending sleep(), however for web scraping projects its often the only solution when all other solutions have been exhausted. But now ill be more prepared in the future if such problems occur again, thanks!
Answer: So it turns out it was indeed the sleep() pausing execution of the entire thread of my pyqt app. This also caused my pyqt app to hang upon button click. See below for solution.
General problem: Some arbitrary amount of code wont run before a time.sleep() invocation in your python program.
Solution: Create a new thread for that problematic snippet of code by using the threading python module. For example:
from PyQt5 import QtWidgets, uic
from time import sleep
from threading import Thread

app = QtWidgets.QApplication([])
dlg = uic.loadUi("Program.ui")

def problematic_code():
    # ...
    sleep(5)
    # ...

def new_thread():
    newThread = Thread(target=problematic_code)
    newThread.start()

dlg.ButtonInYourApp.clicked.connect(new_thread)

Creating a second thread will allow your code to continue running as expected as well as keep your pyqt app from hanging with the spinning wheel.


Extend an asymptotic relation with integer parameter to real parameters?

Question: A text I'm studying derives the following, for integer s>0 and $n \to \infty$:
$$S(s,n):=\sum_{k=0}^{2n}(-1)^{n+k}\binom{2n}{k}^s \sim
\frac{1}{\sqrt{s}}\big(2\cos\big(\frac{\pi}{2s}\big)\big)^{2ns+s-1}\,2^{2-s}
(\pi\,n)^{(1-s)/2} $$
The derivation involves an s-fold multiple integral and a step occurs where the Hessian, a determinant, is estimated. It is therefore definitely depending on $s$ being a positive integer.
I tested this numerically for many $real$ $s>s_0(n)$ and observe that it also seems to hold.
For instance, here is a small table with n=30 and n=300. $S_e$ = 'exact,' the brute-force summation with lots of precision.  $S_a$ =the asymptotic approximation.
$$
\begin{array}{c|lcr}
s & S_e(\cdot,30) &S_a(\cdot,30) & S_e(\cdot,300)  &S_a(\cdot,300) \\
\hline
149/100 & 0.1267 & 0.1271 & 2.465\,\text{x}\,10^{-6} & 3.721\,\text{x}\,10^{-6} \\
150/100 & 0.3696 & 0.3706 & 0.2084 & 0.2084 \\
18/10 & 1.0260\,\text{x}\,10^{11} &1.0296\,\text{x}\,10^{11} &
4.521\,\text{x}\,10^{116} &4.523\,\text{x}\,10^{116} \\
23/10 & 1.028\,\text{x}\,10^{25} &1.033\,\text{x}\,10^{25} & 1.7817\,\text{x}\,10^{261} &1.7826\,\text{x}\,10^{261}  \\
\end{array}
$$
If $s$ drops much below 1.5, the the exact sum appears to go negative and the asymptotic relationship no longer holds.
I seek a proof that the asymptotic relationship holds for all real $s\ge 1.5$
Comment: Can you use some sort of interpolation or squeeze?
Comment: Hello Herb.  Interpolation seems to imply a numerical procedure, but the formula seems to work O.K. already.  I don't have a proof though, and the s=3/2 phenomenon is interesting as well.  I've heard of Carlson's theorem, but I've never seen it applied to an asymptotic expansion.
Answer: This problem is worked out in de Bruijn, Asymptotic Methods in Analysis, Ch. 4.7 for natural $s$ and Ch. 6.4-6.7 for real $s$.
Comment: I'll look up the book, thanks.
Comment: Nice reference.  It even has a special case analysis for s=3/2.


WPF hide slider track

Question: I'm using WPF (and the MVVM framework) to create an interface which has a slider on it.
<Slider Value="{Binding MotorDemandSpeed}" Maximum="3500" />

I'm trying to hide the track part on the slider so that you are left with just the 'thumb tack'. This is what the slider currently looks like (styles are controlled by a theme):

I've looked around at various methods, however I can't find a method that changes only a single slider.
Help is appreciated.
Answer: You need to set the Template property of this particular Slider instance to be able to override its ControlTemplate:
<Slider Value="{Binding MotorDemandSpeed}" Maximum="3500">
    <Slider.Template>
        <ControlTemplate TargetType="Slider">

        </ControlTemplate>
    </Slider.Template>
</Slider>

Comment: Thanks, this was useful as I was unsure how to define the template. The other answer gave some useful links which helped me create the template itself to hide the track, which is why I set the other one as the answer rather than this one, but this was still useful!
Answer: In order to change the appearance of a control you will need to modify the control template. Each control is made up of many parts, and each part many objects. You can modify individual parts (such as the track) with the correct x:Key and TargetType.
This Question has an example of modifying a scrollbar control template, which is most likely similar to the template of this slider you have. The first step would be to identify the Xaml file in your theme which this slider uses and find the parts that define the trackbar, thumb, etc. From there you should be able to recreate the control to your liking, or just completely remove parts you do not need.
Are you using any third party controls that may have information on how to edit their themes? Perhaps try investigating Modifying Control Templates to get a better understanding of control templates.
Here is the MDSN page for the slider control template, you may find this useful.

WPF hide slider track


Algorithm for the generation of a sequence for an animation effect

Question: Preface
I'm implementing a jQuery plugin which provides text fading effects [demo]. The effects are obtained via character replacements based on sequences of characters indexes.
For example, having this text (11 chars x 9 lines = 99 chars):
var text =
  "0123456789\n"+
  "0123456789\n"+
  "0123456789\n"+
  "0123456789\n"+
  "0123456789\n"+
  "0123456789\n"+
  "0123456789\n"+
  "0123456789\n"+
  "0123456789\n"

this sequence leads to a left-to-right top-to-bottom fading effect [fiddle]:
var sequence =
  [ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10 ,
   11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 ,
   22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 ,
   33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43 ,
   44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 ,
   55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65 ,
   66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76 ,
   77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87 ,
   88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98 ]

It's easy to generate this sequence:
var textToSequence = function(text) {
  for (var s = [], i = 0; i < text.length; i++) s.push(i)
  return s
}
var sequence = textToSequence(text)

The problem
I want to add a clockwise from-out-towards-in 45° twisted spiral effect (no, it's not the name of an extreme dive type :P ). This is the correct sequence for the text above:
var sequence =
  [ 0,                  10,                 98,              88,
    11, 1,              9, 21,              87, 97,          89, 77,
    22, 12, 2,          8, 20, 32,          76, 86, 96,      90, 78, 66,
    33, 23, 13, 3,      7, 19, 31, 43,      65, 75, 85, 95,  91, 79, 67, 55,
    44, 34, 24, 14, 4,  6, 18, 30, 42, 54,  64, 74, 84, 94,  92, 80, 68, 56,
    45, 35, 25, 15, 5,  17, 29, 41, 53,     63, 73, 83, 93,  81, 69, 57,
    46, 36, 26, 16,     28, 40, 52,         62, 72, 82,      70, 58,
    47, 37, 27,         39, 51,             61, 71,          59,
    48,                 38,                 50,              60,
    49 ]

You can see the generated animation here [fiddle].
Now: I can't figure out any algorithm for generating the sequence above. Any suggestions?
Bonus points (and a lot of respect!) if you can suggest algorithms for its variations:

clockwise from-in-towards-out
counter-clockwise from-out-towards-in
counter-clockwise from-in-towards-out
Comment: Your js fiddles were not working because it refused to execute your external files, but I fixed it with http://rawgit.com/: use https://rawgit.com/mdesantis/jquery.textfade/master/lib/jquery.textfade.js for your external source.
Comment: Ooops, I mistook it for a 10x10 square. The included linebreaks complicate this…
Comment: This should be very similar to [this question](http://stackoverflow.com/questions/398299/looping-in-a-spiral/18663455#18663455) here. Do check out the algorithms there.
Comment: I wasn't aware about that problem; I'll fix them, thanks!
Comment: I'm unsure why the last index (99) is not included? Can you explain?
Comment: The last index actually _is_ 98: if you run `text.length` you will obtain 99, not 100. The text I wrote is a bit misleading: it is 9 lines x 11 chars = 99, not 10 lines x 10 chars = 100, as you might think at first sight
Comment: OK, though I think that the `98` (and the other indices for the 11. column) should not appear at all then? Why would you fade-in the linebreaks? See my solution below, it just jumps over them (and correctly starts with the 4 corners)
Answer: Here is what you want.
I fill a diamond, with four corners.
Each for loop draws a 45° line of n items, n being the number of turn we made.
To make things simple, I made a convert function which converts the (x, y) position of the current item into an index.
I only add indices if there were not previously added (to handle the last cases when the corners overlap).
I guess you can easily get your bonus points now.
// add item if not present in the array
function pushIfNotPresent(array, item)
{
    if (array.indexOf(item)==-1)
        array.push(item);
}

// convert x y position to index
function convert(x, y, width)
{
    return y*width+x;
}

$(document).ready(function() {
    var text =
      "0123456789\n"+
      "0123456789\n"+
      "0123456789\n"+
      "0123456789\n"+
      "0123456789\n"+
      "0123456789\n"+
      "0123456789\n"+
      "0123456789\n"+
      "0123456789\n"

    var sequence2 = [];

    var width = 10;
    var height = 9;

    var n=0;

    while(sequence2.length<text.length)
    {
        // top left corner
        for(var i=0 ; i<=n && sequence2.length<text.length ; i++)
        {
            console.log(i);
            pushIfNotPresent(sequence2, convert(i, n-i, width+1));
        }
        // top right corner
        for(var i=0 ; i<=n && sequence2.length<text.length ; i++)
        {
            pushIfNotPresent(sequence2, convert(width-1-n+i, i, width+1));
        }
        // bottom right corner
        for(var i=0 ; i<=n && sequence2.length<text.length ; i++)
        {
            pushIfNotPresent(sequence2, convert(width-1-i, height-1-n+i, width+1));
        }
        // bottom left corner
        for(var i=0 ; i<=n && sequence2.length<text.length ; i++)
        {
            pushIfNotPresent(sequence2, convert(n-i, height-1-i, width+1));
        }

        n++;
    }

    // real spiral
    width = 10;
    var sequence3 = [];
    var angle = 0.0;
    var center = (width-1)/2.0;
    var radius = (width+3)/2.0;
    var i=0;
    while(sequence3.length<text.length && i<10000)
    {
        angle += 2.0*3.1416*1.0/360;
        radius -= 0.001;
        pushIfNotPresent(sequence3, convert(center+radius*Math.cos(angle), center+radius*Math.sin(angle), width+1));
        i++;
    }

    $('#test01i').textFadeIn( { 'text': text, 'milliseconds': 50, 'sequence': sequence2 })
    $('#test01o').textFadeOut({ 'text': text, 'milliseconds': 50, 'sequence': sequence2 })
})

Note that I added a real spiral effect using cos and sin functions in only one for loop (try sequence 3)...
Comment: Where is `sequence3`?
Comment: Sorry, I forgot to update my jsFiddle link. Now I updated both the link and the code on stackoverflow.
Answer: This is a little crazy approach, but works well:
function makeSequence(width, height, linebreak, startinside, clockwise) {
    function square(n) {
        if (n==0) return [];
        if (n==1) return [[0,0]];
        var x, y, seq = [];
        // one round along the edges
        for (x=0, y=0; y<n ; y++) seq.push([x, y]);
        for (x++, y--; x<n ; x++) seq.push([x, y]);
        for (x--, y--; y>=0; y--) seq.push([x, y]);
        for (x--, y++; x>=1; x--) seq.push([x, y]);
        var inside = square(n-2).map(function(p) { p[0]++; p[1]++; return p; })
        return startinside
          ? clockwise
            ? inside.concat(seq.reverse())
            : inside.concat(seq)
          : clockwise
            ? seq.reverse().concat(inside)
            : seq.concat(inside);
    }
    var tl = (height-1)/2;
    return square(width+height).map(function(p) { // rotate it
        var x=p[0], y=p[1];
        return [x/2+y/2-tl, y/2-x/2+tl];
    }).filter(function(p) { // whole numbers
        return p[0] % 1 == 0 && p[1] % 1 == 0;
    }).filter(function(p) { // inside the rectangle
        return p[0]>=0 && p[0]<width && p[1]>=0 && p[1]<height;
    }).map(function(p) { // as sequence numbers instead of coordinates
        return (width+linebreak)*p[1]+p[0];
    });
}

(updated demo - if you compare the sequences, you even can see some small bugs in yours regarding the linebreaks)


Pesquisar por varios ids API .net core

Question: Nao sei se fui claro no titulo porem tenho uma duvida, possuo uma rota da seguinte forma:
/api/produto/v1/Aplicacao/filter

onde esse endpoint é um GET que passo uma palavra como parametro e ele faz a busca das palavras que foram passadas.
A duvida é a seguinte, tenho como fazer a rota algo do tipo /api/produto/v1/Aplicacao/filter/categoria/{id}, onde o id da categoria fosse opcional e se eu nao passar nada na categoria ele use somente a rota até /api/produto/v1/Aplicacao/filter e pesquisa a palavra que foi passada por parametro?
Answer: Uma solução seria passar um id de categoria junto com as palavras na rota /api/produto/v1/Aplicacao/filter e, caso esse id seja null, fazer a busca somente pelas palavras.
Para isso, basta criar uma DTO com esses dois campos: uma lista de palavras e uma id de categoria. Essa DTO seria passada como parâmetro no request dentro da controller.
DTO
public class YourDto
{
    public List<String> Palavras { get; set; }
    public int CategoriaId { get; set; }
}

Controller
public IActionResult yourMethodName([FromBody] YourDto dto)

Então basta checar se é null o ID e, se for, só fazer a busca por palavras.

Pesquisar por varios ids API .net core


Backbone/Javascript scope. How to access this.el inside .each

Question: I want to access View's el method  inside each iterator of collection.
This is  mock up of my problem: http://jsfiddle.net/ASdWU/.
Is it possible?
I need it because I want to iterate over models of collections, create and append their view's to .el element (I cannot use jQuery's $() because of has_many relation where each model has its own collection so their css-id is repeated and I cannot select particular id).
Answer: Just pass the view (this) as the third (context) argument to .each():
_.each([1], function() {
         alert(this.el);
}, this);

Forked fiddle.
Comment: Might be worth noting that the callback function will get the array element as an argument.
Answer: Create a variable within the scope that the .each() function can access: http://jsfiddle.net/ASdWU/1/


Vetor para JTextField

Question: Tenho que somar 43 campos de textos que o usuário irá preencher os que irão ser utilizados para ter um total e esse total será utilizado em minha fórmula e não consegui achar uma solução para reduzir essas linhas que fiz manualmente atribuindo a uma variável cada campo. A minha pergunta é:
Consigo elaborar um Vetor para receber campos de textos assim? como seria a fórmula para pegar um Jtext e pegar o valor do próximo e ir somando?
Comment: O que é um JText?E adicione um **[mcve]** para que seja possivel testar e executar seu código.
Comment: JTextField, acabei abreviando por costume, trata-se de um campo de texto.
Answer: Você pode fazer um loop em todos os componentes do seu painel e se caso ele seja uma instância de JTextField, você soma. Ex:
Double total = 0.00;

for (Component c : painel.getComponents()) {
    if (c instanceof JTextField) {
        total += Double.parseDouble(((JTextField) c).getText());
    }
}

Mas lembre-se que todos seus JTextField utilizados no cálculo devem estar no mesmo painel.
Comment: Zulian, muito obrigado cara, deu certinho, criei um painel, joguei todos os controles giratórios lá dentro(agora estou usando JSpinner) e fiz a fórmula, funcionou perfeitamente, valeu galera o apoio. Se alguém souber algum documento bom das funcionalidades de Swing, to tomando um pal aqui pra editar o layout dele. Desde já agradecido.
Comment: Zulian, era JTextField mesmo, desculpa, acabei abreviando por costume, mas valeu cara, irei testar no meu código aqui, só o "System.out.println" que vou precisar mesmo, porque essa variável total eu uso na fórmula.
Comment: Só tem uma problema, pelo que entendi de seu código, você está criando um jTextField a cada rodada do for, mas eu já criei todos os que preciso na tela do jFrame, só quero pegar os valores e somar agora, ai tem o seu segundo for, mas não sei como ele vai passar de um nome para o outro, sendo que cada jText meu são diferentes o nome da variável.
Comment: @GabrielCardoso, o `System.out.println()` era só pra visualizar o resultado.    Dessa maneira que coloquei é mais prática, mas como você já criou, vou atualizar a resposta, dando outro exemplo.
Comment: @GabrielCardoso atualizei a resposta.
Comment: Entendi, foi o que imaginei, de qualquer forma eu teria que atribuir os 43 manualmente na lista, foi praticamente o que eu fiz atribuindo a uma variável. Colocar aqui um pedaço do código.

double TotalCC = 0;

        //Somar os valores passados no centro de custo.
        TotalCC += Double.parseDouble(spnCC1.getValue().toString());
        TotalCC += Double.parseDouble(spnCC2.getValue().toString());
        ...
Mas queria uma forma simplificada de somar isso tudo sem ter que atribuir cada um na mão, porque imagina se eu tivesse muito mais campos..
Comment: @GabrielCardoso sem você apresentar um [mcve] vai ficar dificil ajudar mesmo. A resposta responde ao que foi perguntado, está começando a desvirtuar da duvida inicial, e tudo porque você está apresentando informações que deveriam ter sido adicionadas na pergunta, e não como comentários, fora a não apresentação de um exemplo executável do seu código.
Comment: Postei um pedaço ai do código que estou utilizando no momento, são 43 linhas iguais a essa para cada campo de exceto, eu só queria fazer isso dentro de um for sem precisar atribuir cada campo, o que você me passou realmente funciona, mas eu de qualquer forma irei atribuir cada campo na hora de adicionar na lista. Queria ver se algum método passava por todos jText no painel e ia somando eles.
Comment: @GabrielCardoso se você não quer manipular todos os campos, a solução já foi dada usando loop. Agora se você não está sabendo adicioná-lo no seu código, já é outro problema, e para isso, você **deve** apresentar um **[mcve]** se quiser obter algo mais especifico pra sua solução.
Comment: Você que não entendeu até agora que meu problema é não querer setar isso tudo manualmente, mas relaxa cara, obrigado pela ajuda.
Comment: Na última solução que coloquei, pegando os componentes do painel, você não precisa setar manualmente, olhe novamente e tente entender.
Comment: @GabrielCardoso a solução está no final da resposta, no ultimo laço, ele vai resgatar todos os componentes de texto do painel. Qual a dificuldade? É só aplicar no seu código.
Comment: @Zulian pra não confundir o autor, seria interessante remover o resto, já que aparentemente a outra solução inicial não servirá pra ele.
Comment: Agora apareceu a edição pra mim, vou testar essa, eu estava até então falando da solução anterior.
Comment: @GabrielCardoso Que bom que foi útil. Para os layouts, recomendo ler [a documentação oficial](https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html). Você pode marcar a resposta como correta, clicando no **V** ao lado da mesma.
Comment: Show de bola cara, marquei sim, obrigado pelo documento.

Vetor para JTextField


name description caption don't appear in the wall post

Question: using Facebook Javascript SDK (since FBml doesn't work anymore), posting to a wall using my facebook app does not display name, description and caption at all. I tried adding a link and display, removed description as well, none seems to fix the issue.
Any help or note on this is helpful.
<code>var description = $(this).parent().parent().children('.description').html();
var name = $(this).parent().parent().children('.name').html();

FB.ui(
  {
    method: 'feed',
    attachment:
    {
      name: name,
      caption: 'Test App',
      description: description,
      link: appLink,
      href: appLink
    },
    action_links:
    [
      { text: 'Test App', href: 'appLink' }
    ]
  },
  function(response)
  {
    if (response && response.post_id)
    {
      alert('Post was published.');
    }
    else
    {
      alert('Post was not published.');
    }
  }
);
</code>
Answer: This is actually a facebook bug. I've reported it to Facebook but haven't got any feedback since December 2011 after they've confirmed it a bug and assigned medium priority. Cheers.


How to select id, first_not_null(value1), first_not_null(value2).. on Postgresql

Question: I have a table like this:
+--+---------+---------+
|id|str_value|int_value|
+--+---------+---------+
| 1| 'abc'   |         |
| 1|         |    1    |
| 2| 'abcd'  |         |
| 2|         |    2    |
+--+---------+---------+

I need to get this:
+--+---------+---------+
|id|str_value|int_value|
+--+---------+---------+
| 1| 'abc'   |    1    |
| 2| 'abcd'  |    2    |
+--+---------+---------+

It seems to me that I need something like:
select id, first_not_null(str_value), first_not_null(int_value)
from table
group by id

Is there any acceptable way to do this? I use Postgresql 9.0.1.
Update: this should work with uuid types as well
Comment: uuid. I used max(uuid_value::varchar(36)) as a temporary solution. This is a little bit slower but works.
Comment: If there are multiple non-null values per id, how would you define which one is "first"?
Comment: There aren't. Anyway I need "any" non-null value. In fact I'm trying to get all Ids that have all values filled
Comment: Zimi's solution is likely to be the correct approach then.
Comment: Does it work with uuids?
Comment: ERROR: function max(uuid) does not exist
LINE 1: select id, max(uuid_v)
Comment: What's the data type?
Answer: You should look at http://www.postgresql.org/docs/8.1/static/functions-aggregate.html for aggregate functions.
I guess max should do the work
EDIT: Working example
select id, max(col1), max(col2) from (
    select 1 as id, null as col1, 'test' as col2
    union
    select 1 as id ,'blah' as col1, null as col2
)  x group by id

Comment: Thanks! I used that as a temporary solution. But I suspect there will be some more uuid_value columns and your solution wont fit.
Comment: I used max(uuid_value::varchar(36)) with uuids. This is a little bit slower but works. Thank you.


Can you prove that the sum of the x coordinate and y coordinate products equal cos(θ) without using the law of cosines?

Question: When the product of the x coordinate of a point on a unit circle and the x coordinate of another point on that circle is summed with the product of their respective y values, the result will be cos(θ) where θ is the angle between the two radii.
$$x_{u1}\times x_{u2}+y_{u1}\times y_{u2}=cos(\theta)$$
I've pondered this for a while, read through online resources on vector projections and drawn some diagrams to try and understand this relationship better. However, I'm still slightly confused about how to prove it besides deriving from the law of cosines. Is there another more elementary proof?

Here's the derivation from the law of cosines:

Is there a more elementary proof that as vectors are rotated through the circle at a fixed angle, the decrease in the value of the product of the y coordinates is proportional to the increase in the product of the x coordinates?
I wonder if there's some way to link the relationship to the formula of a circle rather than deriving from the law of cosines?
For two vectors which overlap each other (θ=0) the x, y coordinate "product proportion" is given by the formula used to plot the circle.

As shown above this proportionality is true for cases where $θ>0$ or where one of the coordinates $= 0$, which is tantalisingly close to proof, but I don't think that's enough to prove a general case.
Essentially, I want to prove that as α changes, the changes in $x_1x_2$ and $y_1y_2$ are proportional such that:
$$x_{1b}x_{2b}+y_{1b}y_{2b}=y_{1a}y_{2a}+x_{1a}x_{2a}$$
Comment: You are missing the point that $x_{u1}=\cos \theta_1$ etc.
Comment: Which "cosine rule" did you use in your proof?
Comment: The law of cosines. I've updated the answer to show the proof.
Comment: Can you elaborate a bit jimjim? I understand that the y coordinate of a unit vector is equal to cos(θ) where θ is the angle between that vector and the y axis (and in this case the length of the circumference) but I still can't see the connection between that and the "proportionality of the products".
Comment: first, well done on more explanation. what you need is either rotation on unit circle by using matrices, or complex numbers. either method makes cosine or sine rule a trivial case of more general formulas. I think that might be actually how one derives the cosine rule.
Comment: https://en.wikipedia.org/wiki/Law_of_cosines
Answer: The parameteric equation for a unit circle is $(x,y) \equiv (\cos\theta, \sin\theta)$. Thus, $$x_1x_2 + y_1y_2 = \cos\theta_1\cos\theta_2 + \sin\theta_1\sin\theta_2 \\
= \cos(\theta_1 - \theta_2) \\
= \cos\theta$$
Where $\theta$ is the angle between the two radii, as shown in your figure.
Comment: How did you get from
$\cos\theta_1\cos\theta_2 + \sin\theta_1\sin\theta_2$  to $ \cos(\theta_1 - \theta_2) $ without using the cosine rule that this question is about?
Comment: @jimjim It is not clear to me (from the current form of the question) what "cosine rule" the question is about. Since it's hard for me to imagine why one would need a "more straightforward" proof than this answer, I would guess that OP originally used a different "cosine rule" than the one used here. It is possible, of course, that OP really wanted to ask for a more *elementary* proof rather than a more *straightforward* one.
Comment: I've clarified which cosine rule I used and updated the terminology.
Comment: Could you please explain how you equated $cos\theta_1 cos\theta_2 + sin\theta_1 sin\theta_2$ to $cos(\theta_1 - \theta_2)$
Comment: @JoshHardman : That is the cosine rule written in a different form.
Comment: @JoshHardman that's the [difference formula for cosine](https://brownmath.com/twt/sumdiff.htm), not the cosine rule (cosine rule applies in triangles)
Comment: Thank you! Found a wonderful diagram linked in the textbook which provides a proof of this relationship for smaller angles. A little disappointed I couldn't find an even more elementary way to prove this visually, but at least I can easily show the maths is solid even if it probably appears somewhat obscure to the uninitiated.
Comment: Here are the figures http://math.uaa.alaska.edu/~smiley/trigproofs.html
Answer: I wrote this to supplement Aniruddha's answer and document the process I went through to arrive at a satisfactory solution.
https://myblog1603.wordpress.com/2020/10/08/going-round-in-circles-geometric-proof-of-a-deceptive-formula/
The image is a sketch of a figure which provides the elementary proof and format I was looking to obtain.


Notation for difference of two dates

Question: I am not looking for a formula to calculate the difference of two dates. I am looking for a notation to express the difference of two dates in a formula.
Is there a common way to do that? If not what would be a good way to express that?
I am thinking of something like this:
$t = diff(D_1, D_2)$
where $t \ge 0$ is the number of days and $D_1$ and $D_2$ are two dates.
Comment: Thank you! That looks good. If you would like to formulate it as an answer I will accept it.
Comment: Maybe $\Delta_{D_1\to D_2} D$. That's what we used to do in Physics for moments and work.
Comment: What is the $D$ at the end?
Comment: You can see it as days. $\Delta_{D_1\to D_2}D=D(D_2)-D(D_1)=D_2-D_1$. In fact, sometimes what we're looking for isn't the difference of days but the difference of something else between these days. For example the temperature we have in something is $T_1$ in the day $D_1$ whereas $T_2$ is the temperature in the  day $D_2$. Then $\Delta_{D_1\to D_2}T=T(D_2)-T(D_1)=T_2-T_1$.
Comment: But in fact the $D_1\to D_2$ should be under $\Delta D$ and $\Delta T$ just like for limits: $\lim\limits_{D_1\to D_2}$, but I failed to represent it here.
Comment: It doesn't really matters (at least for me xD). I'll formulate it as an answer. You're welcome!
Answer: To express the difference of two quantities $Q_1$ and $Q_2$ in two different states $1$ and $2$ we use the $\mathop{\Delta{Q}}\limits_{1\to 2}=Q_2-Q_1$. Sometimes the states are clear so we just write $\Delta{Q}$ like with $\Delta{E}=(\Delta{m})c$. Sometimes we use $\mathop{\Delta{Q}}\limits_{Q_1\to Q_2}$ when we emphasize on the values. So in your case: $\mathop{\Delta{D}}\limits_{D_1\to D_2}=D_2-D_1$.
However, you should pay attention to what you make the difference for. If the difference is infinitesimally small, we use instead $d$ or $\delta$ like for $v=\frac{dx}{dt}$.
Comment: @yo' Thank you very much for the help!
Comment: @yo' That's good if it reached you. Yo' didn't show up when writing the ping so that's why I sent it there.
Comment: @elevendollar You're welcome!

Notation for difference of two dates


Porque os valores estão se repetindo se não há dados no banco de dados?

Question: Não estou conseguindo resolver esse problema! Quando faço a frequência dos alunos em um determinado dia, o ****status** deste dia é repetido no mês inteiro**. No exemplo abaixo, fiz do dia 1, depois fiz do dia 2 de um aluno apenas, e observem o que aconteceu.

Verifiquei o página que realiza a frequência e está tudo ok, gravando apenas o dia informado, bem como no banco de dados. O problema está no código abaixo, não encontro onde o script faz a cópia do dia nos dias seguintes.
Código utilizado:

<?php echo form_open(site_url('admin/attendance_report_selector')); ?>

    <?php
    function isWeekend($date) {
      return (date('N', strtotime($date)) >= 7);
    }
    $query = $this->db->get('class');
    if ($query->num_rows() > 0) :
      $class = $query->result_array();
    ?>

        Ano escolar
        <select class="form-control selectboxit" name="class_id" onchange="select_section(this.value)">
          <option value="">Selecione</option>
          <?php foreach ($class as $row) : ?>
            <option value="<?php echo $row['class_id']; ?>" <?php if ($class_id == $row['class_id']) echo 'selected'; ?>><?php echo $row['name']; ?></option>
          <?php endforeach; ?>
        </select>

  <?php endif; ?>

  <?php
    $query = $this->db->get_where('section', array('class_id' => $class_id));
    if ($query->num_rows() > 0) :
    $sections = $query->result_array();
  ?>

          Turma
          <select class="form-control selectboxit" name="section_id">
            <?php foreach ($sections as $row) : ?>
              <option value="<?php echo $row['section_id']; ?>" <?php if ($section_id == $row['section_id']) echo 'selected'; ?>><?php echo $row['name']; ?></option>
            <?php endforeach; ?>
          </select>

  <?php endif; ?>

      Mês
      <select name="month" class="form-control selectboxit" id="month">
        <?php
        for ($i = 1; $i <= 12; $i++) :
        if ($i == 1) $m = 'Janeiro';
        else if ($i == 2) $m = 'Fevereiro';
        else if ($i == 3) $m = 'Março';
        else if ($i == 4) $m = 'Abril';
        else if ($i == 5) $m = 'Maio';
        else if ($i == 6) $m = 'Junho';
        else if ($i == 7) $m = 'Julho';
        else if ($i == 8) $m = 'Agosto';
        else if ($i == 9) $m = 'Setembro';
        else if ($i == 10) $m = 'Outubro';
        else if ($i == 11) $m = 'Novembro';
        else if ($i == 12) $m = 'Dezembro';
        ?>
          <option value="<?php echo $i; ?>" <?php if ($month == $i) echo 'selected'; ?>>
            <?php echo get_phrase($m); ?>
          </option>
        <?php endfor; ?>
      </select>

      Ano letivo
      <select class="form-control selectboxit" name="sessional_year">
        <?php $sessional_year_options = explode('-', $running_year); ?>
        <option value="<?php echo $sessional_year_options[0]; ?>" <?php if ($sessional_year == $sessional_year_options[0]) echo 'selected'; ?>>
          <?php echo $sessional_year_options[0]; ?></option>
        <option value="<?php echo $sessional_year_options[1]; ?>" <?php if ($sessional_year == $sessional_year_options[1]) echo 'selected'; ?>>
          <?php echo $sessional_year_options[1]; ?></option>
      </select>

  <input type="hidden" name="year" value="<?php echo $running_year; ?>">

    <button type="submit" class="btn btn-info">Gerar relatório</button>

<?php echo form_close(); ?>

<?php if ($class_id != '' && $section_id != '' && $month != '' && $sessional_year != '') : ?>

          <?php
          $section_name = $this->db->get_where('section', array('section_id' => $section_id))->row()->name;
          $section_teacher = $this->db->get_where('section', array('section_id' => $section_id))->row()->teacher_id;
          $class_name = $this->db->get_where('class', array('class_id' => $class_id))->row()->name;
          if ($month == 1) $m = 'Janeiro';
          else if ($month == 2) $m = 'Fevereiro';
          else if ($month == 3) $m = 'Março';
          else if ($month == 4) $m = 'Abril';
          else if ($month == 5) $m = 'Maio';
          else if ($month == 6) $m = 'Junho';
          else if ($month == 7) $m = 'Julho';
          else if ($month == 8) $m = 'Agosto';
          else if ($month == 9) $m = 'Setembro';
          else if ($month == 10) $m = 'Outubro';
          else if ($month == 11) $m = 'Novembro';
          else if ($month == 12) $m = 'Dezembro';
          echo get_phrase('Relatório de frequência');
          ?>

          <?php echo get_phrase('') . ' ' . $class_name; ?> : Turma <?php echo $section_name; ?>

          <?php echo $m . ' de ' . $sessional_year; ?>

          <?php echo 'Professor(a) ' . $this->db->get_where('teacher', array('teacher_id' => $section_teacher))->row()->name; ?>

            #

              Alunos  | Dias letivos do mês

            <?php
              $year = explode('-', $running_year);
              $days = cal_days_in_month(CAL_GREGORIAN, $month, $sessional_year);
              // Código que busca o dias letivos no banco de dados
              for ($i = 1; $i <= $days; $i++) {
                    $diasValidos = $this->db->get_where('school_days', array('day' => $i,'month' => $month))->row();
              if (isWeekend($sessional_year . '-' . $month . '-' . $i))
                continue;
              if($diasValidos->day != NULL){
            ?>
            <?php echo $i; ?>
            <?php } ?>
            <?php } ?>
            Faltas
            F. Acumuladas

          <?php
          $data = array();
          $enrolls = $this->db->get_where('enroll', array('class_id' => $class_id, 'year' => $running_year, 'section_id' => $section_id))->result_array();
          $index = 0;
          $students = [];

          foreach ($enrolls as $enroll) {
            array_push($students, $this->db->get_where('student', array('student_id' => $enroll['student_id']))->row());
            }

          $remStudents = $this->db->get_where('remanejamentos', array(
            'old_class' => $class_id,
            'old_section' => $section_id,
            'year' => $sessional_year,
          ))->result_array();

          foreach ($remStudents as $rem) {
            if (in_array($rem['student_id'], array_column($students, 'student_id')))
              continue;

            array_push($students, $this->db->get_where('student', array('student_id' => $rem['student_id']))->row());
            }

            function orderByName($a, $b) {
              return strcmp($a->name, $b->name);
            }
            usort($students, 'orderByName');

            foreach ($students as $row) :
            $showBlank = false;

            $matriculaData = date('m-Y', strtotime(str_replace('/', '-', $row->matricula)));
            $currentData = date('m-Y', strtotime('01' . '-' . $month . '-' . $sessional_year));

            if ($matriculaData > $currentData && explode('-', $matriculaData)[1] == explode('-', $currentData)[1])
              continue;

            if($matriculaData == $currentData)
              $showBlank = true;

              $remanejado = false;

              $rem = $this->db->get_where('remanejamentos', array(
                'student_id' => $row->student_id,
                'old_class' => $class_id,
                'old_section' => $section_id,
              ))->result_array();

              $newStudent = $this->db->get_where('remanejamentos', array(
                'student_id' => $row->student_id,
                'new_class' => $class_id,
                'new_section' => $section_id,
              ))->result_array();

              $dataRem = null;
              $dataRem2 = null;
              $fullDataRem = null;

              if (sizeof($rem) > 0) {
                $remanejado = true;

                $dataRem = date('m-Y', strtotime(str_replace('/', '-', $rem[0]['data_remanejado'])));
                $fullDataRem = date('d-m-Y', strtotime(str_replace('/', '-', $rem[0]['data_remanejado'])));

                $sectionName = $this->db->get_where('section', array('section_id' => $rem[0]['new_section']))->row()->name;

                if($currentData >= explode('/', $dataRem)[0]){
                  $remName = $row->name . ' - ' .'Rem. p/ Turma ' . $sectionName . ', ' . $rem[0]['data_remanejado'];
                }else{
                  $remName = $row->name;
                }
              }

              if (sizeof($newStudent) > 0) {
                $remanejado = true;

                $sectionName = $this->db->get_where('section', array('section_id' => $newStudent[0]['old_section']))->row()->name;

                $dataRem2 = date('m-Y', strtotime(str_replace('/', '-', $newStudent[0]['data_remanejado'])));
                $fullDataRem = date('d-m-Y', strtotime(str_replace('/', '-', $newStudent[0]['data_remanejado'])));

                $remName = $row->name . ' - ' .'Rem. Turma ' . $sectionName . ', ' . $newStudent[0]['data_remanejado'];
              }

              $curData = date('m-Y', strtotime($sessional_year . '-' . $month));

              if(($curData < $dataRem && $sessional_year != explode('-', $dataRem)[1]) || ($curData < $dataRem2 && $sessional_year == explode('-', $dataRem2)[1]))
                continue;

            $index++;
            ?>

              <?= $index ?>

                <?php
                $transferido = (strlen($row->transferencia) > 1 ? true : false);
                  if ($transferido) {
                    $dataTranferido = $row->transferencia;
                    if(explode('-', $currentData)[0] >= explode('/', $dataTranferido)[1]){
                      $remName = $row->name . ' - ' .' Transferido(a): '.$dataTranferido;
                    }else{
                      $remName = $row->name;
                    }
                  }
                  if ($remanejado || $transferido)
                    echo $remName;
                  else
                    echo $row->name;
                ?>

              <?php
                $diasValidos = $this->db->get_where('school_days', array('month' => $month))->result_array();

                $status = 0;
                for ($i = 1; $i <= $days; $i++) {
                  if(in_array($i, array_column($diasValidos, 'day'))){
                  if (isWeekend($sessional_year . '-' . $month . '-' . $i))
                    break;
                    $curDay = $i;
                    if($i < 10)
                      $curDay = '0' . $i;

                    $matriculaData = date('d-m-Y', strtotime(str_replace('/', '-', $row->matricula)));
                    $currentData = date('d-m-Y', strtotime($curDay . '-' . $month . '-' . $sessional_year));

                    $timestamp != null;
                      $timestamp = strtotime($i . '-' . $month . '-' . $sessional_year);
                      if($timestamp != null) {
                        $attendance = $this->db->get_where('attendance', array(
                          'section_id' => $section_id,
                          'class_id' => $class_id,
                          'year' => $running_year,
                          'timestamp' => $timestamp,
                          'student_id' => $row->student_id
                          ))->result_array();
                        }

                        foreach ($attendance as $row1) :
                          $month_dummy = date('d', $row1['timestamp']);

                          if ($i == $month_dummy){
                            $status = $row1['status'];
                          }
                        endforeach;
              ?>
              <td style="text-align: center; color: white; background:
                <?php if ($status == 1) {
                  echo "#00a651";
                }
                if ($status == 2) {
                  echo '#ee4749';
                }
                ?>;">
                <?php
                  if($status == 1){
                    echo '';
                  }
                  if($status == 2){
                    echo '';
                  }
                ?>

              <?php }}
                $attendance = $this->db->get_where('attendance', array(
                  'section_id' => $section_id,
                  'class_id' => $class_id,
                  'year' => $running_year,
                  'student_id' => $row->student_id
                ))->result_array();
              ?>

              <?php
                $ano = explode('-',$running_year)[0];
                $delimiter = '';
                if($month < 10){
                  $delimiter = 0;
                }
                $timestamp = strtotime($currentData);
                $inicio = strtotime($ano.'-'.$delimiter.$month.'-01T00:00:00.000');
                $aux = 0;
                for($i = 0; $i <= count($attendance); $i++){
                  if($attendance[$i]['status'] == 2 && $attendance[$i]['timestamp'] >= $inicio && $attendance[$i]['timestamp'] <= $timestamp){
                    $aux++;
                  }
                }
                echo $aux;
              ?>

              <?php
                $timestamp = strtotime($currentData);
                $aux = 0;
                for($i = 0; $i <= count($attendance); $i++){
                  if($attendance[$i]['status'] == 2 && $attendance[$i]['timestamp'] <= $timestamp){
                    $aux++;
                  }
                }
                echo $aux;
              ?>

            <?php endforeach; ?>

        <?php ?>

<?php
  $hasData = sizeof($this->db->get_where('workload', array('year' => $sessional_year))->result_array()) > 0 ? true : false;
?>

          Controle de Carga Horária
          Neste Mês
          Meses Anteriores
          Total

Dias de aulas previstas

            <?php
            if ($hasData) {
              $previstasNesteMes = $this->db->get_where('workload', array(
                'year' => $sessional_year,
                'mes_id' => ($month - 1),
              ))->row()->aulas_previstas;

              echo $previstasNesteMes;
            }
            ?>

            <?php
            if ($hasData) {
              $previstasMesesAnteriores = 0;

              for ($i = 0; $i < ($month - 1); $i++) {
                $previstasMesesAnteriores += $this->db->get_where('workload', array(
                  'year' => $sessional_year,
                  'mes_id' => $i,
                ))->row()->aulas_previstas;
              }

              echo $previstasMesesAnteriores;
            }
            ?>

            <?php
            if ($hasData) {
              echo $previstasMesesAnteriores + $previstasNesteMes;
            }
            ?>

Dias de aulas dadas

            <?php
            if ($hasData) {
              $dadasNesteMes = $this->db->get_where('workload', array(
                'year' => $sessional_year,
                'mes_id' => ($month - 1),
              ))->row()->aulas_dadas;

              echo $dadasNesteMes;
            }
            ?>

            <?php
            if ($hasData) {
              $dadasMesesAnteriores = 0;

              for ($i = 0; $i < ($month - 1); $i++) {
                $dadasMesesAnteriores += $this->db->get_where('workload', array(
                  'year' => $sessional_year,
                  'mes_id' => $i,
                ))->row()->aulas_dadas;
              }

              echo $dadasMesesAnteriores;
            }
            ?>

            <?php
            if ($hasData) {
              echo $dadasMesesAnteriores + $dadasNesteMes;
            }
            ?>

Dias de aulas a repor

            <?php
            if ($hasData) {
              $reportNesteMes = $this->db->get_where('workload', array(
                'year' => $sessional_year,
                'mes_id' => ($month - 1),
              ))->row()->aulas_report;

              echo $reportNesteMes;
            }
            ?>

            <?php
            if ($hasData) {
              $reportMesesAnteriores = 0;

              for ($i = 0; $i < ($month - 1); $i++) {
                $reportMesesAnteriores += $this->db->get_where('workload', array(
                  'year' => $sessional_year,
                  'mes_id' => $i,
                ))->row()->aulas_report;
              }

              echo $reportMesesAnteriores;
            }
            ?>

            <?php
            if ($hasData) {
              echo $reportMesesAnteriores + $reportNesteMes;
            }
            ?>

    Observações
    <textarea rows="6" class="form-control" disabled style="resize: none">
      <?php
        if ($hasData) {
        echo $this->db->get_where('workload_observations', array('year' => $sessional_year, 'mes_id' => ($month - 1),
        'turno' => $this->db->get_where('section', array( 'section_id' => $section_id,))->row()->nick_name))->row()->content;
        }
      ?>
    </textarea>

        <a href="<?php echo site_url('admin/attendance_report_print_view/' . $class_id . '/' . $section_id . '/' . $month . '/' . $sessional_year); ?>" class="btn btn-primary" target="_blank">
          Imprimir relatório

<?php endif; ?>

Answer: Pelo que vi vc só precisa mudar onde esta inicializando a variável $status nessa parte do código
<?php
            $diasValidos = $this->db->get_where('school_days', array('month' => $month))->result_array();

            $status = 0;
            for ($i = 1; $i <= $days; $i++) {
              if(in_array($i, array_column($diasValidos, 'day'))){

deixa para setar a variavel $status para cada vez que passar no loop, após a linha do for assim:
<?php
            $diasValidos = $this->db->get_where('school_days', array('month' => $month))->result_array();

            for ($i = 1; $i <= $days; $i++) {
              $status = 0;
              if(in_array($i, array_column($diasValidos, 'day'))){


How can I access the copy buffer on the web?

Question: Wild question here.
Is it possible to access the copy buffer on the web. What I mean is. Can I go into Photoshop. Select a piece of a photo. Copy that piece and paste it into some element.
That something would be like a Java applet or Flash or Silverlight or anything. I am just wondering if it is possible and if someone could point me in a direction. Since a few google searches have only found where you can copy files and paste via a Java applet.
Comment: Does this help: http://www.exampledepot.com/egs/java.awt.datatransfer/ToClipImg.html
Answer: You should perhaps look into this article about granting Javascript access to the clipboard. Do some testing afterward, to check if you can access the data or not.
Comment: This is for text data (since javascript can't nativly handle binary data). But not the data I'm looking for. Thanks though.


How to prove that $\sum_{k=1}^n k! \cdot \binom{n}{k}=\lfloor e \cdot n! - 1 \rfloor$

Question: The integer sequence A007526 is a sequence with many equivalent formulations. I have noticed the following expression, which seems to be correct. However, I am not sure how to prove it.
Prove that $$\sum_{k=1}^n k! \cdot \binom{n}{k}=\lfloor e \cdot n! - 1 \rfloor$$

How is the constant $e$ derived?
Another question:
If I define $s = \lfloor e \cdot n! - 1 \rfloor$, can I solve for $n = f(s)$?
I try this:
We can let $e\cdot n!-1=s+\alpha $ where $0\le \alpha<1$. Then $n!=\frac{s+\alpha +1}{e}$. But I do not know if there is a symbolic representation for the inverse operation of factorial (n!).
Comment: Note that $
\sum_{k = 1}^n {k!\frac{{n!}}{{k!(n - k)!}}}  = n!\sum_{k = 0}^{n - 1} {\frac{1}{{k!}}}
$.
Comment: Check this: https://math.stackexchange.com/a/1194024/42969 – found [with Approach0](https://approach0.xyz/search/?q=OR%20content%3A%24%5Csum_%7Bk%3D1%7D%5En%20k!%20%5Ccdot%20%5Cbinom%7Bn%7D%7Bk%7D%24)
Comment: For your second question see [Inverse of a factorial](https://math.stackexchange.com/q/2078997/42969)
Comment: The constant $e$ seems to appear because on the left you have kind of a truncation of $e$. Recall that $e$ is defined as $\sum_{k=0}^\infty \frac{1}{k!}$.
Comment: Nice! Thank you. My additional question is whether there is a possibility to solve for the inverse of that equation.
Comment: Please, don't use images unless really necessary.
Answer: Using @Gary comment
$$A_n=\sum_{k = 1}^n {k!\frac{{n!}}{{k!(n - k)!}}}  = n!\sum_{k = 0}^{n - 1} {\frac{1}{{k!}}}=e \,n\, \Gamma (n,1)$$
Asymptotically
$$A_n \sim  \frac{1}{6} \sqrt{\frac{\pi }{2}} e^{1-n} n^{n-\frac{1}{2}} (12
   n+1)-\frac{n+1}{n}$$ is a very decent approximation (relative error smaller than $0.01$% if $n>5$).
Solving for $n$ the equation
$$\log\left(\frac{1}{6} \sqrt{\frac{\pi }{2}} e^{1-n} n^{n-\frac{1}{2}} (12
   n+1)-\frac{n+1}{n} \right)=\log(s)$$ will not make any problem using Newton method.
Let me try for $s=123456789$ with the ridiculous $n_0=1$. Newton iterates are
$$\left(
\begin{array}{cc}
k & n_k \\
 0 & 1.00000 \\
 1 & 7.31520 \\
 2 & 11.4305 \\
 3 & 11.0552 \\
 4 & 11.0528 \\
\end{array}
\right)$$
Edit
We can generate the first estimate of Newton method for the zero of function
$$f(n)=\log(e \,n\, \Gamma (n,1))-\log(s)$$ starting with $n_0=1$. It is given by
$$n_1=1+\frac{\log (s)}{1-e \,\text{Ei}(-1)}$$ where appears  the the exponential integral function.
Converted to rational numbers, this is
$$n_1=1+\frac{109}{174}\,\log(s)$$
For the worked example, this gives $n_1=12.6713$.
Using $s=10^k$ some results
$$\left(
\begin{array}{cccc}
k & n_1 & n_2 & \text{solution}\\
 1 & 2.44241 & 2.70237 &  2.70019 \\
 2 & 3.88482 & 4.29521 &  4.28579 \\
 3 & 5.32723 & 5.64096 &  5.63655 \\
 4 & 6.76963 & 6.84323 &  6.84305 \\
 5 & 8.21204 & 7.95886 &  7.95713 \\
 6 & 9.65445 & 9.01519 &  9.00608 \\
 7 & 11.0969 & 10.0274 &  10.0058 \\
 8 & 12.5393 & 11.0051 &  10.9666 \\
 9 & 13.9817 & 11.9544 &  11.8953 \\
 10 & 15.4241 & 12.8802 &  12.7972 \\
 11 & 16.8665 & 13.7856 &  13.676 \\
 12 & 18.3089 & 14.6734 &  14.5347 \\
 13 & 19.7513 & 15.5455 &  15.3757 \\
 14 & 21.1937 & 16.4038 &  16.2009 \\
 15 & 22.6361 & 17.2495 &  17.0118 \\
 16 & 24.0785 & 18.0838 &  17.8098 \\
 17 & 25.5209 & 18.9078 &  18.5960 \\
 18 & 26.9634 & 19.7221 &  19.3714 \\
 19 & 28.4058 & 20.5276 &  20.1367 \\
 20 & 29.8482 & 21.3249 &  20.8929 \\
\end{array}
\right)$$
Edit
Thanking @Gary who, in comments, pushed me, we have
$$ \frac{1}{6} \sqrt{\frac{\pi }{2}} e^{1-n} n^{n-\frac{1}{2}} (12
   n+1)-\frac{n+1}{n}=s$$ Neglecting the $1$ gives
$$\sqrt{2 \pi } e^{1-n} n^{n+\frac 12}=s+1\implies e^{-(n+\frac 12)}\,n^{n+\frac 12}=\frac{(s+1)\,e^{\frac 32}}{\sqrt{2\pi}}$$ that what also approximate as
$$ e^{-(n+\frac 12)}\,\left(n+\frac 12\right)^{n+\frac 12}=\frac{(s+1)\,e^{\frac 32}}{\sqrt{2\pi}}$$
So
$$n+\frac 12=\frac{\log (k)}{W\left(\frac{\log (k)}{e}\right)}\qquad \text{where} \qquad k=\frac{(s+1)\,e^{\frac 32}}{\sqrt{2\pi}}$$
For $s=123456789$, this gives $n=12.0557$.
For $s=10^{20}$, it gives $n=21.7035$.
One or two iterations of Newton method would give the solution
Comment: Let me push you once more. You missed the fact that $$
\left( {n + \frac{1}{2}} \right)^{n + 1/2}  = n^{n + 1/2} \left( {1 + \frac{1}{{2n}}} \right)^{n + 1/2}  \sim n^{n + 1/2} {\rm e}^{1/2} .
$$ Therefore, you may replace $\mathrm{e}^{3/2}$ by $\mathrm{e}^2$ in the definition of $k$. Give it a try!
Comment: Try getting an approximate inverse using the Lambert W-function.
Comment: @Gary. I tried and ... failed. It is so close to Lambert !
Comment: @Gary. I just found it. I shall edit. Thanks for pushing me !


Always installing vscode plugin in docker container doesnt work

Question: I am using vscode with docker container. I have following entry in user settings.json.
<code>"remote.containers.defaultExtensions": [
        "ms-python.python",
        "ms-azuretools.vscode-docker",
        "ryanluker.vscode-coverage-gutters"
    ]
</code>
But when I build or rebuild container, these plugins don't get installed automatically inside container.
Am I doing something wrong ?
Modified
Here is how my dockerfile looks like
<code>FROM ubuntu:bionic

RUN apt-get update
RUN apt-get install -y python3.6 python3-pip
RUN apt-get install -y git libgl1-mesa-dev

# Currently not using requirements.txt to improve caching
#COPY requirements.txt /home/projects/my_project/
#WORKDIR /home/projects/my_project/
#RUN pip3 install -r requirements.txt

RUN pip3 install torch pandas PyYAML==5.1.2 autowrap Cython==0.29.14
RUN pip3 install numpy==1.17.3 open3d-python==0.7.0.0 pytest==5.2.4 pptk
RUN pip3 install scipy==1.3.1 natsort matplotlib lxml opencv-python==126.96.36.199
RUN pip3 install Pillow scikit-learn  testfixtures
RUN pip3 install pip-licenses pylint pytest-cov
RUN pip3 install autopep8

COPY . /home/projects/my_project/
</code>
Comment: please include Dockerfile
Comment: I have added dockerfile content in the question. Is that what you meant ?
Answer: This might be an old question, but to whomever it might concern, here is one solution. I encountered this problem, that particularly the Python extension from VS Code would not install itself inside my Docker container in VS Code. In order to get it to install the python extension (and for me anything else) you have to specify the Python version, like:
<code>    "extensions": [
        "ms-azuretools.vscode-docker",
        "firstname.lastname@example.com",
        "ms-python.vscode-pylance"
    ]
</code>
If you want to see this in action you can clone my repository. Simply open this repo in VS Code, install the extension Remote Container, and then it should start the docker container all by itself.


Dificuldade em localizar valor em vetor em C

Question: boa noite..
vou ser direto..

Sou estudante de ADS e estou no segundo semestre..

preciso desenvolver um sistema de estacionamento rotativo.
Nisso o usuario precisa inserir a placa do veiculo e devemos atribuir a isso se o mesmo é idoso, pne ou padrão, e também o horario de entrada do veiculo no estacionamento.
Porem não estou conseguindo fazer nem a primeira parte do exercicio que seria cadastrar uma placa e depois encontrar ela no vetor onde ela foi cadastrada.

Segue abaixo o código e peço q me ajudem a encontrar onde estou errando.
#include <stdio.h>
#include <stdlib.h>
char placa[5];
int op;

void cadastro ();
void pesquisaPlaca ();

int main () {

cadastro ();
pesquisaPlaca ();

return 0;
}

void cadastro (){
do {
    char placa1;
    printf ("\ndigite a placa do veiculo:");
    scanf ("%s",&placa[placa1]);
    printf ("digite 1 para novo cadastro ou 0 para sair:");
    scanf ("%d",&op);
    placa1++;
} while (op==1);

}

void pesquisaPlaca (){
    char placaPesq;
    int j;

    printf ("\ninsira a placa a ser pesquisada:");
    scanf ("%s",&placaPesq);
    fflush(stdin);

    for (j=0;j<=placa;j++) {
        if (strcmp(placa[j], placaPesq)) {
            printf ("\nplaca %s encontrada.", placa[j]); // nao localiza a placa
        } else {
            printf ("\nplaca nao encontrada");
        }
    }
}

Comment: Note que aqui: `char placa1; printf ("\ndigite a placa do veiculo:"); scanf ("%s",&placa[placa1]);` você declara `placa1` mas não atribui nenhum valor à variável. Ao utilizar em `placa[placa1]` a variável `placa1` conterá lixo de memória.
Answer: Algumas dicas:
Aqui você só guarda uma placa de tamanho de 5 caracteres;
char placa[5];

Você precisa de um vetor de placas que contenha o numero das placas, sugestão:
#define TAMANHO_PLACA 5
#define MAXIMO 10

char placas[MAXIMO][TAMANHO_PLACA];

No cadastro você precisa seguir a mesma ideia e usar o tamanho da placa
int i = 0;
do{
    char tmp[TAMANHO_PLACA];
    printf ("\ndigite a placa do veiculo:");
    scanf ("%s",tmp);
    strcpy(&placas[i][0], tmp);
    i++;
}while(opt != 0 || i == MAXIMO);

para pesquisar, basta percorrer o vetor de placas comparando com a que deseja:
char tmp[TAMANHO_PLACA];
printf ("\ndigite a placa do veiculo:");
scanf ("%s",tmp);
for(int i = 0; i <= MAXIMO; i++)
{
    if (strstr(placas[i], tmp) != NULL)
        printf ("achou:");

}


How to apply code to all the files in a directly and convert xml files to txt files

Question: I'm trying to apply code in python to extract necessary information from each xml file and write them in txt files.
I successfully executed my code but the result shows only one file.
Also, my code doesn't look smart, I would be very glad if anyone can help me to solve the problem and give me some correction.
I'm afraid I'm very beginner so I might have many fundamental mistakes...
here is my code

from xml.etree import ElementTree as ET
import os

path = r'/Users/mo/Documents/annotations/xmls'
filenames = []

for filename in os.listdir(path):
    if not filename.endswith('.xml'):
        continue
    fullname = os.path.join(path,filename)
    filenames.append(fullname)

each_name = filename[:-4]

with open(each_name + '.txt', 'a') as f:

    for filename in filenames:
        tree = ET.parse(filename)
        root = tree.getroot()

        for object in root.findall('object'):
            categoryID = object.find('name').text

            for bnd_box in object.findall('bndbox'):
                Xcenter = (int(bnd_box.find('xmax').text) - int(bnd_box.find('xmin').text))/2
                Ycenter = (int(bnd_box.find('ymax').text) - int(bnd_box.find('ymin').text))/2
                width = int(bnd_box.find('xmax').text)- int(bnd_box.find('xmin').text)
                height = int(bnd_box.find('ymax').text) - int(bnd_box.find('ymin').text)
                Detection_rows = str(categoryID) + str(Xcenter) + str(Ycenter) + str(width) + str(height) + '\n'

    f.write(str(Detection_rows))

Thank you very much
Comment: There doesn't seem to be anything wrong just by a quick glance at the code. Can you tell us __exactly__ why this isn't working for you?
Comment: Thank you very much for your comment, IT IS kind of working, but in the destination file only one file was created, but I wanted to have more because I have more than 2000 xml files in original folder...
Answer: Try this (did not test it)
from xml.etree import ElementTree as ET
import os

path = r'/Users/mo/Documents/annotations/xmls'

for filename in os.listdir(path):
    if not filename.endswith('.xml'):
        continue

    fullname = os.path.join(path, filename)

    with open(fullname[:-4] + '.txt', 'a') as f:

        tree = ET.parse(fullname)
        root = tree.getroot()

        for object in root.findall('object'):
            categoryID = object.find('name').text

            for bnd_box in object.findall('bndbox'):
                Xcenter = (int(bnd_box.find('xmax').text) - int(bnd_box.find('xmin').text))/2
                Ycenter = (int(bnd_box.find('ymax').text) - int(bnd_box.find('ymin').text))/2
                width = int(bnd_box.find('xmax').text)- int(bnd_box.find('xmin').text)
                height = int(bnd_box.find('ymax').text) - int(bnd_box.find('ymin').text)
                Detection_rows = str(categoryID) + str(Xcenter) + str(Ycenter) + str(width) + str(height) + '\n'

        f.write(str(Detection_rows))

Your for loop should be outside the open and you changed filenames for filename. Also, I removed one unnecessary for loop. Let me know if it solves the issue for you.
Comment: oh Thank you very very much for your quick answer! I'll try it now and get it back here !


Sonar-qube 4.5 Timeout issue with big project

Question: I'm using Jenkins to run sonar on all my projects. One of them have over 2 millions line of code and started to produce a timeout error when connecting to sonar (posted bellow is the jenkins build log):

<code>[JENKINS] Archiving /app/users/jenkins/jobs/*****RunSonar/workspace/******/pom.xml to com.****.***.****/****Gui/9.1.0/****Gui-9.1.0.pom
[JENKINS] Archiving /app/users/jenkins/jobs/****_****Gui_RunSonar/workspace/****Gui/target/****Gui.war to com.****.***.****/****Gui/9.1.0/****Gui-9.1.0.war
channel stopped
[workspace] $ /app/tools/apache-maven-3.2.1/bin/mvn -f /app/users/jenkins/jobs/****_****Gui_RunSonar/workspace/****Gui/pom.xml -Dgitbranch=my_development -e -B sonar:sonar -Dsonar.preview.readTimeout=90000 -Dsonar.jdbc.driver=oracle.jdbc.driver.OracleDriver -Dsonar.jdbc.url=jdbc:oracle:thin:@mydb:1521:orcl ******** ******** -Dsonar.host.url=https://********/sonar/ -Dsonar.branch=$gitbranch ******** ********
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.****.***.****:****Gui:war:9.1.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-war-plugin is missing. @ line 408, column 23
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ****Gui 9.1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact aspectj:aspectjrt:jar:1.5.4 has been relocated to org.aspectj:aspectjrt:jar:1.5.4
[WARNING] The artifact aspectj:aspectjweaver:jar:1.5.4 has been relocated to org.aspectj:aspectjweaver:jar:1.5.4
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2
[INFO]
[INFO] --- sonar-maven-plugin:2.5:sonar (default-cli) @ ****Gui ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.033 s
[INFO] Finished at: 2015-01-14T10:31:44+00:00
[INFO] Final Memory: 12M/148M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project ****Gui: Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar failed: SonarQube server can not be reached at https://********/sonar. Please check the parameter 'sonar.host.url'. connect timed out -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project *******: Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar failed: SonarQube server can not be reached at https://********/sonar. Please check the parameter 'sonar.host.url'.
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
 at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
 at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
 at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
 at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
 at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar failed: SonarQube server can not be reached at https://*********/sonar. Please check the parameter 'sonar.host.url'.
 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:144)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
 ... 19 more
Caused by: java.lang.IllegalStateException: SonarQube server can not be reached at https://********/sonar. Please check the parameter 'sonar.host.url'.
 at org.codehaus.mojo.sonar.ServerMetadata.getVersion(ServerMetadata.java:70)
 at org.codehaus.mojo.sonar.ServerMetadata.logSettings(ServerMetadata.java:84)
 at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:128)
 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
 ... 20 more
Caused by: java.net.SocketTimeoutException: connect timed out
 at java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
 at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
 at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
 at java.net.Socket.connect(Socket.java:579)
 at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618)
 at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
 at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
 at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
 at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275)
 at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
 at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
 at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
 at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
 at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
 at org.codehaus.mojo.sonar.ServerMetadata.getConnection(ServerMetadata.java:119)
 at org.codehaus.mojo.sonar.ServerMetadata.remoteContent(ServerMetadata.java:91)
 at org.codehaus.mojo.sonar.ServerMetadata.getVersion(ServerMetadata.java:66)
 ... 23 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Sonar analysis completed: FAILURE</code>

I'm pretty sure the sonar.host.url is correct because all of my other jobs in jenkins that run sonar are working. I already tried to use the "sonar.preview.readTimeout" property but with no success. Sonar produces no log.
Does anyone have any idea how to run sonar to avoid this problem?
Best regards
Answer: Have you tried with localhost instead and see if its able to connect to localhost at the very least?  For localhost you need to have sonar server running locally of course.