text:
Q: cross-compile python ModuleNotFoundError: where the module info is from? I'm cross-building python 3.8. Two errors look simiar:
$ python3 -m venv .
Error: Command '['/home/p3t/penv386/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

$ bin/python3 -Im ensurepip --upgrade --default-pip
Traceback (most recent call last):
  File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'

$ pip3 install --user pipenv
Traceback (most recent call last):
  File "/usr/bin/pip3", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 35, in <module>
  File "/usr/lib/python3.8/plistlib.py", line 65, in <module>
ModuleNotFoundError: No module named 'xml'

I've seen a few similar threads on SO:

*

*build python with zlib: Edit Module/Setup to include zlib or install zlib. I did the edit and verified libz exists. It also has a python snippet to verify but should be run if import ok.

*no module named zlib: Similar solution.

*A few other threads are basically very similar to the above two.

Since the "/usr/lib/libz*" does exist and the xml lib "/usr/lib/libexpat*" does exists too, I start to think the module info probably is missing. How to make sure those two modules are properly populating with their information in the python build?
I cross-compiled using buildroot 2020.08.2. From the buildroot configuration, both xml and zlib are selected. I did a strace, have not seen what could be the cause, here for the venv:
$ cat -n log2-venv | egrep '(openat|newfstatat)' | grep '\.so'
     5  5835  openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
     6  5835  openat(AT_FDCWD, "/lib64/tls/aarch64/libpython3.8.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
     8  5835  openat(AT_FDCWD, "/lib64/tls/libpython3.8.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    10  5835  openat(AT_FDCWD, "/lib64/aarch64/libpython3.8.so.1.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
    12  5835  openat(AT_FDCWD, "/lib64/libpython3.8.so.1.0", O_RDONLY|O_CLOEXEC) = 3

    20  5835  openat(AT_FDCWD, "/lib64/libcrypt.so.1", O_RDONLY|O_CLOEXEC) = 3
    28  5835  openat(AT_FDCWD, "/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
    36  5835  openat(AT_FDCWD, "/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
    43  5835  openat(AT_FDCWD, "/lib64/libutil.so.1", O_RDONLY|O_CLOEXEC) = 3
    50  5835  openat(AT_FDCWD, "/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
    58  5835  openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3

   123  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/encodings/__init__.cpython-38-aarch64-linux-gnu.so", 0x7fc2ad5c10, 0) = -1 ENOENT (No such file or directory)
   124  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/encodings/__init__.abi3.so", 0x7fc2ad5c10, 0) = -1 ENOENT (No such file or directory)
   125  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/encodings/__init__.so", 0x7fc2ad5c10, 0) = -1 ENOENT (No such file or directory)

   496  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/collections/__init__.cpython-38-aarch64-linux-gnu.so", 0x7fc2ad43a0, 0) = -1 ENOENT (No such file or directory)
   497  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/collections/__init__.abi3.so", 0x7fc2ad43a0, 0) = -1 ENOENT (No such file or directory)
   498  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/collections/__init__.so", 0x7fc2ad43a0, 0) = -1 ENOENT (No such file or directory)

   544  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/_heapq.cpython-38-aarch64-linux-gnu.so", {st_mode=S_IFREG|0755, st_size=18528, ...}, 0) = 0
   546  5835  openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/_heapq.cpython-38-aarch64-linux-gnu.so", O_RDONLY|O_CLOEXEC) = 3

   578  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/site-packages/pkg_resources/__init__.cpython-38-aarch64-linux-gnu.so", 0x7fc2ad60c0, 0) = -1 ENOENT (No such file or directory)
   579  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/site-packages/pkg_resources/__init__.abi3.so", 0x7fc2ad60c0, 0) = -1 ENOENT (No such file or directory)
   580  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/site-packages/pkg_resources/__init__.so", 0x7fc2ad60c0, 0) = -1 ENOENT (No such file or directory)

   615  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/binascii.cpython-38-aarch64-linux-gnu.so", {st_mode=S_IFREG|0755, st_size=27656, ...}, 0) = 0
   617  5835  openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/binascii.cpython-38-aarch64-linux-gnu.so", O_RDONLY|O_CLOEXEC) = 3

   629  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/importlib/__init__.cpython-38-aarch64-linux-gnu.so", 0x7fc2ad3af0, 0) = -1 ENOENT (No such file or directory)
   630  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/importlib/__init__.abi3.so", 0x7fc2ad3af0, 0) = -1 ENOENT (No such file or directory)
   631  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/importlib/__init__.so", 0x7fc2ad3af0, 0) = -1 ENOENT (No such file or directory)

   766  5835  newfstatat(AT_FDCWD, "/usr/bin/lzma/__init__.cpython-38-aarch64-linux-gnu.so", 0x7fc2ad3510, 0) = -1 ENOTDIR (Not a directory)
   767  5835  newfstatat(AT_FDCWD, "/usr/bin/lzma/__init__.abi3.so", 0x7fc2ad3510, 0) = -1 ENOTDIR (Not a directory)
   768  5835  newfstatat(AT_FDCWD, "/usr/bin/lzma/__init__.so", 0x7fc2ad3510, 0) = -1 ENOTDIR (Not a directory)

   788  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/grp.cpython-38-aarch64-linux-gnu.so", {st_mode=S_IFREG|0755, st_size=14784, ...}, 0) = 0
   789  5835  openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/grp.cpython-38-aarch64-linux-gnu.so", O_RDONLY|O_CLOEXEC) = 3
   810  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/_struct.cpython-38-aarch64-linux-gnu.so", {st_mode=S_IFREG|0755, st_size=38352, ...}, 0) = 0
   811  5835  openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/_struct.cpython-38-aarch64-linux-gnu.so", O_RDONLY|O_CLOEXEC) = 3

   838  5835  newfstatat(AT_FDCWD, "/usr/bin/lzma/__init__.cpython-38-aarch64-linux-gnu.so", 0x7fc2ad43a0, 0) = -1 ENOTDIR (Not a directory)
   839  5835  newfstatat(AT_FDCWD, "/usr/bin/lzma/__init__.abi3.so", 0x7fc2ad43a0, 0) = -1 ENOTDIR (Not a directory)
   840  5835  newfstatat(AT_FDCWD, "/usr/bin/lzma/__init__.so", 0x7fc2ad43a0, 0) = -1 ENOTDIR (Not a directory)

   918  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/math.cpython-38-aarch64-linux-gnu.so", {st_mode=S_IFREG|0755, st_size=45240, ...}, 0) = 0
   919  5835  openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/math.cpython-38-aarch64-linux-gnu.so", O_RDONLY|O_CLOEXEC) = 3
   930  5835  newfstatat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/_datetime.cpython-38-aarch64-linux-gnu.so", {st_mode=S_IFREG|0755, st_size=75320, ...}, 0) = 0
   931  5835  openat(AT_FDCWD, "/usr/lib/python3.8/lib-dynload/_datetime.cpython-38-aarch64-linux-gnu.so", O_RDONLY|O_CLOEXEC) = 3

A: Not sure exactly, it might be a bug in buildroot that does not resolve dependencies for this scenario. A deeper tracking of the source code seems to show: The xml and zlib packages are enabled when in configuration the python-pip is selected. However, I guess, the module info is compiled by the host-python into .pyc files and included into the target python installation. Buildroot does not rebuild host-python. An implication of that is the module info missing from the target python.
Based on the reasoning, this solution looks to work for me:

*

*After enabling python-pip in configuration, run ls output/build/ | grep python to find all the python related packages.

*On each of those packages, run a make *-dirclean on them. For example, if only python3-3.8.6 and host-python3-3.8.6 were found, run the commands below:

make host-python3-dirclean
make python3-dirclean

*

*Run make again to rebuild.

No need to modify Module/Setup or Module/Setup.local.


text:
Q: vb 2008 webbrowser alternative hello i'm using Visual Basic 2008 Express
is there another webbrowsers such as gekoWebBrowser, but with less files, or is it possible to change default browser used by Visual Basic, from IE to Opera, chrome, firefox..
thanks

A: No, the WebBrowser control included with WinForms is always going to use Internet Explorer (IE) as its rendering agent. It calls the native library shdocvw.dll. There is no way to change that. However, upgrading your computer's version of IE will upgrade the rendering agent used by the control.
Lots of people don't like being stuck with IE, however, and for very good reason. There are some alternative web browser controls for the .NET Framework. They are essentially wrappers for the rendering engines used by other browsers. Here are a couple of examples:

*

*WebKit .NET is a wrapper for the WebKit engine, used by Google Chrome and Apple Safari.

*GeckoFX is a wrapper for the Gecko rendering engine, used by Mozilla Firefox.

*MozNet is an alternative wrapper for Gecko that claims to be more active than GeckoFX.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why is .ajaxForm() not working when the site is loaded over https? I've reduced the page down to the bare minimum to recreate this problem. It looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
    {% load staticfiles %}
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
    <script src="//malsup.github.com/jquery.form.js"></script>
    <script type="text/javascript">
        $(document).ready(
                function() {
                    $('#signupform').ajaxForm(
                            function(new_html) {
                                alert("testing!");
                            });
                });
    </script>
</head>

<body>
    <form id="signupform" action="{% url 'index' %}" method="post">
            {% csrf_token %}
            {{ form.email }}
            {{ form.university }}
            <button type="submit">
                GET EARLY ACCESS
            </button>
    </form>
</body>
</html>

Basically just a from and some jquery which uses .ajaxForm() to modify the form.
When I load the site over HTTP it works as expected: when the button is pressed an alert with "testing!" shows, the POST is sent out in the background, and there is no redirection. When I run it over HTTPS there's a problem though, it's like the javascript isn't even there. When I click the submit button there is no alert and the site redirects normally.
I've tested this locally with HTTP with the standard $ python manage.py runserver, and with HTTPS using django-sslserver with $ python manage.py runsslserver. I've also run the app on our Heroku staging server and got the exact same http/https difference.
What could be causing this javascript to behave differently when the site is loaded over https as opposed to http?
Update: per comment, here is the javascript console output:

Mixed Content: The page at 'https://localhost:8000/' was loaded over
  HTTPS, but requested an insecure script
  'http://malsup.github.io/jquery.form.js'. This request has been
  blocked; the content must be served over HTTPS.

Which changes the nature of the question. The question is now: why is

//malsup.github.com/jquery.form.js

not being loaded over https? (not sure if I should delete and repost with this new question)

A: https://malsup.github.com/jquery.form.js does a 301 redirect to http://malsup.github.com/jquery.form.js which ends up being a unsecured resource. Hence the error. I frankly don't know why they would do that. That's the issue stopping you then.


text:
Q: Analog of HTTP Redirect for SMTP In HTTP, you can tell the client who asks for example.com/foo/ that it should ask for something.else/instead.
Is there a way to do it in SMTP? That is, if the client sends a message to john@example.com, tell it to send it to jane@somewhere.else instead.
I know that I can receive the message and relay it to jane@somewhere.else. For many reasons I don't want to relay messages via my server. Instead, I want to tell the client that it should send it to another address.
The reasons include:

*

*I cannot notify the client of a failure (well, perhaps this can be done).

*My server will be blacklisted if the message was spam.

*The destination server will consult blacklists with my IP and not with the original sender's IP, etc.

My motivation is:

*

*If this were possible, perhaps it would be a better antispam measure than greylisting.

*My institutional server has no antispam filters, while my personal server uses IP-based blacklists such as Spamcop. After the institutional server has received a message, I can scan the message at the client but it's too late to consult Spamcomp and to inform the sender that the message was filtered out (I consider it a must in any filtering). I wish the institutional server could simply redirect people to my personal server, which is a lot better protected and correctly informs the sender of the problem at the SMTP stage.

A: Sendmail provides FEATURE(redirect) to handle such cases.
It rejects recipient in reply to RCPT TO: with
551 5.1.1 User has moved; please try <newemail@example.com>

Your email server refuses to accept the recipient with hint, it is up to sending host to generate bounce message to the sender.  Spammers may/will get the new email too.  I do not know any email servers handling automatically such redirects.
I have not investigated how well it is handled by various email clients and level of details provided in bounce message by various email servers.


text:
Q: How to create dataframe from dictionary having list of dictionaries? I have a dictionary:
adict = {'dic1': [{'a': True, 'b': False, 'c': True, 'd': True, 'z': False}],
         'dic2': [{'e': True, 'f': False, 'g': False}]}

How can I create dataframe in this format?

True
False

dic1
a
b

c
z

d

dic2
e
f

g

A: Try this:
(pd.DataFrame({i:j[0] for i,j in adict.items()})
.stack()
.to_frame().rename_axis(['d',None])
.assign(cc = lambda x: x.groupby([pd.Grouper(level=1),0]).cumcount())
.reset_index(level=0)
.set_index([0,'cc'],append=True)['d']
.unstack(level=1)
.droplevel(1)
.sort_index(axis=1,ascending=False))

or
d2 = {True:[],False:[]}

for k,v in d.items():
    for k2,v2 in v[0].items():
        d2.get(v2).append((k,k2))

(v := pd.DataFrame(d2).stack()).to_frame('s').set_index(v.str[0],append=True)['s'].str[-1].unstack(level=1).reset_index(level=0,drop=True)

Output:
0    True False
dic1    a     b
dic1    c     z
dic1    d   NaN
dic2    e     f
dic2  NaN     g


text:
Q: Working on a PR for DefinitelyTyped. How can I fix "Cannot find module 'csstype'" when I run "npm run lint markdown-to-jsx"? Here's what I have done so far following the instructions on https://github.com/DefinitelyTyped/DefinitelyTyped#verifying.
I forked https://github.com/DefinitelyTyped/DefinitelyTyped.
I git cloned my fork and ran npm install.
I updated the type definitions and tests of types/markdown-to-jsx.
Now, running npm run lint markdown-to-jsx returns an error.
Why?
npm run lint markdown-to-jsx

> definitely-typed@0.0.3 lint /Users/sunknudsen/tmp/DefinitelyTyped
> dtslint types "markdown-to-jsx"

Error: Errors in typescript@next for external dependencies:
../react/index.d.ts(34,22): error TS2307: Cannot find module 'csstype'.

A: Did you try npm install within types/<your-package-name>, in your case:
cd types/markdown-to-jsx && npm i;

? It should fix it.
If it doesn't, you might just have some dependencies somewhere along the tree that also need to be installed. I see that these are typings for markdown-to-jsx, so I would suggest to also run npm i in the types folder of react, react-dom, and react-markdown.
I was running into a similar issue, and running it in types/react (in addition to running it in my project's types of course) solved it:
cd types/react && npm i


text:
Q: Gitlab docker-compose error: Error executing action `enable` on resource 'runit_service[redis]' I update my gitlab from 12.8 to 12.9 through docker compose.
But after updating i face this error: Error executing action enable on resource 'runit_service[redis]'.
docker-compose logs -f --tail 100:
gitlab_1  | There was an error running gitlab-ctl reconfigure:
gitlab_1  |
gitlab_1  | runit_service[redis] (redis::enable line 66) had an error: Errno::ENOENT: template[/var/log/gitlab/redis/config] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/provider_runit_service.rb line 136) had an error: Errno::ENOENT: No such file or directory @ realpath_rec - /opt/gitlab/sv/redis/log/config
gitlab_1  |
gitlab_1  |         verifications []
gitlab_1  |         cookbook "redis"
gitlab_1  |       end
gitlab_1  |
gitlab_1  |       System Info:
gitlab_1  |       ------------
gitlab_1  |       chef_version=14.14.29
gitlab_1  |       platform=ubuntu
gitlab_1  |       platform_version=16.04
gitlab_1  |       ruby=ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
gitlab_1  |       program_name=/opt/gitlab/embedded/bin/chef-client
gitlab_1  |       executable=/opt/gitlab/embedded/bin/chef-client
gitlab_1  |
gitlab_1  |
gitlab_1  |     ================================================================================
gitlab_1  |     Error executing action `enable` on resource 'runit_service[redis]'
gitlab_1  |     ================================================================================
gitlab_1  |
gitlab_1  |     Errno::ENOENT
gitlab_1  |     -------------
gitlab_1  |     template[/var/log/gitlab/redis/config] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/provider_runit_service.rb line 136) had an error: Errno::ENOENT: No such file or directory @ realpath_rec - /opt/gitlab/sv/redis/log/config
gitlab_1  |
gitlab_1  |     Cookbook Trace:
gitlab_1  |     ---------------
gitlab_1  |     /opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/provider_runit_service.rb:255:in `block in <class:RunitService>'
gitlab_1  |
gitlab_1  |     Resource Declaration:
gitlab_1  |     ---------------------
gitlab_1  |     # In /opt/gitlab/embedded/cookbooks/cache/cookbooks/redis/definitions/redis_service.rb
gitlab_1  |
gitlab_1  |      66:   runit_service 'redis' do
gitlab_1  |      67:     down node['redis']['ha']
gitlab_1  |      68:     template_name 'redis'
gitlab_1  |      69:     options({
gitlab_1  |      70:       service: 'redis',
gitlab_1  |      71:       log_directory: redis_log_dir
gitlab_1  |      72:     }.merge(params))
gitlab_1  |      73:     log_options node['gitlab']['logging'].to_hash.merge(node['redis'].to_hash)
gitlab_1  |      74:   end
gitlab_1  |      75:
gitlab_1  |      76:   if node['gitlab']['bootstrap']['enable']
gitlab_1  |      77:     execute "/opt/gitlab/bin/gitlab-ctl start redis" do
gitlab_1  |      78:       retries 20
gitlab_1  |      79:     end
gitlab_1  |      80:   end
gitlab_1  |      81:
gitlab_1  |
gitlab_1  |     Compiled Resource:
gitlab_1  |     ------------------
gitlab_1  |     # Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/redis/definitions/redis_service.rb:66:in `block in from_file'
gitlab_1  |
gitlab_1  |     runit_service("redis") do
gitlab_1  |       params {:socket_group=>"git", :name=>nil}
gitlab_1  |       provider Chef::Provider::RunitService
gitlab_1  |       action :enable
gitlab_1  |       default_guard_interpreter :default
gitlab_1  |       service_name "redis"
gitlab_1  |       enabled false
gitlab_1  |       running false
gitlab_1  |       masked nil
gitlab_1  |       options {:service=>"redis", :log_directory=>"/var/log/gitlab/redis", :socket_group=>"git", :name=>nil}
gitlab_1  |       pattern "redis"
gitlab_1  |       start_command "start"
gitlab_1  |       stop_command "stop"
gitlab_1  |       status_command "status"
gitlab_1  |       restart_command "restart"
gitlab_1  |       supports {:restart=>true, :reload=>true, :status=>true}
gitlab_1  |       sv_bin "/opt/gitlab/embedded/bin/sv"
gitlab_1  |       sv_dir "/opt/gitlab/sv"
gitlab_1  |       service_dir "/opt/gitlab/service"
gitlab_1  |       lsb_init_dir "/opt/gitlab/init"
gitlab_1  |       log true
gitlab_1  |       owner "root"
gitlab_1  |       group "root"
gitlab_1  |       restart_on_update true
gitlab_1  |       run_template_name "redis"
gitlab_1  |       log_template_name "redis"
gitlab_1  |       check_script_template_name "redis"
gitlab_1  |       finish_script_template_name "redis"
gitlab_1  |       sv_templates true
gitlab_1  |       log_options {"svlogd_size"=>209715200, "svlogd_num"=>30, "svlogd_timeout"=>86400, "svlogd_filter"=>"gzip", "svlogd_udp"=>nil, "svlogd_prefix"=>nil, "udp_log_shipping_host"=>nil, "udp_log_shipping_hostname"=>nil, "udp_log_shipping_port"=>514, "logrotate_frequency"=>"daily", "logrotate_maxsize"=>nil, "logrotate_size"=>nil, "logrotate_rotate"=>30, "logrotate_compress"=>"compress", "logrotate_method"=>"copytruncate", "logrotate_postrotate"=>nil, "logrotate_dateformat"=>nil, "enable"=>true, "ha"=>false, "hz"=>10, "dir"=>"/var/opt/gitlab/redis", "log_directory"=>"/var/log/gitlab/redis", "username"=>"gitlab-redis", "group"=>"gitlab-redis", "uid"=>nil, "gid"=>nil, "shell"=>"/bin/false", "home"=>"/var/opt/gitlab/redis", "bind"=>"127.0.0.1", "port"=>0, "maxclients"=>"10000", "maxmemory"=>"0", "maxmemory_policy"=>"noeviction", "maxmemory_samples"=>5, "tcp_backlog"=>511, "tcp_timeout"=>60, "tcp_keepalive"=>300, "password"=>nil, "unixsocket"=>"/var/opt/gitlab/redis/redis.socket", "unixsocketperm"=>"777", "master"=>true, "master_name"=>"gitlab-redis", "master_ip"=>nil, "master_port"=>6379, "master_password"=>nil, "client_output_buffer_limit_normal"=>"0 0 0", "client_output_buffer_limit_slave"=>"256mb 64mb 60", "client_output_buffer_limit_pubsub"=>"32mb 8mb 60", "save"=>["900 1", "300 10", "60 10000"], "rename_commands"=>{"KEYS"=>""}, "announce_ip"=>nil, "announce_port"=>nil}
gitlab_1  |       declared_type :runit_service
gitlab_1  |       cookbook_name "redis"
gitlab_1  |       recipe_name "enable"
gitlab_1  |       service_mirror # Declared in
gitlab_1  |
gitlab_1  |     service("redis") do
gitlab_1  |       provider Chef::Provider::Service::Simple
gitlab_1  |       action [:nothing]
gitlab_1  |       default_guard_interpreter :default
gitlab_1  |       service_name "redis"
gitlab_1  |       enabled nil
gitlab_1  |       running nil
gitlab_1  |       masked nil
gitlab_1  |       pattern "redis"
gitlab_1  |       start_command "/opt/gitlab/embedded/bin/chpst -u root:root /opt/gitlab/embedded/bin/sv start /opt/gitlab/service/redis"
gitlab_1  |       stop_command "/opt/gitlab/embedded/bin/chpst -u root:root /opt/gitlab/embedded/bin/sv stop /opt/gitlab/service/redis"
gitlab_1  |       status_command "/opt/gitlab/embedded/bin/chpst -u root:root /opt/gitlab/embedded/bin/sv status /opt/gitlab/service/redis"
gitlab_1  |       restart_command "/opt/gitlab/embedded/bin/chpst -u root:root /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/redis"
gitlab_1  |       supports {:restart=>true, :reload=>true, :status=>true}
gitlab_1  |     end
gitlab_1  |
gitlab_1  |     end
gitlab_1  |
gitlab_1  |     System Info:
gitlab_1  |     ------------
gitlab_1  |     chef_version=14.14.29
gitlab_1  |     platform=ubuntu
gitlab_1  |     platform_version=16.04
gitlab_1  |     ruby=ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
gitlab_1  |     program_name=/opt/gitlab/embedded/bin/chef-client
gitlab_1  |     executable=/opt/gitlab/embedded/bin/chef-client
gitlab_1  |
gitlab_1  |
gitlab_1  | Running handlers:
gitlab_1  | Running handlers complete
gitlab_1  | Chef Client failed. 0 resources updated in 10 seconds
gitlabdpsoftservercom_gitlab_1 exited with code 1

And my docker-compose.yml file:

version: '3'

services:
  gitlab:
    image: gitlab/gitlab-ce:12.10.8-ce.0
    hostname: mygitlab.ir
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://sample.ir'
        gitlab_rails['gitlab_shell_ssh_port'] = 8822

    ports:
      - "8880:80"
      - "8822:22"
    volumes:
      - ./gitlab-config:/etc/gitlab
      - ./gitlab-data:/var/opt/gitlab
      - ./logs:/var/log/gitlab
    restart: always


text:
Q: How to select rows conditionally in a table with JSON data type column in MySQL 5.7.34? I have following table:
CREATE TABLE tb_products (
    product_id int(11) NOT NULL AUTO_INCREMENT,
    product_name varchar(255) NOT NULL,
    product_attributes json NOT NULL,
    PRIMARY KEY (product_id)
);

One of the row in this table looks like as:

product_attributes field:
[
    {
        "site": "site1",
        "categories": [
            "site1 cat1",
            "site1 cat2",
            "site1 cat3"
        ]
    },
    {
        "site": "site2",
        "categories": [
            "site2 cat1",
            "site2 cat2"
        ]
    }
]

*

*How to select row where site = site1?

*How to select row where site = site1 and categories = site1 cat1?

A: Finding it is relatively easy

CREATE TABLE tb_products  (
    product_id int(11) NOT NULL AUTO_INCREMENT,
    product_name varchar(255) NOT NULL,
    product_attributes json NOT NULL,
    PRIMARY KEY (product_id)
);

INSERT INTO tb_products
VALUES (1,'test','[
    {
        "site": "site1",
        "categories": [
            "site1 cat1",
            "site1 cat2",
            "site1 cat3"
        ]
    },
    {
        "site": "site2",
        "categories": [
            "site2 cat1",
            "site2 cat2"
        ]
    }
]')

SELECT * FROM tb_products
WHERE JSON_SEARCH(product_attributes, 'one', 'site1', null, '$[*].site') Is NOT NULL
AND JSON_SEARCH(product_attributes, 'one', 'site1 cat1', null, '$[*].categories[*]') Is NOT NULL

product_id | product_name | product_attributes
---------: | :----------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
         1 | test         | 5b7b2273697465223a20227369746531222c202263617465676f72696573223a205b2273697465312063617431222c202273697465312063617432222c202273697465312063617433225d7d2c207b2273697465223a20227369746532222c202263617465676f72696573223a205b2273697465322063617431222c202273697465322063617432225d7d5d

db<>fiddle here


text:
Q: How to use Karaf with Hazelcast Jet in Java module? It is little bit tricky to make understand but I will try.
I am creating application in which multiple sources data is coming from different module which is deployed in karaf but when I am trying to fetch it is not registering bundle properly, So whats happening if interface contains method which returns BatchStage then modules are not getting registered in same bundle but I keep simple method which returns List object then it is working fine.
For each source I am creating one module which returns BatchStage object
common module interface with BatchStage return and implementing it in different modules not working:
public interface DataService {
      BatchStage<Object> getData(Pipeline pipeline, Map<String, Object> data);
}

common module interface with List return and implementing it in different modules is working:
public interface DataService {
      List<Object> getData(Pipeline pipeline, Map<String, Object> data);
}

I am trying to fetch bundle as below:
BundleContext bundleContext = Activator.getBundleContext();
 Collection<ServiceReference<DataService>> references = bundleContext
                    .getServiceReferences(DataService.class, null);
            for (ServiceReference<DataService> reference : references) {
                DataService calcService = bundleContext.getService(reference);
                if (calcService.name().equalsIgnoreCase("jdbc")) {

                        result = calcService.getData(data, additonalDetails);

                    break;
                }
            }

I think there is some issue with BundleContext as Pipeline object in interface implements Serializable?


text:
Q: Does statistically simple algos qualify as AI algos? We have a customer purchase transaction history data with variables like below
recency - how recently they bought?
frequency - How often they bought?
monetary - How much value did they bring to the company?
and also few more variables like product id, purchase date etc.
We would like to do the below projects
a) Customer segmentation
b) Customer Lifetime value prediction
c) Customer Churn
So, for all the three above objectives, I thought I will use the below approaches
a) Jenks Natural breaks optimization
b) and c) Buy Till you die models
So, now my question is our superiors ask me to do AI projects but if I do projects using above algorithm, does it qualify as AI project?
Am confused. Because AI comes from statistics and these models also are backed by statistical proofs etc.
So, does the above approaches qualify as AI algos? would it be appropriate to call them as AI algos? Considering jenks breaks is simple to implement, can that be called an AI algorithm?

A: There's no universally accepted definition of artificial intelligence. Since this directive came from your superiors, it does not matter whether anyone here considers the projects you've proposed to be artificial intelligence projects; what matters is whether your superiors consider them to be artificial intelligence projects.
I would suggest presenting them a high-level overview of the projects you have in mind and their possible benefits to your company and let them decide whether they're the kinds of projects they want you spending your time on.


text:
Q: What are the different areas of Memory & Disk? I'm neither sure about if this is a right place to ask nor sure about how to put my query.
Let me put it this way:

*

*Main Memory starting at 0x00000 to    0xFFFFF.

*Diskspace starting at    0x00000000  to 0xFFFFFFFF.

But what we'll be able to access will not be from 0th byte till last byte right?
On hardisk I guess at the 0th byte we have MBR. & at someplace we have Filesystem (we are able to acess only this). What else?
Similarly with the Main memory. We have some Kernel Memory & User Memory(in which each processes live). What else?
My question is what are all the regions from 0th byte till the last byte? I don't know what to search for or where to find such information? If any one can post some links, that would be great.
EDIT:
I'm using x86 32Bit on Windows. Actually I was reading a book on Computer security where author mentions that a malware can either live on the disk or in the memory.(which is very true). But when we say computer is infected that doesn't mean only files (which are part of filesystem) is infected. There are other area's which are not mean't for user, like MBR. or Kernel Memory.
So, the question popped up in my mind. What are all such areas that I may not be aware about?

A: Apart from the fact that the answer to this question is highly dependent on the OS, disk space is not at all part of the main memory. On Intel architectures, disk access takes some I/O address space (which is different from memory address) per channel. And the exact number of words depends on what channel: IDE/ATA/SATA/SCSI. On other architectures which are memory mapped like the PowerPC disk access do take some memory address space, but still not much.
To illustrate (and be warned that this is a very simplified example, not the real world), assume a memory mapped CPU* like the PowerPC trying to access a disk with LBA addressing. The disk really only need 2 to 3 words of memory to hold multiple Gigabytes of data. That is, we only need 12 bytes to store and retrieve Gigabytes of data:

*

*2 words (8 bytes) to tell the disk where to seek to, that is, at what address do we want to read form or write to.

*1 word (4 bytes) to actually do the read and write. Every time you read from this address, the 2 word pointer automagically increment by 1 character (or 4 if you read in 32 bits).

But the above is an abstracted view of what really happens. Most disk controllers have several more registers to control power management, disk spin speed, enter and exit sleep modes etc.
And what are the addresses of these memory locations? Well, it depends on what I/O channel you're talking about. The old-school ISA bus depends on the user setting jumpers on cards to set the addresses. So for those you need to ask the user. The PCI bus auto-negotiates the addresses with the disk controllers at boot time and then, depending on architecture, either tells your bios what devices exist or pass them as parameters to the bootloader or store them in some temporary registers on the system bus. USB works like PCI but negotiates with the OS instead of the BIOS... etc.
As you can see, there is no simple answer to this even if you limit it to only specific cases like Windows7 running on 64 bit AMD CPU running on Dell motherboards.
*note: since you're worried about memory locations.

A: Your question is complex, and hard to answer without knowing the scope of where the view of memory is.
Pretending we're in ring-0 with direct mapped memory, a PC-compatible has multiple memory regions. Lower memory, BIOS mapped code, IO ports, video memory, etc. They all live in the same memory space. You communicate with peripherals by reading and writing from specific memory addresses (which are mapped to those components). These addresses are setup by the hardware in question and the drivers in use.
Once we enter user mode, you have to deal with virtual memory. Addresses are symbolic, and may or may not map to any particular part of physical memory. I'd suggest reading up on Virtual memory


text:
Q: Spring AOP and Post Construct I want to write the name of method which is using with @PostConstruct. But I found that AOP is unable to "Around" the PostConstruct method.
Is there any way to use AOP with PostConstruct method?

A: Give this a try.
    @Around("@annotation(javax.annotation.PostConstruct)")
    public void myAdvice(ProceedingJoinPoint jp) throws Throwable{
        System.out.println("This is before " + jp.getSignature().getName() + "()");
        jp.proceed();
    }

Additionally you need to activate compile-time weaving. I published a Demo project on github which uses maven. Clone https://github.com/jannikweichert/PostConstructAOPDemo and execute
mvn clean compile spring-boot:run

After that you should see in the Sysout:
This is before test()
test() is executed

Enjoy!

A: The @PostConstruct and @PreDestroy annotations are part of J2ee library  and not part of Spring AOP. So By default, Spring will not aware of the @PostConstruct and @PreDestroy annotation. To enable it, you have to either register 'CommonAnnotationBeanPostProcessor' or specify the
as
 ' in bean configuration file,
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />

<bean id="mybean" class="mypackage.MyBean">
    <property name="myPropertyName" value="my value" />
</bean>

Or as

<bean id="myBean" class="mypackage.myBEan">
    <property name="myProperty" value="test message value" />
</bean>

and annotate your method
@PostConstruct
public void myMethod() throws Exception {
  System.out.println("PostConstruct : " + myProperty);
}

A: Spring AOP is proxy based. Unless configured to do otherwise, Spring AOP performs run-time weaving and @PostConstruct executes at load time of an application.
To enable @PostConstruct to be executed by @Around advice at load time you have to set up Spring load-time weaving. Once setup use @annotation as a binding form for @Around advice, as follows:
@Around("@annotation(javax.annotation.PostConstruct)")
public void logAround(ProceedingJoinPoint joinPoint) throws Throwable {
    System.out.println("method name: " + joinPoint.getSignature().getName());
}


text:
Q: Cómo agregar texto desde un select a un textarea donde se encuentra el cursor Hola quiero agregar texto desde un select a un textarea en la parte donde quedo el cursor, pero solo logro que se inserte al comienzo del textarea y no donde esta el cursor

$(document).ready(function(){

  $('#txtAreaPreviewMensaje').focus(function(){
   var campo=$('#txtAreaPreviewMensaje').val();
   $('#longMensaje').text(campo.length);
  });
  $('#txtAreaPreviewMensaje').keydown(function(){
   var campo=$('#txtAreaPreviewMensaje').val();
   $('#longMensaje').text(campo.length);
  });
  $( '#txtAreaPreviewMensaje' ).keyup(function() {
     var campo=$('#txtAreaPreviewMensaje').val();
   $('#longMensaje').text(campo.length);
  });
  $('#selecccionar').change(function(){
   var value=$('#selecccionar').val();
   if(value===''||value===null){

   }else{
    var pos = $("#ultimaPosicion").val();
    var textoActual = $("#txtAreaPreviewMensaje").val();
    var textoInsertar = value;
    var position = pos;
    var output = [textoActual.slice(0, position), textoInsertar, textoActual.slice(position)].join('');
    $("#txtAreaPreviewMensaje").val(output);
    $("#txtAreaPreviewMensaje").focus();
   }
  });
  /*function posicion(pos){
   $('ultimaPosicion').val(pos);
  }*/
  $('#txtAreaPreviewMensaje').blur(function(){
   var end = $('#txtAreaPreviewMensaje').prop('selectionEnd');
   $('ultimaPosicion').val(end);
  });
  });

 <title></title>

 <select id="selecccionar">
  <option value="">selecionar dato...</option>
  <option value="Emmanuel">Emmanuel</option>
  <option value="Cristina">Cristina</option>
  <option value="Alicia">Alicia</option>
  <option value="Esjani">Esjani</option>
 </select>

 <textarea  id="txtAreaPreviewMensaje" name="mensaje" wrap=physical cols="28" rows="4" ></textarea>

 <input type="hidden" id="ultimaPosicion" value="0">

</htm>

A: Un ejemplo (sin necesidad de jQuery) de como insertar texto en la posición del cursor

var campo = document.getElementById('campo');
var boton = document.getElementById('boton');
var insertar = 'hola';

boton.addEventListener('click', e => {
  var inicio = campo.selectionStart;
  var fin = campo.selectionEnd;
  var texto = campo.value;
  campo.value = texto.slice(0, inicio) + insertar + texto.slice(fin);
  campo.selectionStart = campo.selectionEnd = inicio + insertar.length;
  campo.focus();
});
<textarea id="campo">0123456789</textarea>
<button id="boton">Insertar</button>

A: Buen día colega! Creo que ese código esta un poco desorganizado, pero atendiendo a tu consulta te dejo esta solución. Fíjate en la parte del output... Use template literals para resolver el asunto. Espero te resulte útil!

$(document).ready(function () {

    $('#txtAreaPreviewMensaje').focus(function () {
        var campo = $('#txtAreaPreviewMensaje').val();
        $('#longMensaje').text(campo.length);
    });
    $('#txtAreaPreviewMensaje').keydown(function () {
        var campo = $('#txtAreaPreviewMensaje').val();
        $('#longMensaje').text(campo.length);
    });
    $('#txtAreaPreviewMensaje').keyup(function () {
        var campo = $('#txtAreaPreviewMensaje').val();
        $('#longMensaje').text(campo.length);
    });
    $('#selecccionar').change(function () {
        var value = $('#selecccionar').val();
        if (value === '' || value === null) {
            return;
        } else {
            var pos = $("#ultimaPosicion").val();
            var textoActual = $("#txtAreaPreviewMensaje").val();
            var textoInsertar = value;
            var output = `${textoActual} ${textoInsertar}`;
            $("#txtAreaPreviewMensaje").val(output);
            $("#txtAreaPreviewMensaje").focus();
        }
    });
    /*function posicion(pos){
        $('ultimaPosicion').val(pos);
    }*/
    $('#txtAreaPreviewMensaje').blur(function () {
        var end = $('#txtAreaPreviewMensaje').prop('selectionEnd');
        $('ultimaPosicion').val(end);
    });
});

    <title></title>

    <select id="selecccionar">
    <option value="">selecionar dato...</option>
    <option value="Emmanuel">Emmanuel</option>
    <option value="Cristina">Cristina</option>
    <option value="Alicia">Alicia</option>
    <option value="Esjani">Esjani</option>
    </select>

    <textarea id="txtAreaPreviewMensaje" name="mensaje" wrap=physical cols="28" rows="4"></textarea>

    <input type="hidden" id="ultimaPosicion" value="0">


text:
Q: Inject the right set of Props into Modal based on clicked button ID I am facing a problem, which I am sure is simple to solve, however, I cannot figure out the solution to it.
The problem is the following:
I am writing a Vue.js application. I have a component with 3 buttons in it. Each button is meant to trigger a Modal component, and inject the right header and body into the Modal for the user to read. I can hard code a single header and body into the Modal no problem, however, I am having difficulties how to connect the right buttons with the right set of Props being injected into the Modal.
My code is the following:
Component with a set of buttons in it which are meant to trigger the Modal component:
<template>

        <button class="myButton" @click="showModal">Button1</button>

        <button class="myButton" @click="showModal">Button2</button>

        <button class="myButton" @click="showModal">Button3</button>
//Hard coding the title and bodyMessage triggers the Modal well -> Done for testing purposes -  needs to be eddited; so the Modal title and body change when different buttons are clicked
        <Modal  title='This is my Modal title' bodyMessage='This is my Modal body message' v-show="isModalVisible" @close="closeModal"/>

          <SimpleGallery galleryID="my-test-gallery" :images="images" />

</template>

My Modal component:
<template>
<transition name="modal-fade">

        <slot name="header">
          {{ title }}
        </slot>
        <button
          type="button"
          class="btn-close"
          @click="close"
        >
          x
        </button>

        <slot name="body">
          {{ bodyMessage }}
        </slot>

</transition>
</template>

Could anyone point me how to inject the right modalMessages to the Modal when the right button is clicked (e.g Button1 injects modalMessage with ID 1 etc)? I have tried a few solutions and none of them seem to work.
I would be very grateful for any help!
Thank you kindly!

A: You can set and pass index of modalMessages in showModal method, and bind props in modal component:

Vue.component('modal', {
  template: `
  <transition name="modal-fade">

          <slot name="header">{{ title }}</slot>
          <button type="button" class="btn-close"  @click="close">x</button>

          <slot name="body">{{ bodyMessage }}</slot>

  </transition>
  `,
  methods: {
    close() {
      this.$emit('close');
    },
  },
  props: ['title', 'bodyMessage']
})

new Vue({
  el: '#demo',
  data() {
    return {
      isModalVisible: false,
      selected: null,
      modalMessages: [{ id: 1, title: 'This is my First Modal title', bodyMessage: 'This is my first Modal message' }, { id: 2, title: 'This is my Second Modal title', bodyMessage: 'This is my second Modal message' }, { id: 3, title: 'This is my Third Modal title', bodyMessage: 'This is my third Modal message' },]
    };
  },
  methods: {
    showModal(id) {
      this.selected = this.modalMessages.find(m => m.id === id)
      this.isModalVisible = true;
    },
    closeModal() {
      this.isModalVisible = false;
    }
  },
})

          <button class="myButton" @click="showModal(msg.id)">Button {{ msg.id }}</button>

        <Modal :title='selected?.title' :body-message='selected?.bodyMessage' v-show="isModalVisible" @close="closeModal"/>


text:
Q: Awk: How do I output data from two files So yeah im trying to match file1 that contains email to file2 that cointains email colons address, how do i go on bout doing that?
tried  awk 'FNR==NR{a[$1]=$0; next}{print a[$1] $0}' but idk what im doing wrong
file1:
email@email.email
email@test.test
test@email.email

file2:
email@email.email:addressotest
email@test.club:clubbingson
test@email.email:addresso2

output:
test@email.email:addresso2
email@email.email:addressotest

A: Following awk may help you in same.
awk 'FNR==NR{a[$0];next} ($1 in a)' FILE_1 FS=":" FILE_2

A: join with presorting input files
$ join -t: <(sort file1) <(sort file2)

email@email.email:addressotest
test@email.email:addresso2

A: Hey why going for a awk solution when you can simply use the following join command:
join -t':' file 1 file2

where join as its names indicate is just a file joining command and you chose the field separator and usually the input columns and output to display (here not necessary)
Tested:
$more file{1,2}
::::::::::::::
file1
::::::::::::::
email@email.email
email@test.test
test@email.email
::::::::::::::
file2
::::::::::::::
email@email.email:addressotest
email@test.club:clubbingson
test@email.email:addresso2

$join -t':' file1 file2
email@email.email:addressotest
test@email.email:addresso2

If you need to sort the output as well, change the command into:
join -t':' file 1 file2 | sort -t":" -k1

or
join -t':' file 1 file2 | sort -t":" -k2

depending on which column you want to sort upon (eventually add the -r option to sort in reverse order.
join -t':' file 1 file2 | sort -t":" -k1 -r

or
join -t':' file 1 file2 | sort -t":" -k2 -r


text:
Q: handleCallback,MyViewHolder.onClick Am getting an unexpected error in Android studio while running the app and click on the target image the app is crash and the following error message which am getting.
    Process: com.salman.firebasecomicreaderapp, PID: 2874
    android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
        at android.app.ContextImpl.startActivity(ContextImpl.java:952)
        at android.app.ContextImpl.startActivity(ContextImpl.java:928)
        at com.salman.firebasecomicreaderapp.Adapter.MyComicAdapter$1.onClick(MyComicAdapter.java:53)
        at com.salman.firebasecomicreaderapp.Adapter.MyComicAdapter$MyViewHolder.onClick(MyComicAdapter.java:89)
        at android.view.View.performClick(View.java:7125)
        at android.view.View.performClickInternal(View.java:7102)
        at android.view.View.access$3500(View.java:801)
        at android.view.View$PerformClick.run(View.java:27336)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)```

A: Either you are not correctly caching the context object or you are running in Android 28(Android P)
try the following way

myViewHolder.setRecyclerItemClickListener(new IRecyclerItemClickListener() { @Override public void onClick(View view, int position) {
   Intent intent = new Intent(context,ChapteraActivity.class);
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   }
  context.startActivity(intent);
 }
});


text:
Q: how to use Python to detect a cycle in a dictionary For example:
{1: 5, 2: 6, 3: 5, 4: 5, 5: 6, 6: 7, 7: 1, 9: 6}

1:5>5:6>6:7>7:1, so there is a cycle in this dictionary

How to find out this cycle?
And give me the value appeared in the cycle, which is:
[1, 5, 6 7]

A: dic = {1: 5, 2: 6, 3: 5, 4: 5, 5: 6, 6: 7, 7: 1, 9: 6}

seen = []
k = 1
while k not in seen and k is not None:
    seen.append(k)
    k = dic.get(k)

result = seen[seen.index(k):] if k is not None else []


text:
Q: Domain classes relations query not working after upgrade grails from 1.3.7 to 2.2.2 I am upgrading my grails apps from grails version 1.3.7 to 2.2.2. I made most of codes working except this one. The same code working in grails 1.3.7 but stop working and get errors in grails 2.2.2. Please help.  Here are the classes cause the issue.
Domain class User, UserConfig, and Service class UserService.
public class User implements Serializable {
  String id
  ...
  static hasMany = [userConfigs:UserConfig]

  static mapping = {
    version false
    table 'c_user'
    id column: 'id'
  }

}
public class UserConfig implements Serializable
{
    UserProfile profile
    String genesysUserId

    static belongsTo = [user: User]

    static mapping = {
        version false
        table 'sp_user_config'
        id composite:['user', 'profile']
        user column: 'user_id'
        profile column: 'profile_id', lazy: false
    }
}

public class UserService {

    boolean transactional = true

    def getUserList(groupIdList) {

        def userList = User.list()

        userList.findAll() { user ->
            user.userConfigs?.find() { userConfig ->
                        groupIdList.contains(userConfig?.profile?.group?.id)

            }
        }
    }
}

I got Class; java.lang.IllegalArgumentException
Message: argument type mismatch
 in class UserService.groovy at line
user.userConfigs?.find() { userConfig->
and line userList.findAll() { user->
If I add 'List userConfigs'  to User domain class as
public class User implements Serializable {
  String id
  List<UserConfig> userConfigs
  ...
  static hasMany = [userConfigs:UserConfig]

  static mapping = {
    version false
    table 'c_user'
    id column: 'id'
  }

}

I got Class : java.sql.SQLException
Message: ORA-00904: "USERCONFIG0_"."USER_CONFIGS_IDX": invalid identifier from the same class UserService and same line of code.
Is this the new version of grails' issue or hibernate issue?

A: The first thing, and the easiest, is if you have the children as a list (List in this case) hibernate expects to see an index column in the table so it knows where in the list to put each child. The SQL exception there seems to point to that.
As for the first issue it doesn't seem to be a hibernate one, since you are just iterating over already loaded objects. You didn't include UserProfile so not sure if it has anything to do with that object.
My first step would be to throw in some logging into those closures and see what's happening. Or if you a debugger fan, use that.


text:
Q: Numbering depth in appendix when the appendix is a separate file from the main I saw the thread Numbering depth in appendix
but unfortunately, I don't know how to adjust the code to fit this into the case where my appendix is a separate tex file in my project, as is shown in the screenshots below.
The main tex file is Thesis.tex while app1.tex is the appendix file. The theorem in appendix is displayed as Theorem A.0.1. But I want Theorem A.0.1 to become Theorem A.1. I don't know how to make the commands
\usepackage{chngcntr}

\counterwithin{theorem}{section}

work in my case. Like, where should I add them? I have try many places but they are not working as expected. Or do you have any other solutions?
In Thesis.tex
\documentclass{book}

\usepackage{amsmath,amsthm,amssymb}
\newtheorem{theorem}{Theorem}[section]

\begin{document}

\appendix
\include{app1}

\end{document}

In app1.tex
\chapter{The Data on Cows}
\label{data.app}

\begin{theorem}

\end{theorem}

A: Adaptations

*

*corrected the code to a MWE

*use \counterwithin{theorem}{chapter} (chapter instead of section, as you use a book-like class)

Result

Code
\documentclass{book}

\usepackage{amsmath,amsthm,amssymb}
\newtheorem{theorem}{Theorem}[section]

\usepackage{chngcntr}

\begin{document}

\appendix
\counterwithin{theorem}{chapter}
\chapter{The Data on Cows}
\label{data.app}

\begin{theorem}
bla
\end{theorem}

\end{document}


text:
Q: Aframe, Can not get a reference to the cameras THREE.js object3D AFRAME.registerComponent('temp', {

      init: function () {

        var el = this.el;
        var camera = this.el.getObject3D('camera');

        console.log("CAMERA: "+camera);
      }

    });

I have an aframe scene with just a box and an a-camera object. I am trying to get a reference to the camera's object3D however, whenever I try, I am getting an undefined object. In addition to above, I have tried doing document.querySelector("#camera").object3D and that does not work either.

A: This is what you are trying to accomplish on one of the A-Frame examples (https://aframe.io/aframe/examples/boilerplate/hello-world/):
document.querySelector("[camera]").getObject3D('camera')


text:
Q: Get user name and email using Microsoft.Identity.Client I am using this package https://www.nuget.org/packages/Microsoft.Identity.Client
to authenticate a user, auth is working fine, problem is, I was thinking to use the token that I get after login to get the user name and email (as I need not only access to the inbox, contacts, and calendar; but also link the user to a rol using an email).
The problem is, when I get the token, I get a long string as userId (I guess encrypted). Is there any way I can use this package to get the email?
This is the section where I get the token back
public SessionTokenCache(string userId, HttpContextBase httpContext)
    {
        this.userId = userId;
        cacheId = userId + "_TokenCache";
        this.httpContext = httpContext;
        BeforeAccess = BeforeAccessNotification;
        AfterAccess = AfterAccessNotification;
        Load();
    }

This is the tutorial I followed
https://dev.outlook.com/restapi/tutorial/dotnet

A: Once you have a token, maybe you can use the Graph API to get details for the logged on user? The result is Json which can be used to extract the bits you want.
        public static async Task<string> GetUserData(string token)
    {
        //get data from API
        HttpClient client = new HttpClient();
        HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://graph.microsoft.com/v1.0/me");
        message.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", token);
        HttpResponseMessage response = await client.SendAsync(message);
        string responseString = await response.Content.ReadAsStringAsync();
        if (response.IsSuccessStatusCode)
            return responseString;
        else
            return null;
    }


text:
Q: How we can create Android Chrome web applications that are present on the Google Chrome web store Im new to Android and Google chrome web application development. I want to create an android application which has the ability to run Chrome web applications that are present on the Google Chrome web store. Can some body guide me , how I can start and where can i find the step by step helping documents. I googled it , but dint get any .
If any sample codes available to start, then that would be really helpful.
thanks and regards
Suje

A: There's two kinds of Chrome Web Store (CWS) apps: packaged and hosted. Packaged ones don't have a URL and can only run inside Chrome. Hosted apps are just regular web applications hosted at a URL and can in theory run from any browser, provided that it supports the features needed by the app.
There are a few ways to embed web apps into an Android application, the most popular of which is PhoneGap. Here's a nice getting started guide. http://www.phonegap.com/start/


text:
Q: 64 bit to Windows 7 upgrade
Possible Duplicate:
installing Win 7 from Vista

I have a AMD Athlon 64 X2 Dual core processor on my computer with Vista Home Premium, but I believe it using a 32 bit Vista version(how can I find out what bit my system is really using?). Can I upgrade to Win 7 64 bit Home, if my present OS is using a 32 bit Vista OS.

A: You cannot upgrade a 32-bit OS to a 64-bit version; you have to do a clean install. Don't worry, though, all your old files will be moved to a new directory called Windows.old, so you won't lose anything, you'll just have to reinstall your applications.
To find out which version you have, go to Control Panel -> System and Maintenance -> System, and it should say either 32-bit or 64-bit Operating System.


text:
Q: How to Register Widget with Post thumbnail and post title
I want to register a sidebar like this. I have register a widget with this code
register_sidebar(array(
            'name'=>esc_html__('Main Sidebar', 'software'),
            'id'=>'sidebar-1',
            'description'=>'This widget is for Right Sidebar',
            'before_widget'=>'',
            'after_widget'=>' ',
            'before_title'=>'

',
            'after_title'=>'

'
            ));

My html codes are

Recommended

Windows 7 mainstrem support ends

So How can I do this. DO I need to register a custom widget? or there are any other solution?
Thanks in Advance.

A: yes you can also make your custom but follow this plugin it will so
https://wordpress.org/plugins/recent-posts-widget-with-thumbnails/
https://wordpress.org/plugins/flexible-posts-widget/
so from both of this you get output that you want.
**WITH OUT PLUGIN **
STEP -1
In your functions.php file, write the following code:
<?php
class Realty_Widget extends WP_Widget{
function __construct() {
    parent::__construct(
        'realty_widget', // Base ID
        'Realty Widget', // Name
        array('description' => __( 'Displays your latest listings. Outputs the post thumbnail, title and date per listing'))
       );
}
function update($new_instance, $old_instance) {
        $instance = $old_instance;
        $instance['title'] = strip_tags($new_instance['title']);
        $instance['numberOfListings'] = strip_tags($new_instance['numberOfListings']);
        return $instance;
}

} //end class Realty_Widget
register_widget('Realty_Widget');

STEP -2 The form() method
very simple form with 2 fields: a text field for the Widget title, and a drop down list for the number of listings we want to show:
<?php function form($instance) {
    if( $instance) {
        $title = esc_attr($instance['title']);
        $numberOfListings = esc_attr($instance['numberOfListings']);
    } else {
        $title = '';
        $numberOfListings = '';
    }
    ?>

        <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'realty_widget'); ?>
        <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />

        <label for="<?php echo $this->get_field_id('numberOfListings'); ?>"><?php _e('Number of Listings:', 'realty_widget'); ?>
        <select id="<?php echo $this->get_field_id('numberOfListings'); ?>"  name="<?php echo $this->get_field_name('numberOfListings'); ?>">
            <?php for($x=1;$x<=10;$x++): ?>
            <option <?php echo $x == $numberOfListings ? 'selected="selected"' : '';?> value="<?php echo $x;?>"><?php echo $x; ?></option>
            <?php endfor;?>
        </select>

    <?php
    }

STEP - 3 The widget() method
<?php
function widget($args, $instance) {
    extract( $args );
    $title = apply_filters('widget_title', $instance['title']);
    $numberOfListings = $instance['numberOfListings'];
    echo $before_widget;
    if ( $title ) {
        echo $before_title . $title . $after_title;
    }
    $this->getRealtyListings($numberOfListings);
    echo $after_widget;
}

STEP -4 Pull our Custom Posts
This method will do a query of our custom posts. It will only return the number of posts that we've saved in our widget. Add this code to our class:
<?php
function getRealtyListings($numberOfListings) { //html
    global $post;
    add_image_size( 'realty_widget_size', 85, 45, false );
    $listings = new WP_Query();
    $listings->query('post_type=listings&posts_per_page=' . $numberOfListings );
    if($listings->found_posts > 0) {
        echo '
';
            while ($listings->have_posts()) {
                $listings->the_post();
                $image = (has_post_thumbnail($post->ID)) ? get_the_post_thumbnail($post->ID, 'realty_widget_size') : '

';
                $listItem = '
' . $image;
                $listItem .= '';
                $listItem .= get_the_title() . '';
                $listItem .= 'Added ' . get_the_date() . '
';
                echo $listItem;
            }
        echo '
';
        wp_reset_postdata();
    }else{
        echo '
No listing found
';
    }
}

note here in above 4th step my post type is listing so i used it
you can set your own post type.
ex- you need to use like this
$listings->query('post_type=post&posts_per_page=' . $numberOfListings );

AND IN END once you get image and text then set your own css as per your design.


text:
Q: Matlab remove noise I want to remove noise from an image. The image i've been given is a .mat file but it's very complicated because when i load the mat file no image can be seen, then i use imwrite to make it jpg
imwrite(destroyedImg, 'fr.jpg');
But when i use imshow I get only colorful dots in white background!
Is there a way to find out how to clear the noise from this picture?!
I'm not allowed to use the internal functions but to build one myself! But i cannot figure out the kind of noise and then remove it! i also have to return the "clear image" in RGB format and not grayscale!
here is some of my code
clear all; close all;
load('image_destroyed.mat');
imwrite(image_destroyed, 'fraou.jpg');
img = imread('fraou.jpg');
subplot(2,2,1), imshow(img)
title('Fraou');
H = fspecial('average',[3 3]);
average = imfilter(img, H, 'replicate');
subplot(2,2,2), imshow(average);
title('average');H = fspecial('gaussian',[5 5]);
average = imfilter(img, H, 'replicate');
subplot(2,2,3); imshow(average);title('gaussian');
H = wiener2(img,[5 5]);
subplot(2,2,4); imshow(H)
title('wiener 5x5');

A: DO NOT USE imwrite to 'jpg' to get your image - this only introduces artifacts.
Your input image is of type double with values exceeding the range [0..1] and thus all the confusion.
load('image_destroyed.mat');
image_destroyed = image_destroyed / 255.0; % back to [0..1] range
imshow( image_destroyed ); % should be meaningful now.

A: The following code, presuming that image_destroyed is a variable contained in image_destroyed.mat, is probably what is causing the issue:
load('image_destroyed.mat');
imwrite(image_destroyed, 'fraou.jpg');
img = imread('fraou.jpg');

At best this is equivalent to img = image_destroyed;, and therefore is unnecessary.  It is possible (and given your strange results, quite likely) that this write/read process is actually introducing further degradation into your image, through inappropriate scaling or clipping, compression, etc.
For MATLAB image processing functions, when using doubles, you should make sure your data is scaled between 0 and 1.


text:
Q: Is there a workaround to log4j rolling issue? I'm using a daily rolling policy with log4j2 with a TimeBasedTriggeringPolicy.
The log must roll each day at midnight.
I'm using the example except that I have a timezone Europe/Paris.
https://howtodoinjava.com/log4j2/log4j2-rollingfileappender-example/

To enable the daily rolling, log4j2 does not include the
DailyRollingFileAppender which was present in earlier log4j. To
rollover logs on daily basis, set interval to 1 in
TimeBasedTriggeringPolicy.

<RollingFile
  name="rollingFile"
  fileName="${LOG_DIR}/application.log"
     filePattern="${LOG_DIR}/application.%d{dd-MMM}{Europe/Paris}.log.gz"
  ignoreExceptions="false">
  <PatternLayout>
      <Pattern>%d{yyyy-MM-dd HH:mm:ss}{Europe/Paris} %-5p %m%n</Pattern>
  </PatternLayout>
  <Policies>
      <TimeBasedTriggeringPolicy interval="1"/>
  </Policies>
  <DefaultRolloverStrategy max="5" />
</RollingFile>

I'm facing the issue that instead of rolling at midnight Paris Time, it rolls at GMT which is 22:00 on the previous day.
I found that issue that could be related :
https://issues.apache.org/jira/browse/LOG4J2-1631
On that issue, the reporter seems to report the exact same issue except that he was using a different timezone.

A: I think implementing your own TimeBasedTriggeringPolicy to correctly roll over files based taking timezone into account should not be that hard to achieve.
See this example for additional information


text:
Q: Unknown class in interface builder file, when copying storyboard I imported my storyboard from another app I worked on, however now on every view the module is set to none, and when I run the project I get the following error:
Unknown class _TtC9Gym_Amigo26SplashScreenViewController in Interface Builder file.

and
Could not load the "GRADIENT LONG RECTANGLE.png" image referenced from a nib in the bundle with identifier "com.wal******.***-*****"

A: All you have to do is pretend that you just created this storyboard, and configure it as you would if you had just created it. Thus:

*

*For the first error, locate e.g. the splash screen view controller in the storyboard and re-enter its class in its Identity inspector (Amigo26SplashScreenViewController). When you press Return, the module will be entered and the class will become known to the storyboard.

*For the second error, add the "GRADIENT LONG RECTANGLE.png" image to your project. In the storyboard, set it as the image of this image view (or whatever it is).

A: You coppy only the storyboard file in your project so when you build the project xcode couldn't find the image "GRADIENT LONG RECTANGLE.png" in one of your uiimageView. So set this image to concern image view. So your one error will be gone.
Now for the second error there is an unknown class in your splash screen interface builder.
So just find out that class and look for its declaration in your project. If it is not declared, declare it or delete the splash screen and add your own from the scratch.


text:
Q: Access object of tab bar controller item I have 4 tab bar item. Each of them will have its own navigationController within it. I am trying to set a property of tab(1) rootViewController from tab(2). How do I get the instance of tab1(rootVC) class back?

A: i think use this line.....
[[tabBarController setSelectedIndex:0];

A: I think it will help you
[[self.tabBarController setSelectedIndex:0];


text:
Q: Proofs-request: Proofs that five exponention rules hold for positive real bases and rational exponents,using pre-calculus math Proofs must assume that $0^0$ is undefined.
Alas, I was able to find proofs only for integer exponents and real bases (by the way, considering that this is already proven, it can enough to prove the rules only for positive bases and fractional exponents, including exponents that are improper fractions). I specifically restricted bases to positive reals in order to avoid complex numbers and implicit divisions by zero.
I want to prove following rules:
1.$x^{a}x^{b}=x^{a+b}\space$
2.$\frac{x^{a}}{x^{b}}=x^{a-b}\space$
3.$(x^{a})^b=x^{ab}\space$
4.$(xy)^a=x^ay^a \space$
5.$(\frac{x}{y})^{a}=\frac{x^{a}}{y^{a}}\space$

A: For positive integer exponents and positive real bases $x$, rule (1) is just the observation that multiplying $1$ by $x$ $n$ times and then $m$ more times is the same as multiplying $1$ by $x$ $(m+n)$ times.
For positive integer exponents the other four rules follow from rule (1).
For example, (1) implies (2) because
$$
x^{a-b}x^b = x^{a-b+b} = x^a.
$$
Then the definition of $x^a$ for other rational numbers is determined by the requirement that (1) stay true.
That requirement forces
$$
x^0 = 1
$$
because
$$
x = x^1 = x^{1+0} = x^1x^0 = xx^0
$$
and you can cancel the nonzero $x$,
$$
 x^{-a} = 1/x^a
$$
because
$$
1 = x^0 = x^{-a+a} = x^{-a}x^a
$$
and
$$ x^{1/a} = \sqrt[a]{x}
$$
because
$$
 (x^{1/a})^a = x^{a \times (1/a)} = x^1 = x.
$$
Then the rest of the rules follow from rule (1) as before for all rational exponents. The arguments there depend only on the associative, commutative and distributive laws that are as true for rationals as they are for integers.


text:
Q: How disable maintenance mode from files in magento2? I don't have ssh access to one of my website. I have only FTP details . so how i can disable Mode using FTP.

A: You can disable magento maintenance mode by rename or delete of maintenance.flag file from var folder.


text:
Q: Mass product category update (adding `home` category to all products) - Prestashop 1.6.0.6 I observed that the count of all products is not equal to the number of products in category home. It is due to the fact that this biggest parent category was not always selected during product adding. So some products belong to home but others not.
While I need to display the correct number of products for the category home page, I was looking in the database for the columns that holds the categories but not found them in ps_product or  ps_product_lang.
what is the idea behind an sql query that can mass modify the appropriate fields in database so that all my products belong to category home.
Your usual help is appreciated. Thank you.
Edit:
I found that the table in database is ps_category_product. Is it the only one?
this table is like this:
+-------------+------------+----------+
| id_category | id_product | position |
+-------------+------------+----------+
|          11 |          1 |        1 |
|          11 |          2 |        2 |
|          11 |         10 |        3 |
+-------------+------------+----------+

I need maybe to create x lines (x= the number of products) . each line has id_category=1 and id_product= product id and position= position++. Is is the best approach?
Any help regarding how to implement it in sql?
Thanks again.

A: You can assign every product to the Home category with a simple SQL query:
INSERT IGNORE INTO ps_category_product SELECT 2, id_product, 0 FROM ps_product

2 is normally the id_category value of the Home category, 0 is the position.
If you want unique position values then you need a more complex query:
INSERT IGNORE INTO ps_category_product SELECT 2, id_product, ((SELECT MAX(position) FROM ps_category_product WHERE id_category = 2) + (@inc := @inc + 1)) FROM ps_product INNER JOIN (SELECT @inc := 0) AS i


text:
Q: Differentiability of Matrix function satisfying exponential functional equation Let $\{U(t)\;|\;t \in \mathbb{R}\}$ be a subgroup of $\text{GL}_n(\mathbb{R})$ such that $t \mapsto U(t)$ is continuous and satisfies $U(0) = E_n$ and $$U(t+s) = U(s)U(t)$$

Is it true then that $t \mapsto U(t)$ is differentiable at $0$ (and
  hence for all $t \in\mathbb{R}$)?

If yes, I would appreciate a hint on how to prove this since it is clear by definition that $$U(h) - U(0) = o(1) \text{ for } h \to 0$$ but not $$U(h) - U(0) = o(||h||)\text{ for } h \to 0$$

A: Yes. Since $I$ is non-singular, we may define in its small neighbourhood a matrix logarithm. It follows that $f(t) = \log U(t)$ is well defined in some neighbourhood of zero because $U$ is continuous and $U(0)=I$.
By definition, the subgroup $\{U(t): t\in\mathbb R\}$ is Abelian. Hence $\log\left(U(s)U(t)\right)=\log U(s)+\log U(t)$. Consequently, if we denote by $f_{ij}$ the $(i,j)$-th component of $f$, then we can reduce the original functional equation to
$$
f(s+t)=f(s)+f(t)
$$
or $f_{ij}(s+t)=f_{ij}(s)+f_{ij}(t)$ for each $(i,j)$. This is basically Cauchy's functional equation, with the exception that the domain of $f_{ij}$ is a neighbourhood of zero instead of the whole real line. However, the same solution method applies: using the additive property, one can show that there exists a real number $c_{ij}$ such that $f_{ij}(q) = c_{ij}q$ for every rational number $q$ inside the domain of $f_{ij}$. Then, using the continuity of $f_{ij}$ and the denseness of rational numbers in $\mathbb R$, we conclude that $f_{ij}(t)=c_{ij}t$.
Hence $f(t)=tC$ for some constant matrix $C$. That is, $U(t)=e^{tC}$ on some neighbourhood of zero. Thus $U$ is differentiable at zero.

A: Let $s(x) =\sum_k \frac{(-1)^k}{k} x^k $ then it is easy to see that $s\circ U $ is differentiable and thus so is $U.$


text:
Q: Beamer metropolis theme: How can I add a paragraph below the horizontal bar in section page? Below is the code from the metropolis theme that is responsible for formatting each section page appearing in the presentation:
\setbeamertemplate{section page}{
    \begin{center} % add center if missing
    \begin{minipage}{30em}
    \usebeamercolor[fg]{section title}
    \usebeamerfont{section title}
    %\raggedright % comment out raggedright
    \centering % add centering here to center title
    \insertsectionhead\\[-1ex]
    \usebeamertemplate*{progress bar in section page}
    \par
    \ifx\insertsubsectionhead\@empty\else%
    \usebeamercolor[fg]{subsection title}%
    \usebeamerfont{subsection title}%
    \insertsubsectionhead
    \fi
    \end{minipage}
    \end{center}
    \par
    \vspace{\baselineskip}
}

The output so far is the section title followed by a horizontal progression bar. What I am trying to achieve is adding text in smaller font below the horizontal progression bar. Any ideas how to do it?
Example of how I want it to look like:


text:
Q: Select value based on current date being more than 1, 2 and 3 years from a date Good day,
I hope someone can assist me with a small line of code. I have build a sales rep commissions report, and for each item that a sales rep earns comm off, there is a date that the rep first got the item as new business, say for example, item A started 01/01/2018.
Their commission break down means that they get 7% for the first year after the start date (01/01/2018 < 1 year of current date), 5% if (01/01/2018 > 1 year of current date < 2 years of current date), 2.5% if (01/01/2018 > 2 years of current date < 3 years of current date).
I have written the select statement for the whole report, but I am battling to find any info on this.
I assume I would need a CASE statement, but I do I tell SQL to check if the current date is less than one year, or more than one year, but less thank 2 years, etc.
Really appreciate the assistance!

A: I suppose you can use CASE like this:
SELECT
    CASE
        WHEN CURRENT_TIMESTAMP >= DATEADD(YEAR, 2, startdate) THEN 2.5
        WHEN CURRENT_TIMESTAMP >= DATEADD(YEAR, 1, startdate) THEN 5.0
        ELSE 7.0
    END AS commission

Note that the cases are sorted.


text:
Q: Use Metadata API to search based on location of artist? I've been told that according to Spotify, you can build a playlist based on geolocation. I'm not finding anything in the documentation or the response data to figure out how to do this. Am I missing something?
Thanks,
Chris

A: Who told you that? Spotify has no Geo features - without using an external API that'll give you a location of an artist, you can't do what you're asking with the Spotify APIs.


text:
Q: TypeError: undefined is not an object (evaluating 'this') I do not get an error when I delete the component menu I created specially from where I put it, but I get an error when my component is there. Thank you for your comments already.

import Menu from './Navigator'
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { faBars } from '@fortawesome/free-solid-svg-icons';

export default class HeaderLeft extends Component {
    constructor(props){
        super(props);
        this.state={check:false}
    }
    render() {
        return (<SafeAreaView><View onStartShouldSetResponderCapture={() => { this.setState({ check: !this.state.check }) }} style={styles.align}>
            <FontAwesomeIcon icon={faBars} size={16} color={"#2D6A4F"} /><Menu check={this.state.check}></Menu></View></SafeAreaView>)
    }

}
const styles = StyleSheet.create({

    align: {
        height: 60, display: 'flex', justifyContent: 'center', padding: 20
    },

});```

A: Have a try by making the changes as the below code in your code.:
add below in the constructor:
this.handleResponderCapture = this.handleResponderCapture.bind(this)

Add below method:
handleResponderCapture = () => {
    this.setState({
        check: !this.state.check
    })
}

Make changes as below in View
<View
    onStartShouldSetResponderCapture={this.handleResponderCapture}
    style={styles.align}
>


text:
Q: Run an application as another user in Mac I have tried various methods mentioned across many sites, but cant able to run perfectly on newer versions of mac os.
I have tried:
sudo -i -u otheruser -H
OR
sudo login -f otheruser

And try running the app in the new prompt using /Applications/Sketch.app/Contents/MacOS/Sketch
Also I have tried:
su otheruser -c "/Applications/Sketch.app/Contents/MacOS/Sketch"

All of these run the app. But as soon as I open something which require system events (such as requesting macos native file picker) the application crashes. The following error is visible when such events are started.
+[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'com.apple.view-bridge': Connection interrupted

I have tried with many applications. Exactly same error occurs. Please help.

A: You can't run UI applications as user A while being logged in as user B. The easiest way to get something similar is to enable Fast User Switching and then switch between user A and user B as needed. But each user will have its own Finder etc then, you can't use applications on the same screen at once.


text:
Q: strong parameters with multi-model form I have the following form:
<%= form_tag classification_code_rules_path do %>
  <% @classification_code_rules.each do |rule| %>
    <%= fields_for "classification_code_rule[]", rule do |pf| %>
      <%= pf.text_field :name %>
     <% end %>
  <% end %>
  <%= submit_tag %>
<% end %>

It sends what I want to the server:
Parameters: { ... "classification_code_rule"=>[{"name"=>"dasdsaf"}, {"name"=>"sfsdgdfhgf"}, {"name"=>"hfghfgjhgjhg"}], "commit"=>"Save changes"}

Since classification_code_rule is an array, I handle the params as follows:
  def classification_code_rule_params
    params[:classification_code_rule].each do |rule_param|
      rule_param.permit!
    end
  end

But I am getting the following error:
When assigning attributes, you must pass a hash as an argument.

How can I handle this situation where the strong param is an array?

A: Try something like this
params.require(:classification_code_rule).map do |rule_param|
  ActionController::Parameters.new(rule_param.to_hash).permit!
end


text:
Q: how to kill Fragment after load it using navigation component here's my sample code that i need to kill the fragment after load it in the navHost activity (Main Activity) and i'm using navigation component BTW the Fragment is a splash screen Fragment so how to kill it to not shows after loading with back button press.
class SplashFragment : Fragment() {

private var _binding: FragmentSplashBinding? = null
private val binding get() = _binding!!

private lateinit var loadingAnim : AnimationDrawable

override fun onCreateView(
    inflater: LayoutInflater, container: ViewGroup?,
    savedInstanceState: Bundle?
): View {
    _binding = FragmentSplashBinding.inflate(inflater, container, false)

    lunchLogoAnimation()
    lunchLoadingAnimation()

    Handler(Looper.getMainLooper()).postDelayed({
        findNavController().navigate(R.id.action_splashFragment_to_homeFragment)

    },6000)

    return binding.root
}

private fun lunchLogoAnimation(){

    val loadAnimation = AnimationUtils.loadAnimation(activity,R.anim.splash_screen_logo_translate)
    Handler(Looper.getMainLooper()).postDelayed({
        binding.monkeyLogoSplash.visibility = View.VISIBLE
        binding.monkeyLogoSplash.startAnimation(loadAnimation)
    },500)

}

private fun lunchLoadingAnimation(){

    loadingAnim = binding.loadingDots.drawable as AnimationDrawable

    Handler(Looper.getMainLooper()).postDelayed({
        binding.loadingDots.animate().setDuration(500).alpha(1f).withEndAction {
            loadingAnim.start()
        }
    },1500)

}

override fun onDestroyView() {
    super.onDestroyView()
    _binding = null
}

A: Fragment can be removed easily,
inside the main activity-> kotlin,
supportFragmentManager.beginTransaction().remove(myFragment).commit()

or inside the particular fragment,
parentFragmentManager.beginTransaction().remove(this).commit()

java
getSupportFragmentManager().beginTransaction().remove(myFragment).commit();

getParentFragmentManager.beginTransaction().remove(this).commit();


text:
Q: ViewModel Not returning data to Post method I am using ASP.Net Core 5.0
I have a viewmodel -
using YellowFeverPortal.Web.Models;
using System.Collections.Generic;
using System.Linq;

namespace YellowFeverPortal.Web.ViewModels
{
    public class RegistrationListViewModel
    {
        public List<Registration> allRegistrations { get; set; }

        public Registration theRegistration { get; set; }

        public Registration theFirstRegistration { get; set; }

        public int clinicId { get; set; }

        public string clinicShortCode { get; set; }
    }
}

I have a razor view that uses the viewmodel -
@model RegistrationListViewModel
@{
    ViewData["Title"] = "Registration";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<form method="post" asp-controller="registration" asp-action="registration">

            @Model.vaccinationClinicShortCode - Current Registration
            <button type="button" class="btn-sm btn-primary float-right" onClick="history.go(-1); return false;" title="Click to confirm designation renewals">Back</button>

        <input id="vaccClinicId" asp-for="vaccinationClinicId" class="form-control" style="display:none" />
        <input id="vaccClinicShortCodeId" asp-for="vaccinationClinicShortCode" class="form-control" style="display:none" />
        <input id="regId" asp-for="theRegistration.Id" class="form-control" style="display:none" />
        <input id="regsId" asp-for="allRegistrations" class="form-control" style="display:none" />

        <fieldset class="form-group">

                    Code of Practice Received

                    <input id="codeOfPracRecvdId" type="checkbox" asp-for="theRegistration.CodeOfPracticeReceived" />

                    Certificate Sent

                    <input id="certSentId" type="checkbox" asp-for="theRegistration.CertificateSent" />

                    Designation Date

                    <input id="registeredAtId" type="date" asp-for="theRegistration.RegisteredAt" />

                    Certificate Sent Date

                    <input id="certSentDateId" type="date" asp-for="theRegistration.CertificateSentAt" />

                    Invoice Number

                    <input id="invoiceNumberId" asp-for="theRegistration.InvoiceNumber" />

                    Sanofi Informed

                    <input id="sanofiInformedId" type="checkbox" asp-for="theRegistration.SanofiInformed" />

                    Invoice Date

                    <input id="invoiceSentAtId" type="date" asp-for="theRegistration.InvoiceSentAt" />

                    Number of Years to Renewal

                    <select id="numOfYearsId" asp-for="theRegistration.NumberOfYearsId" asp-items="@(new SelectList(ViewBag.NumberOfYearsList, "Id", "TheNumberOfYears"))" style="height: 37px;">
                        <option value='0' className='display-none'>Please Select...</option>
                    </select>

                    <input type="submit" value="Submit" name="Submit" class="btn btn-success float-right" id="SubmitForm" />

        </fieldset>

                First Registration

        <fieldset class="form-group">

                        Designation Form Received
                        Code Of Practice Received
                        Designation Date
                        Certificate Sent
                        Certificate Sent Date
                        Invoice Number

                        @Model.theFirstRegistration.RegistrationFormReceived
                        @Model.theFirstRegistration.CodeOfPracticeReceived
                        @(Model.theFirstRegistration.RegisteredAt.HasValue ? Model.theFirstRegistration.RegisteredAt.Value.ToString("dd/MM/yyyy") : "")
                        @Model.theFirstRegistration.CertificateSent
                        @(Model.theFirstRegistration.CertificateSentAt.HasValue ? Model.theFirstRegistration.CertificateSentAt.Value.ToString("dd/MM/yyyy") : "")
                        @Model.theFirstRegistration.InvoiceNumber

        </fieldset>

                Subsequent Registrations

</form>

And I have a post method in my controller -
 [HttpPost]
 [ValidateAntiForgeryToken]
 public IActionResult Registration(RegistrationListViewModel registrationListViewModel)
 {
    if (!ModelState.IsValid)
    {
       return View("Registration", registrationListViewModel);
    }

    if (registrationListViewModel.allRegistrations is null || registrationListViewModel.allRegistrations.Count() == 0)
    {
       _registrationRepository.CreateRegistration(registrationListViewModel.theRegistration);
    }
    else
    {
       _registrationRepository.UpdateRegistration(registrationListViewModel.theRegistration);
    }

    return View(registrationListViewModel);
 }

When I press the submit button the number of allRegistrations is 0.  There should be 1.  That is the number of allRegistrations that is passed to the view.
I even have a input tag that I set to allRegistrations, but that makes no difference, it still returns 0 allRegistrations.
Any ideas why?
Thanks

A: For targets that are collections of simple types, model binding looks for matches to parameter_name or property_name. If no match is found, it looks for one of the supported formats without the prefix.

*

*In other words, you need the input name in your form to be similar to "allRegistrations[0].RegistrationFormReceived".

*In this way, the data can be successfully bound to allRegistrations after the form is submitted.

Code:
<input hidden asp-for="@Model.allRegistrations[0].RegistrationFormReceived">
<input hidden asp-for="@Model.allRegistrations[0].CodeOfPracticeReceived">
<input hidden asp-for="@Model.allRegistrations[0].RegisteredAt">
<input hidden asp-for="@Model.allRegistrations[0].CertificateSent">
<input hidden asp-for="@Model.allRegistrations[0].CertificateSentAt">
<input hidden asp-for="@Model.allRegistrations[0].InvoiceNumber">

Output html string:
<input hidden="" type="text" id="allRegistrations_0__RegistrationFormReceived" name="allRegistrations[0].RegistrationFormReceived" value="RegistrationFormReceived">
<input hidden="" type="text" id="allRegistrations_0__CodeOfPracticeReceived" name="allRegistrations[0].CodeOfPracticeReceived" value="CodeOfPracticeReceived">
<input hidden="" type="datetime-local" id="allRegistrations_0__RegisteredAt" name="allRegistrations[0].RegisteredAt" value="2021-06-23T13:58:22.875">
<input hidden="" type="text" id="allRegistrations_0__CertificateSent" name="allRegistrations[0].CertificateSent" value="CertificateSent">
<input hidden="" type="datetime-local" id="allRegistrations_0__CertificateSentAt" name="allRegistrations[0].CertificateSentAt" value="2021-06-23T13:58:22.876">
<input hidden="" type="text" id="allRegistrations_0__InvoiceNumber" name="allRegistrations[0].InvoiceNumber" value="InvoiceNumber">


text:
Q: using for loop to enter data to mysql i have a dynamically generated form. the form generates itself when addmore button is clicked.
this is my html form markup
  <form name="addcourses" action="" method="post">
<fieldset><legend>Add Courses</legend>

    <select name="txtcategory0" id="id_str">
    <option value="" selected="selected"></option>
<option value="Management">Management</option>
<option value="Medical">Medical</option>
<option value="Dental">Dental</option>
<option value="Nursing">Nursing</option>
<option value="Ayurvedic">Ayurvedic</option>
<option value="Homeopathy">Homeopathy</option>
<option value="Unani">Unani</option>
<option value="Physiotherapy">Physiotherapy</option>
<option value="Pharmacology">Pharmacology</option>
<option value="Naturopathy & Yoga">Naturopathy & Yoga</option>
<option value="Engineering">Engineering</option>
<option value="Information Technology">Information Technology</option>
<option value="Computer / IT Training Institutes">Computer / IT Training Institutes</option>
<option value="Animation">Animation</option>
<option value="Polytechnic">Polytechnic</option>
<option value="Maritime">Maritime</option>
<option value="ITI">ITI</option>
<option value="Biotechnology">Biotechnology</option>
<option value="Law">Law</option>
<option value="Fashion Technology">Fashion Technology</option>
<option value="Hotel Management">Hotel Management</option>
<option value="Mass Media">Mass Media</option>
<option value="Distance Learning">Distance Learning</option>
<option value="Library Science">Library Science</option>
<option value="Degree Colleges">Degree Colleges</option>
<option value="B.Ed">B.Ed</option>
<option value="Fine Arts">Fine Arts</option>
<option value="Film Institutes">Film Institutes</option>
<option value="Tutorials">Tutorials</option>
<option value="Entrance Coaching">Entrance Coaching</option>
<option value="Vocational Courses">Vocational Courses</option>
<option value="Beautician Courses">Beautician Courses</option>
<option value="Language Courses">Language Courses</option>
<option value="Certificate Courses">Certificate Courses</option>
<option value="Schools">Schools</option>
<option value="International Schools">International Schools</option>
<option value="Private Schools">Private Schools</option>
<option value="Nursery / Play Homes">Nursery / Play Homes</option>
<option value="Flying Institutes">Flying Institutes</option>
<option value="Call Center Training">Call Center Training</option>
<option value="Sports Academy">Sports Academy</option>
<option value="10 + 2">10 + 2</option>
</select>
    <input type="text" name="txtcourse_name0" id="id_cname" value="" />
    <input type="text" name="txtseat0" id="id_seats" value="" style="width:40px;" />
    <select name="txtfees0" id="id_elig" >
<option value="" selected="selected"></option>
<option value="1 - 5000">1 - 5000</option>
<option value="5001 - 10000">5001 - 10000</option>
<option value="10001 - 20000">10001 - 20000</option>
<option value="20001 - 30000">20001 - 30000</option>
<option value=">30001 - 40000">30001 - 40000</option>
<option value="40001 - 50000">40001 - 50000</option>
<option value="50001 - 60000">50001 - 60000</option>
<option value="60001 - 70000">60001 - 70000</option>
<option value="70001 - 80000">70001 - 80000</option>
<option value="80001 - 90000">80001 - 90000</option>
<option value="90001 - 1 Lac">90001 - 1 Lac</option>
<option value="1 Lac - 1.5 Lac">1 Lac - 1.5 Lac</option>
<option value="1.5 Lac - 2 Lac">1.5 Lac - 2 Lac</option>
<option value="2.5 Lac - 3 Lac">2.5 Lac - 3 Lac</option>
<option value="3.5 Lac - 4 Lac">3.5 Lac - 4 Lac</option>
<option value="4.5 Lac - 5 Lac">4.5 Lac - 5 Lac</option>
<option value="5.5 Lac - 6 Lac">5.5 Lac - 6 Lac</option>
<option value="6.5 Lac - 7 Lac">6.5 Lac - 7 Lac</option>
<option value="7.5 Lac - 8 Lac">7.5 Lac - 8 Lac</option>
<option value="8.5 Lac - 9 Lac">8.5 Lac - 9 Lac</option>
<option value="9.5 Lac - 10 Lac">9.5 Lac - 10 Lac</option>
<option value="10.5 Lac - 11 Lac">10.5 Lac - 11 Lac</option>
<option value="11.5 Lac - 12 Lac">11.5 Lac - 12 Lac</option>
<option value="12.5 Lac - 13 Lac">12.5 Lac - 13 Lac</option>
<option value="13.5 Lac - 14 Lac">13.5 Lac - 14 Lac</option>
<option value="14.5 Lac - 15 Lac">14.5 Lac - 15 Lac</option>
<option value="15 Lac & Above">15 Lac & Above</option>
</select>

 <input type="button" onclick="addRow();"  value="Add More"/>
<input type="button" value="Remove" onclick="removeRow();" />
<input type="hidden" name="len" value="1" />

<input name="submit" type="submit" value="submit" />
</fieldset>
</form>

i use this java script to add form fields


text:
Q: Docker not running certain RUN directives? I am trying to run a docker container to automatically set up a sphinx documentation site, but for some reason I get the following error when I try to build
Step 9/11 : RUN make html
 ---> Running in abd76075d0a0
make: *** No rule to make target 'html'.  Stop.

When I run the container and console in, I see that sphinx-quickstart does not seem to have been run since there are no files present at all in /sphinx. Not sure what I have done wrong. Dockerfile is below.
  1 # Run this with
  2 # docker build .
  3 # docker run -dit -p 8000:8000 <image_id>
  4 FROM ubuntu:latest
  5
  6 WORKDIR /sphinx
  7 VOLUME /sphinx
  8
  9 RUN apt-get update -y
 10 RUN apt-get install python3 python3-pip vim git -y
 11
 12 RUN pip3 install -U pip
 13 RUN pip3 install sphinx
 14
 15 RUN sphinx-quickstart . --quiet --project devops --author 'Timothy Pulliam' -v '0.1' --language 'en' --makefile
 16 RUN make html
 17
 18 EXPOSE 8000/tcp
 19
 20
 21 CMD ["python3", "-m", "http.server"]

EDIT:
Using LinPy's suggestion I was able to get it to work. It is still strange that it would not work the other way.

A: so you need to set those in one line:
RUN sphinx-quickstart . --quiet --project devops --author 'Timothy Pulliam' -v '0.1' --language 'en' --makefile && make html

I think you can see in the logs , remove intermediate container there for the rule html is not there anymore

A: The Dockerfile VOLUME directive mostly only has confusing side effects.  Unless you're 100% clear on what it does and why you want it, you should just delete it.
In particular, one of those confusing side effects is that RUN commands that write into the volume directory just get lost.  So when on line 7 you say VOLUME /sphinx, the RUN sphinx-quickstart on line 15 tries to write its output into the current directory, which is a declared volume directory, so the output content isn't persisted into the image.
(Storing your code in a volume isn't generally appropriate; build it into the image so it's reusable later.  You can use docker run -v to bind-mount content over any container-side directory regardless of whether or not it's declared as a VOLUME.)

A: You've already resolved the issue with LinPy's helpful comment, but just to add more, doing a quick google search with your error message comes up with this StackOverflow post...
gcc makefile error: "No rule to make target ..."
Perhaps you were accidentally invoking a different command (in this case a GCC command) rather than the .bat file provided by Sphinx.
Hopefully this might shed a bit more light on WHY it was happening. I assume the Ubuntu parent image you're using has GCC pre-installed.


text:
Q: How do i use Chartboost with admob mediation? I am looking to use chartboost,vungle and adcolony with admob mediation.
I have successfully generated ads through vungle and adcolony.But not getting ads with chardboost.
        vunglePub.init(getActivity(), "String");

        AdColony.configure(getActivity(), "version", "String", "String");

        MobileAds.initialize(getActivity(), "String");
        mAd = MobileAds.getRewardedVideoAdInstance(getActivity());
        FromRewardVideos();
        Bundle bundle = new Bundle();

        adRequest = new AdRequest.Builder()
            .addNetworkExtrasBundle(VungleInterstitialAdapter.class, bundle)
            .addNetworkExtrasBundle(AdColonyAdapter.class, bundle)
            .addTestDevice("device_id")
            .build();

And i am trying to implement ChartBoost like this -
Chartboost.startWithAppId(getActivity(),"id","signature");
    DelegateMethod();
    Chartboost.setDelegate(chartboostDelegate);
    Chartboost.onCreate(getActivity());

private void AdLoad() {
    if (Chartboost.hasRewardedVideo(CBLocation.LOCATION_DEFAULT)) {
       Chartboost.showRewardedVideo(CBLocation.LOCATION_DEFAULT);
    }
    else {
        // We don't have a cached video right now, but try to get one for next time
        Chartboost.cacheRewardedVideo(CBLocation.LOCATION_DEFAULT);

    }
}

private void DelegateMethod() {
    chartboostDelegate = new ChartboostDelegate() {
        @Override
        public void didFailToLoadRewardedVideo(String location, CBError.CBImpressionError error) {
            super.didFailToLoadRewardedVideo(location, error);

            Chartboost.cacheRewardedVideo(CBLocation.LOCATION_DEFAULT);

        }

    };
}

And calling adbuilder like this
Bundle bundle = new Bundle();

    adRequest = new AdRequest.Builder()
        .addNetworkExtrasBundle(ChartboostAdapter.class, bundle)
        .addTestDevice("device_id")
        .build();

Thanks in advance

A: If you're trying to mediate all of these networks through AdColony, I believe you are NOT supposed to be initializing all of the ad networks on their own. The AdMob adapter functions by initializing each ad network as you call for an ad.
I know that for Chartboost in particular, if you initialize the SDK outside of the Chartboost adapter, the AdMob integration with Chartboost will simply fail and you're better off using Chartboost on its own. AdMob intends to have the adapter do all of the initializing.
I believe they have official instructions on how to integrate each ad network at this link here: https://firebase.google.com/docs/admob/ios/mediation-networks


text:
Q: How to get values from foreach with insert statement I'm a newbie. I use GetSelectedIndices and foreach to get each values in array.
After that, I provided those values for the insert statement. How can I get query_TheLoai from insert statement in foreach? I work it on webform
var TheLoaiIds = lbxTheLoai.GetSelectedIndices();

foreach (var TheLoaiId in TheLoaiIds)
{
    string query_TheLoai = "SELECT @MaPhim = SCOPE_IDENTITY();INSERT INTO ChiTietTL VALUES ('" + TheLoaiId + "', @MaPhim)";
}

Sorry for the awkwardness

A: var TheLoaiIds = lbxTheLoai.GetSelectedIndices();
string CStr = "YourConnectionString";

string Query = "INSERT INTO ChiTietTL VALUES ('" + TheLoaiId + "', @MaPhim)";

using(var conn = new SqlConnection(CStr))
{
    foreach (var TheLoaiId in TheLoaiIds)
    {
        using(var cmd = new SqlCommand(Query, conn))
        {
             try
             {
                 cmd.Parameters.AddWithValue("@MaPhim", TheLoaiId);
                 cmd.ExecuteNonQuery();
             }
             catch (SqlException ex)
             {
                 MessageBox.Show(ex.ToString());
             }
         }
     }
}

A:     var TheLoaiIds = lbxTheLoai.GetSelectedIndices();
    string CStr = "YourConnectionString";

    string Query = "SELECT @MaPhim = SCOPE_IDENTITY(); INSERT INTO ChiTietTL VALUES (@TheLoaiId, @MaPhim)";

    using(var conn = new SqlConnection(CStr))
    {
        foreach (var TheLoaiId in TheLoaiIds)
        {
            using(var cmd = new SqlCommand(Query, conn))
            {
                 try
                 {
                     cmd.Parameters.AddWithValue("@TheLoaiId", TheLoaiId);
                     cmd.ExecuteNonQuery();
                 }
                 catch (SqlException ex)
                 {
                     MessageBox.Show(ex.ToString());
                 }
             }
         }

}