text:
Q: Trouble installing C++ libraries from Github I've used C++ for several courses in university but the libraries we used in these courses were quite simple to install. When we came across libraries which required a bit more complex installation, our teachers always provided detailed instructions.
This time I'm doing a project on my own. I have downloaded libraries for my own projects in the past. Sometimes the install was easier, sometimes I had to search for hours to do things most people here would do in 5 minutes.
I did some studying to remember some stuff about the compiling process, what dynamic and static libraries are, etc. I feel I understand the most part but it didn't really help me with my efforts to install some libraries. Some people in Github provide instructions for newbies like me, but others, understandably, don't.
I'm saying a lot so I'll get to the point. I will provide links for the library I'm trying to install but in case I'm not allowed to, please let me know so I can rewrite this in a way that is allowed.
I'm trying to install libccd so I can then install fcl. In the instructions 3 ways are mentioned:

*

*Using Makefile

*Using autotools

*Using Cmake

In all 3 methods, I see specific commands like this :

First of all, where am I supposed to write these commands?
I don't even know how to search this. So, I tried installing with methods I've previously used.
Here are the steps I took:

*

*Downloaded the whole repository.

*Made a solution for Visual Studio with Cmake-gui (that's all I know how to do with Cmake,unfortunately it usually was enough so I never learnt more)

*Compiled the code in Release mode, which should give me a lib file.

*Now,in my own project, I added the relevant include directories of the repository I downloaded and the library directory for the lib file which was produced.

I'm not sure about my last step. I'm pretty sure if I did the installation as proposed in the link(and as required by fcl), I would have a new folder for the library including just an include folder and a lib folder. Now I'm just searching for the correct include files and the lib file in subfolders of subfolders hoping I include the right ones. I'm a bit lost.
I'd really like some general steps(if there are) to installing a library. I know each library has its own ways but I assume the general idea with Cmake or Makefile should be the same. I have tried searching online but I didn't come across a good or detailed enough tutorial. I really don't wanna waste any more days trying to install libraries and I don't want to end up asking here again.
UPDATE:
It looks like there is no standard way to install libraries. Since I'm getting 'close votes' I'll include a specific question:
Are the steps I took correct? What should I do next?

A:
I'm trying to install libccd so I can then install fcl. In the instructions 3 ways are mentioned:

*

*Using Makefile

*Using autotools

*Using Cmake

In all 3 methods, I see specific commands like this :

First of all, where am I supposed to write these commands?

These instructions are for a UNIX-like system. Makefiles, autotools... these are UNIX things. You'd typically write those build commands into a console window on something like Linux or a Mac.
CMake is a bit more cross-platform. You can find out how to invoke CMake on other SO questions.
You can get Makefiles and such to work on Windows, using projects like Cygwin and MSYS. I'd generally recommend you avoid that unless you really need it.

I'm not sure about my last step. I'm pretty sure if I did the installation as proposed in the link(and as required by fcl), I would have a new folder for the library including just an include folder and a lib folder. Now I'm just searching for the correct include files and the lib file in subfolders of subfolders hoping I include the right ones. I'm a bit lost.

This is where no "general" advice exists. Different authors put their output in different places. If their instructions didn't include this information, you're already doing the right thing. If you get really stuck, you can always just ask them.

I'd really like some general steps(if there are) to installing a library.

No such thing exists, but where these industry-standard tools are involved, you can usually go on general documentation for those tools, or from memory.
I also suggest you shop around for a general book on programming, as general principles should be covered in any good one of those.


text:
Q: Spring MVC Test Dirties a *Different* ApplicationContext I'm working on an Application using Spring MVC 4.0.4 and Hibernate, and we're using Spring Test MVC 1.0.0.M2 to do some integration/unit tests. We use HSQLDB as an in-memory DB during these tests and have Hibernate create the schema (hibernate.hbm2ddl.auto is create). I've got a problem with a setup that's sort of like the following:
There are three test classes: A, B, C. They all use the database and are executed in that order. It's essentially this:
Test A and C:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
        "/configuration/someBeanConfig",
        "/configuration/someDatabaseConfig.xml",
})
@WebAppConfiguration()
public class SomeTest {
  // ... Tests
}

Test B:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
    // Configs and test data sets:
    SomeDatabaseConfig.class,
    SomeOtherConfig.class,
    // Actual beans used:
    SomeBean.class,
    AnotherBean.class,
})
public class DifferentTest {
  // ... Tests
}

According to the Spring documentation, since the ApplicationContext config of A and C are equal, they share a cached ApplicationContext. B has a different context. However, it still uses the same database.
Here is the problem:

*

*Test B does some things that pollute the database, causing Test C to fail.

*According to this Spring documentation I can use the @DirtiesContext annotation to tell Spring that a test does something bad to the ApplicationContext and that Spring should re-initialize it upon next use.

*Putting @DirtiesContext on Test B will not work, because it's not context B that should be fixed, it's also that of A and C. Putting it on Test B won't make Spring re-initialize that of Test C.

*I could put @DirtiesContext on Test A. Then, when it's time to run Test C, Spring will create the new ApplicationContext from scratch. However, if the order of tests ever changes, or we add tests with the same ApplicationContexts and they're run in between these, the problem would just re-occur. All the while the order of unit/integration tests really should not matter. So it's not a permanent solution, and it's also not very elegant.

*I tried setting the hibernate.hbm2ddl.auto property to create-drop and update, but since the ApplicationContext is re-created from scratch, neither is the database schema, and so it doesn't help.

Any suggestions on how to tell Spring that all contexts are dirtied (say, @DirtiesEveryContext)? Or any other suggestions about how to solve this?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Extending the available space in a mirrored ZFS pool with zpool add? I have a mirror pool with two devices (sda, sdb) on my Debian.
And now I inserted two additional devices (sdc, sdd), so I could double the available space in the /mnt/data/ directory.
Is it done by just sudo zpool add backup-pool mirror sdc sdd?
I'm a bit scared so I want to make sure. Sorry for the rookie question.
Here are the details of my pool:
sudo zfs list
NAME               USED  AVAIL     REFER  MOUNTPOINT
backup-pool       1.47T  1.17T       96K  /backup-pool
backup-pool/data  1.47T  1.17T     1.47T  /mnt/data

sudo zpool list
NAME          SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
backup-pool  2.72T  1.47T  1.25T        -         -    11%    53%  1.00x    ONLINE  -

sudo fdisk -l
Disk /dev/sdc: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EFAX-68J
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/sdd: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EFAX-68J
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/sdb: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EFAX-68J
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: ABB57994-974B-734A-A2A9-2BA616368A52

Device          Start        End    Sectors  Size Type
/dev/sdb1        2048 5860515839 5860513792  2.7T Solaris /usr & Apple ZFS
/dev/sdb9  5860515840 5860532223      16384    8M Solaris reserved 1

Disk /dev/sda: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EFAX-68J
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: DCDDA5ED-CB54-C042-9AF6-076F07F44E96

Device          Start        End    Sectors  Size Type
/dev/sda1        2048 5860515839 5860513792  2.7T Solaris /usr & Apple ZFS
/dev/sda9  5860515840 5860532223      16384    8M Solaris reserved 1

Thanks!

A: Short answer:

Is it done by just sudo zpool add backup-pool mirror sdc sdd?

Yes.
Long answer:

I'm a bit scared so I want to make sure.

It's often simpler than one might think to test using non-critical devices, such as small virtual memory disks or in this case, file-backed virtual disks.
This is on FreeBSD, but Linux has tools to do the same thing.
I'll create four files of 1G each and use each file as a file-backed virtual disk:
# for i in $(jot 4 0)
> do
>         truncate -s1G md$i
>         mdconfig -f md$i
> done

I now have drives /dev/md0 through /dev/md3 to play with.  I'll create the original single-VDEV pool you have by mirroring /dev/md0 and /dev/md1:
# zpool create tank mirror md0 md1
# zpool status tank
  pool: tank
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            md0     ONLINE       0     0     0
            md1     ONLINE       0     0     0

errors: No known data errors

The Wrong Way:
If you try to add the next disk md2 to the pool, zpool warns that you're down-grading the redundancy of the pool:
# zpool add tank md2
invalid vdev specification
use '-f' to override the following errors:
mismatched replication level: pool uses mirror and new vdev is disk

And indeed if you do force this operation, and likewise force the addition of md3 you get:
# zpool add -f tank md2
# zpool status tank
  pool: tank
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            md0     ONLINE       0     0     0
            md1     ONLINE       0     0     0
          md2       ONLINE       0     0     0

errors: No known data errors

# zpool add -f tank md3
# zpool status tank
  pool: tank
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            md0     ONLINE       0     0     0
            md1     ONLINE       0     0     0
          md2       ONLINE       0     0     0
          md3       ONLINE       0     0     0

errors: No known data errors

Notice that devices md2 and md3 have no redundancy.  Your pool is vulnerable to any of three failures: 1) if BOTH halves of the mirror fail; 2) if disk md2 fails; or 3) if disk md3 fails.  Any one of those three events will make your pool unusable.
The Better Way:
My example above is simply to show what happens when you do it the wrong way.  The better method, indeed the one which I believe you are seeking, is to add the two new drives as a second mirror, concatenated with the first mirror.
For improved redundancy, tell zpool that you want to add a mirror to the existing pool:
# zpool status tank
  pool: tank
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            md0     ONLINE       0     0     0
            md1     ONLINE       0     0     0

errors: No known data errors

# zpool add tank mirror md2 md3
# zpool status tank
  pool: tank
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          mirror-0  ONLINE       0     0     0
            md0     ONLINE       0     0     0
            md1     ONLINE       0     0     0
          mirror-1  ONLINE       0     0     0
            md2     ONLINE       0     0     0
            md3     ONLINE       0     0     0

errors: No known data errors


text:
Q: mutt smtp certificate hostname does not match I'm trying to polish up my mailserver so that all tls certificates match, and everything runs as perfectly as possible.  I can receive email just fine.  I can also send email, however when mutt checks the smtp certificate, it tells me the hostname doesn't match the certificate.  I ~could~ disable certificate checking, but that seems like it just masks the symptoms instead of fixing the problem.  Its my intention to force the use of TLS for both IMAP receiving and SMTP sending.  I don't intend for POP access at all.
From what I can tell, the server hostname is correctly set, and it's being reported by both the kernel and postfix config.
My server hostname does have an A record in DNS that points to the correct IP.

*

*The server webmail can be accessed using https://webmail.poindexter.farm/
username and password are below

*SMTP(postfix) and IMAP(dovecot) are both on hwsrv690473.poindexter.farm

*I've created a test user account to help any of you, username and password are both "test"

Any help would be much appreciated!

A magic ssl command I was asked to run... I have no idea how it works.
brad@mini-odin:~ $ echo "" | openssl s_client -connect poindexter.farm:587 -starttls smtp | openssl x509 -noout -text | grep -1 'Alternative Name'
depth=1 C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
verify error:num=20:unable to get local issuer certificate
verify return:0
250 SMTPUTF8
DONE

            X509v3 Subject Alternative Name:
                DNS:hwsrv-690473.poindexter.farm

muttrc on client computer
brad@mini-odin:~ $ cat .muttrc
# vi ~/.muttrc
# About Me
set from = "test@poindexter.farm"
set realname = "test account"

# My credentials
set smtp_url = "smtp://test@poindexter.farm:587/"
set smtp_pass = "test"

set imap_user = "test" #-This allows login when opening mutt
set imap_pass = "test"
#set smtp_authenticators="login"

set ssl_starttls = yes
set ssl_force_tls = yes

# My mailboxes
set folder = "imaps://hwsrv-690473.poindexter.farm:993"
set spoolfile = "+INBOX"

# Where to put the stuff
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"

# Etc
set mail_check = 30
set move = no
set imap_keepalive = 900
set sort = threads
set editor = "vim"

# GnuPG bootstrap
# source ~/.mutt/gpg.rc
brad@mini-odin:~ $

mutt debug file from the point of hitting y to send a composed email
brad@mini-odin:~ $ cat .muttdebug0
[2020-06-11 11:57:36] In mutt_reflow_windows
[2020-06-11 11:57:38] Sending message...
[2020-06-11 11:57:38] ../../sendlib.c:2782: mutt_mktemp returns "/tmp/mutt-mini-odin-1001-25828-368841125475337537".
[2020-06-11 11:57:38] mwoh: buf[Subject: test email] is short enough
[2020-06-11 11:57:38] ../../send.c:987: mutt_mktemp returns "/tmp/mutt-mini-odin-1001-25828-15718660201142318120".
[2020-06-11 11:57:38] mwoh: buf[Subject: test email] is short enough
[2020-06-11 11:57:38] Looking up poindexter.farm...
[2020-06-11 11:57:38] Connecting to poindexter.farm...
[2020-06-11 11:57:38] Connected to poindexter.farm:587 on fd=5
[2020-06-11 11:57:38] 5< 220 hwsrv-690473.poindexter.farm ESMTP Postfix (Debian/GNU)
[2020-06-11 11:57:38] 5> EHLO localhost
[2020-06-11 11:57:38] 5< 250-hwsrv-690473.poindexter.farm
[2020-06-11 11:57:38] 5< 250-PIPELINING
[2020-06-11 11:57:38] 5< 250-SIZE 10240000
[2020-06-11 11:57:38] 5< 250-VRFY
[2020-06-11 11:57:38] 5< 250-ETRN
[2020-06-11 11:57:38] 5< 250-STARTTLS
[2020-06-11 11:57:38] 5< 250-ENHANCEDSTATUSCODES
[2020-06-11 11:57:38] 5< 250-8BITMIME
[2020-06-11 11:57:38] 5< 250-DSN
[2020-06-11 11:57:38] 5< 250 SMTPUTF8
[2020-06-11 11:57:38] 5> STARTTLS
[2020-06-11 11:57:38] 5< 220 2.0.0 Ready to start TLS
[2020-06-11 11:57:57] SSL/TLS connection using TLS1.2 (ECDHE-RSA/AES-256-GCM/AEAD)
[2020-06-11 11:57:58] 5> EHLO localhost
[2020-06-11 11:57:58] 5< 250-hwsrv-690473.poindexter.farm
[2020-06-11 11:57:58] 5< 250-PIPELINING
[2020-06-11 11:57:58] 5< 250-SIZE 10240000
[2020-06-11 11:57:58] 5< 250-VRFY
[2020-06-11 11:57:58] 5< 250-ETRN
[2020-06-11 11:57:58] 5< 250-AUTH PLAIN LOGIN
[2020-06-11 11:57:58] 5< 250-ENHANCEDSTATUSCODES
[2020-06-11 11:57:58] 5< 250-8BITMIME
[2020-06-11 11:57:58] 5< 250-DSN
[2020-06-11 11:57:58] 5< 250 SMTPUTF8
[2020-06-11 11:57:58] SASL local ip: 192.168.1.10;55794, remote ip:192.119.74.117;587
[2020-06-11 11:57:58] External SSF: 256
[2020-06-11 11:57:58] External authentication name: test
[2020-06-11 11:57:58] Authenticating (LOGIN)...
[2020-06-11 11:57:58] 5> AUTH LOGIN
[2020-06-11 11:57:58] 5< 334 VXNlcm5hbWU6
[2020-06-11 11:57:58] mutt_sasl_cb_authname: getting authname for poindexter.farm:587
[2020-06-11 11:57:58] 5> dGVzdA==
[2020-06-11 11:57:58] 5< 334 UGFzc3dvcmQ6
[2020-06-11 11:57:58] mutt_sasl_cb_pass: getting password for test@poindexter.farm:587
[2020-06-11 11:57:58] 5> dGVzdA==
[2020-06-11 11:57:58] 5< 235 2.7.0 Authentication successful
[2020-06-11 11:57:58] SASL protection strength: 0
[2020-06-11 11:57:58] SASL protection buffer size: 65536
[2020-06-11 11:57:58] 5> MAIL FROM:<test@poindexter.farm>
[2020-06-11 11:57:58] 5< 250 2.1.0 Ok
[2020-06-11 11:57:58] 5> RCPT TO:<brad.bailey@gmail.com>
[2020-06-11 11:57:58] 5< 250 2.1.5 Ok
[2020-06-11 11:57:58] 5> RCPT TO:<test@poindexter.farm>
[2020-06-11 11:57:58] 5< 250 2.1.5 Ok
[2020-06-11 11:57:58] updating progress: 0K
[2020-06-11 11:57:58] Sending message... 0K/0.4K (0%)
[2020-06-11 11:57:58] 5> DATA
[2020-06-11 11:57:58] 5< 354 End data with <CR><LF>.<CR><LF>
[2020-06-11 11:57:58] 5> Date: Thu, 11 Jun 2020 11:57:38 -0500
[2020-06-11 11:57:58] 5> From: test account <test@poindexter.farm>
[2020-06-11 11:57:58] 5> To: brad.bailey@gmail.com, test@poindexter.farm
[2020-06-11 11:57:58] 5> Subject: test email
[2020-06-11 11:57:58] 5> Message-ID: <20200611165738.GA25828@localhost>
[2020-06-11 11:57:58] 5> MIME-Version: 1.0
[2020-06-11 11:57:58] 5> Content-Type: text/plain; charset=us-ascii
[2020-06-11 11:57:58] 5> Content-Disposition: inline
[2020-06-11 11:57:58] 5> User-Agent: Mutt/1.10.1 (2018-07-13)
[2020-06-11 11:57:58] 5>
[2020-06-11 11:57:58] 5> sending a test email to check smtp certificate
[2020-06-11 11:57:58] 5> .
[2020-06-11 11:57:59] 5< 250 2.0.0 Ok: queued as CE28F82380
[2020-06-11 11:57:59] 5> QUIT
[2020-06-11 11:57:59] Mail sent.
[2020-06-11 11:57:59] mutt_free_body: unlinking /tmp/mutt-mini-odin-1001-25828-1671701897145424224.
[2020-06-11 11:59:08] mutt_index_menu[729]: Got op 151
[2020-06-11 11:59:08] Mailbox is unchanged.
[2020-06-11 11:59:08] Closing connection to hwsrv-690473.poindexter.farm...
[2020-06-11 11:59:08] 4> a0005 CLOSE
a0006 LOGOUT
[2020-06-11 11:59:08] 4< a0005 OK Close completed (0.000 + 0.000 secs).
[2020-06-11 11:59:08] 4< * BYE Logging out
[2020-06-11 11:59:08] Handling BYE
[2020-06-11 11:59:08] 4< a0006 OK Logout completed (0.000 + 0.000 secs).
[2020-06-11 11:59:08] IMAP queue drained
brad@mini-odin:~ $

postfix hostname configuration
brad@hwsrv-690473:/home/brad$ sudo postconf -d myhostname
[sudo] password for brad:
myhostname = hwsrv-690473.poindexter.farm
brad@hwsrv-690473:/home/brad$

server hostname
brad@hwsrv-690473:/home/brad$ hostname
hwsrv-690473.poindexter.farm
brad@hwsrv-690473:/home/brad$ hostnamectl
   Static hostname: hwsrv-690473.poindexter.farm
         Icon name: computer-vm
           Chassis: vm
        Machine ID: a945a3535aa8484399fd888f61e31e6d
           Boot ID: 4e25349837c340e280e1060eff314f7c
    Virtualization: kvm
  Operating System: Debian GNU/Linux 9 (stretch)
            Kernel: Linux 4.9.0-3-amd64
      Architecture: x86-64
brad@hwsrv-690473:/home/brad$ cat /proc/sys/kernel/hostname
hwsrv-690473.poindexter.farm
brad@hwsrv-690473:/home/brad$

server /etx/postfix/main.cf
brad@hwsrv-690473:/home/brad$cat /etc/postfix/main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
delay_warning_time = 1h

readme_directory = no

# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2

# TLS parameters
#smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_cert_file=/etc/letsencrypt/live/hwsrv-690473.poindexter.farm/fullchain.pem
#smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_key_file=/etc/letsencrypt/live/hwsrv-690473.poindexter.farm/privkey.pem
smtpd_use_tls=yes
smtp_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = hwsrv-690473.poindexter.farm
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, poindexter.farm, localhost.farm, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

# Mail will be stored in users' ~/Maildir directories
#
# NB: make sure to enforce this setting as well in the `mail_location`
# of /etc/dovecot/conf.d/10-mail.conf (thanks to Markus Hoffmann for
# pointing this out):
#
#     mail_location = maildir:~/Maildir
#
home_mailbox = Maildir/
mailbox_command =

# From http://wiki2.dovecot.org/HowTo/PostfixAndDovecotSASL
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
# SPF stuff

smtpd_recipient_restrictions =
    permit_sasl_authenticated,
    reject_invalid_hostname,
    reject_unknown_recipient_domain,
    reject_unauth_destination,
    reject_rbl_client sbl.spamhaus.org,
    check_policy_service unix:private/policy-spf,
    check_sender_access hash:/etc/postfix/sender_access,
    check_recipient_access hash:/etc/postfix/recipient_access,
    permit
policy-spf_time_limit = 3600s
#
# DKIM
milter_default_action = accept
milter_protocol = 6
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891

brad@hwsrv-690473:/home/brad$

A: You're mutt client is connecting to the SMTP server at smtp://test@poindexter.farm:587/, therefore the hostname is poidexter.farm.  However, your Lets Encrypt certificate has a single Subject Alternate Name (SAN) extension containing a dnsName of hwsrv-690473.poindexter.farm.  You can see this with:
echo "" | openssl s_client -connect poindexter.farm:587 -starttls smtp | openssl x509 -noout -text | grep -1 'Alternative Name'

The above command uses OpenSSL to act as a client (the openssl s_client -connect poindexter.farm:587 -starttls smtp) and connect to your server at poindexter.farm:587 at which point it pretends to be a SMTPS client (-starttls smtp).  As part of the handshake, your server returns its certificate, which the command outputs amongst a multitude of other information.  This data is piped (|) into another OpenSSL command (the openssl x509 -noout -text) which accepts a certificate (conveniently in the PEM format the previous command outputs), decodes it and outputs this as human readable text.  Finally, this text output is piped (|) to grep (the grep -1 'Alternative Name') which filters for the phrase Alternative Name and outputs that and the next line (due to the -1).  You can see the whole certificate by removing the last pipe and grep.
As you can see, the hostname you're accessing doesn't match the name in the certificate, hence the hostname does not match message.
You need to either configure DNS so that the mutt accesses the server using hwsrv-690473.poindexter.farm or get a new certificate with a SAN of poidexter.farm.  That is, they should match.

A: I knew that garethTheRed was on the right path, it's only logical that somewhere the hostname is different.
Changing the hostname on the server is not an option because I have other services running on it.
However, I decided to experiment more with .muttrc, and found a solution!
.muttrc line
#set smtp_url = "smtp://test@poindexter.farm:587/" # this did not work
set smtp_url = "smtp://test@hwsrv-690473.poindexter.farm:587/" # this works

The first line, which is basically username@domain.name:port does not work.
The second line, which is username@server_hostname:port works like a charm!
Thanks, garethTheRed!


text:
Q: Tacky Dropdown Menu Wordpress tacky dropdown
Hi!
Sorry if I've not framed this question correctly but I'm new here. I have this wordpress website where I cannot seem to get rid of these tacky dropdowns. I need them slightly to the right like a proper dropdown and asking these on Facebook groups led me here as I was suggested to mess with the CSS to get this fixed. I know some basic functions but something like this is out of my league. I was hoping if someone well versed on CSS or wordpress styling could help me out here.
Also, if it helps I'm using newsmag theme.
Thanks in Advance

A: If you want them to align to the left side of the buttons, the style is found on line 5668 of /wp-content/themes/Newsmag/style.css:
.sf-menu li ul {
  left: -9px;
  z-index: 99;
  /* responsive portrait tablet */
}

Remove or comment out the line "left: -9px;". Then your dropdowns will line up on the left side.
Please clarify if that's not what you want.


text:
Q: same results in arules after changing support and confidence Yesterday I've started experimenting with apriori and everything was working fine, i.e. I changed support and confidence and results were different depending on combination.
But today after running the same code and same dataset I'm getting 0 rules no matter which combination I'm using.
My dataset looks like this (foodmarket data):
Trans_Id,Product

3694728,Washington Berry Juice

3779788,Washington Berry Juice

4146666,Washington Berry Juice

4405313,Washington Berry Juice

etc.
My code is:
library('arules')
transactions <- read.transactions(file="transactions.csv",format="single",sep=",",cols=c(1,2),rm.duplicates="false")

basket_rules <- apriori(transactions, parameter = list(sup = 0.05, conf = 0.01, target="rules",minlen=2))

With the following results:
http://s2.postimg.org/b9k7xfq91/apriori_results1.jpg
And another one with different parameters but same result:

So, I have no idea how is that possible.

A: The first screen shot is hard to read. The second one just says that there are no items in your transactions which pass the minimum support threshold and that is why you do not get any rules. Maybe there is a problem with reading the transactions. Did you try summary(transactions) first?


text:
Q: Can I place all ssl directives in NGINX's http block? I've a webserver serving several subdomains (the usual nginx.conf with a sites-enabled folder), and I'm updating ssl_ciphers, ssl_dhparam, etc.
Given that I want the same security measures for all the subdomains, can I place ssl_ciphers, ssl_dhparam, ssl_protocols, etc. in the http block of nginx.conf, rather than repeating in every subdomain's server block?

A: Short answer: Yes
In the documentation each directive specifies a context which are the blocks within which the directives may be placed. All of the ssl_ directives can be placed in the http or server contexts.


text:
Q: How to configure StandardOauth2AccessTokenProvider properly? We are currently trying to access the Google Spreadsheet REST API through InvokeHTTP.
However, we are struggling to get the StandardOauth2AccessTokenProvider configured properly.
We upgraded our Nifi instance to version 1.16.3 in order to provide the scope, however, we are not sure which data needs to be put into the Client ID and Client Secret.
We tried the following options:

*

*Create Oauth2 credentials in the Google Cloud console and provide these

*Combine the above approach with a google username and password (in User Password mode)

*Create a service account and provide its credentials
Whenever we try to send any request to the Google Spreadsheets API, we always get the same stack trace:
2022-09-29 11:47:18,193 ERROR [Timer-Driven Process Thread-2] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=86d7424e-0183-1000-cd72-d2071e1add8b] Failed to properly initialize Processor. If still scheduled to run, NiFi will attempt to initialize and run the Processor again after the 'Administrative Yield Duration' has elapsed. Failure is due to java.io.UncheckedIOException: OAuth2 access token request failed
java.io.UncheckedIOException: OAuth2 access token request failed
    at org.apache.nifi.oauth2.StandardOauth2AccessTokenProvider.getAccessDetails(StandardOauth2AccessTokenProvider.java:330)
    at org.apache.nifi.oauth2.StandardOauth2AccessTokenProvider.acquireAccessDetails(StandardOauth2AccessTokenProvider.java:289)
    at org.apache.nifi.oauth2.StandardOauth2AccessTokenProvider.getAccessDetails(StandardOauth2AccessTokenProvider.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:254)
    at org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:105)
    at com.sun.proxy.$Proxy108.getAccessDetails(Unknown Source)
    at org.apache.nifi.processors.standard.InvokeHTTP.initOauth2AccessTokenProvider(InvokeHTTP.java:864)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:145)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:133)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:78)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:55)
    at org.apache.nifi.controller.StandardProcessorNode.lambda$initiateStart$6(StandardProcessorNode.java:1662)
    at org.apache.nifi.engine.FlowEngine$3.call(FlowEngine.java:123)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (StringReader); line: 1, column: 2]
    at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2391)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:735)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:659)
    at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:2005)
    at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:802)
    at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4761)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4667)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3629)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3597)
    at org.apache.nifi.oauth2.StandardOauth2AccessTokenProvider.getAccessDetails(StandardOauth2AccessTokenProvider.java:324)
    ... 26 common frames omitted

Is this due to a possible Consent Screen? Any pointers on what we are doing wrong?


text:
Q: gitlab-runner broken in CI, works manually - Debian release-upgrade at fault? Some time ago, I had set up a gitlab-runner on a Debian 9 server. All was well. CI ran and it ran successfully. Now, 11 months after the last test had been run, I was instructed to add a feature to the project and the first thing I did was re-run old tests.
They failed, going from "no problem" to "no worky at all" in 11 months. The only thing that I gave significance to was a distribution-upgrade to Debian 10.
No worky - running locally under gitlab-runner's service-account:
/tmp/projektv$ sudo -u gitlab-runner /usr/lib/gitlab-runner/gitlab-runner   exec shell run_tests
Runtime platform                                    arch=amd64 os=linux pid=25578 revision=1564076b version=12.4.0
Running with gitlab-runner 12.4.0 (1564076b)
Using Shell executor...
Running on simsrv15...
ERROR: Job failed: exit status 1
FATAL: exit status 1

Automatic jobs (when pushing commits) on the webUI look the same. Same outcome with gitlab-runner versions 12.0 and 12.3. No change with new registration.
Works when run locally with my personal user-account:
/tmp/project$ /usr/lib/gitlab-runner/gitlab-runner exec shell run_tests
Runtime platform                                    arch=amd64 os=linux pid=23331 revision=1564076b version=12.4.0
Running with gitlab-runner 12.4.0 (1564076b)
Using Shell executor...
Running on simsrv15...
Fetching changes...
....
OK
System check identified no issues (0 silenced).
Destroying test database for alias 'default' ('file:memorydb_default?mode=memory&cache=shared')...
Job succeeded

Running the faulty job with --debug or even strace did not reveal anything especially interesting to me. https://pastebin.com/8j8eQAHB
Running the same job from a different runner, newly set up on a Debian 9 system, works perfectly.

A: I found that running strace -f automatically attaches to spawned children. As I had seen that forking was one of the last things that the runner did, I tried that. And look what I found:
[pid 88504] execve("/usr/bin/clear_console", ["/usr/bin/clear_console", "-q"], 0x564cc4bbf1c0 /* 19 vars */) = 0

clear_console, eh? Armed with new knowledge, google gave me this:
https://gitlab.com/gitlab-org/gitlab-runner/issues/4559
Fun thing: Debian 9 also has clear_console in the .bash_logout, where it does not crash the runner....


text:
Q: Value passed to time.sleep() determines whether code fails or not I'm not sure what's going on here but my code fails with exit code 15 and no other errors messages depending on what value I pass to time.sleep()
import docker, docker.utils, time
Thread(target = partial(image_runner.run, create_biobox_args(app))).start()

time.sleep(1)
client = docker.Client(**docker.utils.kwargs_from_env(assert_hostname = False))
container = filter(lambda x: x['Image'] == name, client.containers())[0]['Id']
while client.inspect_container(container)["State"]["Status"] == "running":
    time.sleep(20)

I have a docker container started in another thread with Thread(...).start(). However if I use time.sleep() with a value greater than 10 my code will fail with exit code 15, but work otherwise. Any idea what's going on here? I've been trying to debug this but haven't a clue.

A: Turns out my feature tests timeout after 10 seconds and this what causes the problem. Adjusting the length of the cucumber feature tests default timeout fixes this problem.


text:
Q: Python SQL Select Syntax with variable in between I have a SQL statement that works in mysql:
SELECT * FROM `ps_message` WHERE `id_order` = 111 ORDER BY id_message asc LIMIT 1

What is wrong with the following statement in Python:
cursor2.execute("SELECT * FROM ps_message WHERE id_order='%s'" % order["id_order"] " ORDER BY id_message asc LIMIT 1")

How should the syntax be in Python to work?

A: You have a syntax error in string formatting. Should be:
cursor2.execute("SELECT * FROM ps_message WHERE id_order='%s' ORDER BY id_message asc LIMIT 1" % order["id_order"])

Using format() is also preferable over old-style string formatting. Read more about it here.

A: Pass the order number as a query parameter.
e.g.
cursor2.execute("SELECT * FROM ps_message WHERE id_order=%s ORDER BY id_message asc LIMIT 1", [ order["id_order"] ])

Note that when using query parameters you don't put quotes around the %s.
This approach is recommended to avoid the risk of sql injection attacks.
It should also be more efficient if there are many queries.
https://docs.python.org/2/library/sqlite3.html
http://pymssql.org/en/stable/pymssql_examples.html


text:
Q: How does a compiled program interact with the OS? When a program is compiled it is converted to machine code which can be "understood" by the machine. How does this machine code interact with the operating system in order to do things like getting input from the keyboard ?
To me, it seems that the machine code should run at a lower level than the operating system and therefore, I can't understand how the OS can act as an intermediary between the compiled application and the hardware.
PS : I just started C ++ programming and I am trying to understand how cin and cout work

A: The operating system provides system calls that programs can call to get access to lower level services.
Note that system calls are different from the system() function that you have probably used to execute external programs.
System calls are used to do things like access files, communicate over the network, request heap memory, etc.

A: This is a very good question (better than you know), and there is a lot to learn. A LOT.
I'll try to keep it short. The operating system acts as a level of abstraction between software and hardware:
   Software
       .
      /|\
       |   communicates with
      \|/
       '
Operating System
       .
      /|\
       |   communicates with
      \|/
       '
   Hardware

The OS communicates with the hardware through programs called drivers (widely used term), and the OS communicates with software through procedures called system calls (not-so-widely used term).
Essentially, when you make a system call, you are leaving your program and entering code of the operating system. System calls are the only way programmers are allowed to communicate with resources.

Now I would stop there, but you also said:

To me, it seems that the machine code should run at a lower level than
  the operating system and therefore, I can't understand how the OS can
  act as an intermediary between the compiled application and the
  hardware.

This is tricky, but simple once you understand some basics.
First, all code is just machine code running on the CPU. No code is higher or lower than other code (with the exception of some commands that can only be run in a privileged kernel mode). So the question is, how can the OS possibly be in control even though it is relinquishing control of the CPU to the user?
When code is running on a CPU, there is a concept called an interrupt. This is a signal sent to the CPU that causes the currently running code to stop and get switched out with another piece of code, called an interrupt handler.
Examples of interrupts include the keyboard, the mouse, and most importantly, the clock.
The clock interrupt is raised on a regular basis causes the operating system's clock interrupt handler to run. Within this clock interrupt handler is the operating system's code that examines what code is currently running determines what code needs to run next. This can be either more operating system code or more user code.
Because the clock is always ticking, and because the operating system always gets this periodic chance to run on the CPU, it is able to orchestrate everything within the computer, even though it runs using the same set of CPU commands as any normal program.


text:
Q: How to inject JAR version when running Gradle? Typically I see version statically defined inside a build.gradle or gradle.properties file like so:
version = '1.5.3'

But I would like to "inject" the version dynamically when I run gradle jar, so something like this:
gradle jar --version "1.5.4"

etc. But it doesn't look like Gradle supports this. In any event, I need a way to define the version number outside of the buildscript or any of its property files. Any way to accomplish this is a viable solution. Any ideas?

A: The version is just a property of the project, that you can define externally, as any other property, using the -P option:
gradle jar -Pversion=1.5.4


text:
Q: Trouble with resizebox and Revtex4.1 I'm having a lot of trouble using resizebox with equations in Latex for certain templates. I have the following code:
\documentclass[%
aip,%
jmp,%
% cp,%
amsmath,amssymb,%
%preprint,%
reprint,%
groupedaddress,
%author-year,%
%author-numerical,%
]{revtex4-1}

\begin{document}

\begin{equation} \label{eq:Field_x}
\resizebox{.9\hsize}{!}{$\hat{x} =0$} \\
\end{equation}

\end{document}

Using a IEEE format file and the most recent version of Latex, it works perfectly fine. However if I want to compile it to AIP publishing standards which uses REVTEX 4.1, I get the following errors:
! LaTeX Error: There's no line here to end.See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help.... \resizebox{.9\hsize}{!}{$\hat{x} =0$} \\
! Missing $ inserted.<inserted text>$ \resizebox{.9\hsize}{!}{$\hat{x} =0$} \\
! Display math should end with $$.<to be read again>\par \resizebox{.9\hsize}{!}{$\hat{x} =0$} \\

I've tried so much and I can't seem to figure out what's wrong. Why would it compile fine using the standard compiler, but not ok using REVTEX4.1? Does anyone have any ideas for what I'm doing wrong and/or if there is a workaround?

A: Your error refers to a line-ending which, in your case, happens inside the equation.
Remove the trailing \\ in your equation should solve your problem.


text:
Q: laravel push queued jobs from different codebase I'm trying to trigger Jobs from other codebase
MyCommand Class:
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Jobs\MyJob;

class EncodeTvVideos extends Command
{
    use DispatchesJobs;

    protected $signature = 'command:my';

    protected $description = '';

    public function handle()
    {
        $job = (new MyJob($this->argument()))
            ->onConnection('beanstalkd')
            ->onQueue('cron-default'));

        $this->dispatch($job);
    }
}

And MyJob Class:
<?php namespace App\Jobs;

use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class MyJob extends Job implements ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    private $payload;

    public function __construct($payload = null)
    {
        $this->payload = $payload;
    }

    public function handle()
    {
        echo "Job processed here";
        $this->job->delete();
    }
}

I'm listen my queue by using queue:listen command like
php artisan queue:listen --queue=cron-default

If i run command (inside some codebase) command:my i'm getting payload like this any processed successfully.
{
    "job":"Illuminate\\\\Queue\\\\CallQueuedHandler@call",
    "data":{
        "command":"O:29:\\"Acme\\Jobs\\FooJob\\":4:{s:11:\\"fooBar\\";s:7:\\"abc-123\\";s:5:\\"queue\\";N;s:5:\\"delay\\";N;s:6:\\"\\u0000*\\u0000job\\";N;}"
    }
}

Now my problem is i need to trigger this Job or command from other codebase is there any way?
I don't have domain name for the (commands/workers project) or else i could try create one route it will trigger command.

A: By the help this ref
By using these packages "illuminate/queue": "5.2.", "pda/pheanstalk": "~3.0", "illuminate/encryption": "5.2."
I'm able to push plain payload to the given tube like this
use Illuminate\Queue\Capsule\Manager as Queue;

$queue = new Queue;

// Some drivers need it
$queue->getContainer()->bind('encrypter', function() {
    return new Illuminate\Encryption\Encrypter('foobar');
});

$queue->addConnection([
    'driver' => 'beanstalkd',
    'host' => 'localhost',
    'queue' => 'default',
], 'default');

$queue->push('App\Jobs\MyJob@process', ['data'=> 'something']);

//First parameter complete path of the JobClass in other codebase
//Second parameter any parameter to the Job.
Minor modification in my Job to handle both commands, and plain payload
<?php namespace App\Jobs;

use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class MyJob extends Job implements ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    private $payload;

    public function __construct($payload = null)
    {
        $this->payload = $payload;
    }

    public function handle()
    {
        echo "Job processed here";
        $this->job->delete();
    }

   public function process($job, $payload)
    {
        echo "Job processed from plain payload";
        $job->delete();
    }
}


text:
Q: Delete Tree child node in Window application I am working on a Windows application where I am showing logs using a treeview as shown below, here nodes are created dynamically on the basis of daily logs
Logs -
+ 12-02-2001
+ 12-02-2001
+ 12-02-2001
+ 12-02-2001

but I want to add delete button with each node as shown below
Logs -
+ 12-02-2001 Delete
+ 12-02-2001 Delete
+ 12-02-2001 Delete
+ 12-02-2001 Delete

Thanks.

A: You can make it easier using ContextMenuStrip.
http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip.aspx
            //event handler for menuItem Click
    private void mnuDelNode_Click(object sender,EventArgs e)
    {
        //better confirm before delete using a message box

        DeleteRecursive(listView.SelectedNode);
    }
    private void DeleteRecursive(TreeNode root)
    {
        //your delete logic here
    }

A: If you are using WindowsForms, you would need to implement custom drawing of the TreeView and do hit testing on the Click event to see if the button was clicked.  The TreeView was not really designed to add in buttons, so you may wish to consider an alternative design, say adding in a right menu, a toolbar, and/or right click menu with the Delete command on it, as that would be significantly less work and more in line with how the standard Windows controls work (you don't see a bunch of buttons behind folder names in Windows Explorer's TreeView for instance).


text:
Q: Converting the contents of a linked list to string (using stringstream) but cannot figure out how to iterate through list c++ I am currently trying to write a function that will convert the data inside a linked list to a string using stringstream. I cannot figure out how to do it but have started the function with minimal functionality. How could I better write my function to achieve this?
SList.cpp:
/*
 * SList.cpp
 *
 * written by Carlos D. Escobedo
 * created on 26 Oct
 *
 * References: programmingforums.org (printing linked lists), stackoverflow
 *             (.h file linking issues)
 */

#include "SList.h"

SList::SList() {
    head = NULL;
    size = 0;
}

SList::~SList() {
    SList::clear();
    delete head;
}

void SList::insertHead(int value) {
    if(head == NULL) {
        head = new SLNode(value);
    } else {
        SLNode* temp = new SLNode(value);
        temp->setNextNode(head);
        head = temp;
    }
    size++;
}

void SList::removeHead() {
    if (head != NULL) {
        head = NULL;
        size--;
    }
}

void SList::clear() {
    head = NULL;
}

unsigned int SList::getSize() const {
    return size;
}

string SList::toString() const {
    stringstream ss;
    if (head != NULL) {
        ss.str("");
    } else {
        int i = 1;
        for (SLNode* n = head; n != NULL; n->getNextNode()) {
            if  (i < (size - 1))
                ss << n->getContents() << ", ";
            ss << n->getContents();
            i++;
        }
    }
    return ss.str();
}

A: If this isn't homework you should drop the homemade list and use a standard container like vector or list.
Example for vector
// vector of string
std::vector<std::string> stringVector;

// add strings
stringVector.push_back("text");
stringVector.push_back("more text");

// iterate all
for (auto& str : stringVector)
{
    // do something with str
    // example:
    std::cout << str;
}

There is a number of standard containers in c++, e.g. vector, list, deque, array. Each have different pros and cons. You need to learn them to write c++


text:
Q: cuRL returnin 404 error I`m using cuRL to get some data from remote server... The response is in JSON format..
This is my code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_URL, 'http://www.myaddress.com/mypage.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, array("id" => $id));
$return = curl_exec($ch);
curl_close($ch);

If I access the link in the browser the page load OK, but if I access through the cuRL return a 404 error...

A: It's possible the server check the HTTP Header, it's the case in the majority of case.
So add the same HTTP Header of your browser, verify with Firebug :
curl_setopt($ch, CURLOPT_HTTPHEADER, array('SomeName: SomeValue'));

A: Probably there is something else the browser is sending your cURL code is not. You can use any of the tools other folks have suggested, Firebug, Wireshark, Fiddler, etc, etc.
What you need to do is add missing pieces to your request to match the browser as closely as possible in the cURL request until the remote page responds with a 200.
I notice you're doing a POST. In many cases what happens with your browser is you visit a page with a GET request. A session is initialized on the remote site and a cookie is saved in your browser with the session id.
This cookie then needs to be supplied along with subsequent POST requests. PHP cURL has many options to support cookies. There may be other requirements such as CSRF tokens and so forth.
Again, reverse-engineering is the key.

A: I can guess a few things that it can be checked from the server side, to show the error.
1) As it is stated in other answers, be sure to set all the necessary headers, you can check them e.g. by firebug, as it is shown in here,

or you can get the headers by php get_headers function.
to set it use
curl_setopt($ch, CURLOPT_HTTPHEADER, array("HeaderName: HeaderValue"));

2) When you open a page in the browser(excluding form submit with post method) it makes a get request, instead of post, so if in the server side it is checked $_GET, then your post request will not be considered.
3) If you sure that it should be a post request(say, it is a form submit), then the following can be a problem: some forms can have hidden fields, that again are being checked in the server, and if they are not set, error can be returned. So, you should look at the source code of the form and add them(if there are any) to your post parameters.
4) if you are submitting a form, be sure to set the submit button with its name and value as well, because similar to hidden fields, this can be checked as well.
5) Cookies can be a problem as well, because by default browser has it , and curl does not. To to able to set and read cookies use this code
// set cookie
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);

// use cookie
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);

here, $cookie_file path to the cookies file. Do not know in linux or mac, but in windows be sure to use absolute path to the cookie file.
6) Also, you can set the referer by
curl_setopt($ch, CURLOPT_REFERER, 'http://www.myaddress.com/mypage.php');

EDIT: In case of ajax request you might want to add a header X-Requested-With with value as XMLHttpRequest


text:
Q: Matlab coneplot meshgrid error MATLAB:griddedInterpolant:NdgridNotMeshgrid3DErrId / not plotting anythin Basically I want to plot a 3D vector field using coneplot in Matlab.
My script looks like this:
data=oommf2matlab('420x350x5-2_5-5.omf');
x=linspace(data.xmin,data.xmax,data.xnodes);
y=linspace(data.ymin,data.ymax,data.ynodes);
z=linspace(data.zmin,data.zmax,data.znodes);
[X,Y,Z]=meshgrid(y,x,z);
scale=4;
angle = data.datay ./ data.datax;
colors = angle;
figure;
coneplot(data.positionx,data.positiony,data.positionz,data.datax,data.datay,data.dataz,X,Y,Z,scale,colors);

oommf2matlab is a function for converting my data into matlab and returns a structure like this:
xmin: 0
ymin: 0
zmin: 0
xmax: 4.2400e-07
ymax: 3.5400e-07
zmax: 1.2500e-08
xnodes: 212
ynodes: 177
znodes: 5
datax: [212x177x5 double]
datay: [212x177x5 double]
dataz: [212x177x5 double]
positionx: [212x177x5 double]
positiony: [212x177x5 double]
positionz: [212x177x5 double]

Running this script gives me an error

Error using interp3 (line 146) Input grid is not a valid MESHGRID.
Error in coneplot (line 144)    ui = interp3(x,y,z,u,cx,cy,cz,method);
Error in omf2cone (line 11)
  coneplot(data.positionx,data.positiony,data.positionz,data.datax,data.datay,data.dataz,X,Y,Z,scale,colors);

If traced the error via debugging to the MATLAB:griddedInterpolant:NdgridNotMeshgrid3DErrId error which looks like this:
identifier:
'MATLAB:griddedInterpolant:NdgridNotMeshgrid3DErrId'

message:
Data is in MESHGRID format, NDGRID format is required.
Convert your data as follows:
P = [2 1 3];
X = permute(X, P);
Y = permute(Y, P);
Z = permute(Z, P);
V = permute(V, P);
F = griddedInterpolant(X,Y,Z,V)
cause: {0x1 cell}
stack: [3x1 struct]

This is strange to me, because interp3 already does what the error suggests as a fix.
Also if I let coneplot generate the mesh itself via:
coneplot(data.datax,data.datay,data.dataz,X,Y,Z,scale,colors);

There is no error, however there is no plot created whatsoever, only the axis of the figure.

A: instead of using meshgrid use griddedInterpolant() instead so that your data is in the format identified in the error.
Also part of your error could be in this line [X,Y,Z]=meshgrid(y,x,z); where instead you want [X,Y,Z]=meshgrid(x,y,z);? This could cause the syntax error you are describing


text:
Q: How to add Table Card in Dialogflow Fulfillment? I've been working on my Dialogflow Fulfillment in my Webhook / Web API and I'm now looking at the Fulfillment Messages part of the response. I've realized it has to be a list of GoogleCloudDialogflowV2IntentMessage.
Looking at the metadata of that class; I see this:

It seems to support all these types of responses:

*

*Basic Card

*Card

*Carousel Select

*Image

*Link Out Suggestion

*List Select

*Payload

*Quick Replies

*Simple Responses

*Suggestions

*Text

When I was working in the Dialogflow Console; if I clicked on 'Add Response' under the 'Google Assistant' responses; there were options that are not directly in this GoogleCloudDialogflowV2IntentMessage class. The option I'm interested in is: 'Table Card'.
How can I make my API return a 'Table Card' as a response?
Can I somehow pass details of a 'Table Card' in the 'Payload' property?
Am I misunderstanding something somewhere along the lines?
Help / Advice appreciated.

A: The TableCard is available for the Google Assistant only. It is not available for other integration types. Using it puts the information in the platform-specific Payload field.
You can put whatever you want in the Payload field - but it won't do you any good unless the platform that is receiving it knows what to do with it.


text:
Q: ANDing the stack pointer I'm working on a computer system exam review question asking for the stack pointer offset at various points in the program, and I'm confused about how the stack frame is set up. I've been learning assembly between 32-bit and 64-bit systems for a couple weeks but I haven't seen an instruction to AND the stack pointer before.
Can someone explain what purpose this serve, what would would be the offset of %esp after fourth instruction, and I calculating %esp correctly? I've commented the code with what I think the value of the offset would be after each instruction.
main:
0x0x0804848a <+0>:  push    %ebp                 ;-0x4
0x0x0804848b <+1>:  mov     %esp, %ebp
0x0x0804848d <+3>:  and     $0xfffffff0, %esp    ;[-0x4, -0x13]
0x0x08048490 <+6>:  sub     $0x20, %esp          ;[-0x24, -0x33]
0x0x08048493 <+9>:  movl    $0xa, 0x1c(%esp)
0x0x0804849b <+17>: movl    $0xa, (%esp)
0x0x080484a2 <+24>: call    0x804841d <r>        ;[-0x28, -0x37]

A: You will be enlightened if you repeat your math with a stack pointer that starts at 0x3.
Alignment. Many CPU types require alignment for best performance or for vector instructions like SSE, to work at all.


text:
Q: Java - OutofMemoryError while reading a huge csv file I want to read a huge csv file by Java. It includes 75,000,000 lines. The problem is, even though I am using maximum xms and xmx limits, i am getting: `java.lang.OutOfMemoryError(GC overhead limit exceeded), and it shows this line causes the error:
String[][] matrix = new String[counterRow][counterCol];

I did some tests and see that i can read 15,000,000 lines well. Therefore I started to use this sort of code:
String csvFile = "myfile.csv";
List<String[]> rowList = new ArrayList();
String line = "";
String cvsSplitBy = ",";
BufferedReader br = null;
try {
    int counterRow = 0, counterCol = 12, id = 0;
    br = new BufferedReader(new FileReader(csvFile));
    while ((line = br.readLine()) != null) {
        String[] object = line.split(cvsSplitBy);
        rowList.add(object);
        counterRow++;
        if (counterRow % 15000000 ==0) {
            String[][] matrix = new String[counterRow][counterCol];
            .. do processes ..
            SaveAsCSV(matrix,id);
            counterRow=0; id++; rowList.clear();
        }
    }
}
...

Here, it writes first 15.000.000 lines very well, but in the second trial, this again gives the same error, although counterRow is 15,000,000.
In summary, I need to read a csv file that includes 75,000,000 rows (approx 5 GB) in Java and save a new csv file or files after doing some processes with its records.
How can I solve this problem?
Thanks
EDIT: I am also using rowList.clear() guys, forgot to specify here. sorry.
EDIT 2: My friends, I dont need to put all file in memory. How can I read it part by part. Actually this is what I tried to do by using  if(counterRow%15000000==0). What is its correct way?

A: You can read the lines individually then do your processing until you have read the entire file
String encoding = "UTF-8";
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("/bigfile.txt"), encoding));
String line;
while ((line = br.readLine()) != null) {
   // process the line.
}
br.close();

this should not go fubar just make sure you proces it immediatly and don't store it in variables outside your loop

A: The issue is not that you do not have enough memory, the issue "GC overhead limit exceeded" means that the garbage collection is taking too long. You cannot fix this by allocating more memory, but only by using -XX:-UseGCOverheadLimit. That is, if you really want that much data in memory.
See e.g. How to solve "GC overhead limit exceeded" using maven jvmArg?
Or use peter lawrey's memory-mapped HugeCollections: http://vanillajava.blogspot.be/2011/08/added-memory-mapped-support-to.html?q=huge+collections : It writes to disk if the memory is full.

A: Maybe you forgot to call
rowList.clear();

after
counterRow=0; id++;

A: The "java.lang.OutOfMemoryError: GC overhead limit exceeded" error will be displayed when your application has exhausted pretty much all the available memory and GC has repeatedly failed to clean it.
The solution recommended above - specifying a -XX:-UseGCOverheadLimit is something I strongly suggest not to do. Instead of fixing the problem you are just postponing the inevitable: the application is running out of memory and needs to be fixed. Specifying this option just masks the original "java.lang.OutOfMemoryError: GC overhead limit exceeded" error with a more familiar message "java.lang.OutOfMemoryError: Java heap space".
Possible solutions pretty much boil down to two reasonable alternatives in your case - either increase heap space (-Xmx parameter) or reduce the heap consumption of your code by reading the file in smaller batches.


text:
Q: how to understand this JavaScript code output? let { length } = "hello app"
console.log(length) //=> 9

why the output of console.log is 9(it seems like string's length)?  Actually, I can't understand the syntax of first line.


text:
Q: passing value to method in jquery coundown plugin I'm using jquery countdown plugin with the following code.
$('#countbox').countdown({

layout:'<b>{d<}{dnn}:{d>}'+
    '{hnn}: {mnn} : {snn} </b>',
timeSeparator: ':',
onExpiry: sold,
onTick: highlight,
serverSync: serverTime

});
function serverTime(pid) {
    var time = null;
    $.ajax({
        url: 'ajax_countdown',
        async: false,
        data: ({pid:pid}),
        dataType: 'text',
        success: function(text) {
            time = new Date(text);
        },
         error: function(http, message, exc) {
            time = new Date();
    }});
    alert(time);
    return time;
}

Question 1: using this I'm calling the function serverTime and I want to pass the value pid to the method. How do I achieve this ?

Question 2 is related to the javascript Date function
$d4 ="2011,01-1,11,23,31,32";
alert(new Date(<?php echo $d4; ?>));

when I run the above code I get following result

Tue Jan 11 2011 23:31:32 GMT+0530
  (India Standard Time)

But, the ajax call (as above) also returns the same result, yet in this case when I alert, I receive the following response

Invalid Date
alert(time);

Why is this different in the second case and how can I alter my code to receive my desired behaviour?

A: The "alert" fires before the ajax answer returns... include it into the success function... or call a function from success..
function serverTime(pid) {
    var time = null;
    $.ajax({
        url: 'ajax_countdown',
        async: false,
        data: ({pid:pid}),
        dataType: 'text',
        success: function(text) {
            time = new Date(text);
            alert(time);
            return time;
        },
         error: function(http, message, exc) {
            time = new Date();
    }});
}

A: i got answer myself for this
Question 1: using this i 'm calling function serverTime . here i want to pass the value pid to the method.how to do this ?
The code snippet not yet tested but i hope it will work.
 $('#countbox').countdown({

    layout:'<b>{d<}{dnn}:{d>}'+
        '{hnn}: {mnn} : {snn} </b>',
    timeSeparator: ':',
    onExpiry: sold,
    onTick: highlight,
    serverSync: function() { serverTime(pid); }

    });

function serverTime(pid) {
    alert(pid);

}


text:
Q: Bot confirmation after user reacts not displaying in Discord.js I want the user to answer a "yes or no" question using reactions. However, there is a bug in which when the tagged user reacts to the question, the bot is not sending a message on whether or not the tagged user wants to negotiate. Here is my code below.
     const yesEmoji = '✅';
        const noEmoji = '❌';
        client.on('message', (negotiate) => {
            const listen = negotiate.content;
            const userID = negotiate.author.id;
            var prefix = '!';
            var negotiating = false;
            let mention = negotiate.mentions.users.first();

            if(listen.toUpperCase().startsWith(prefix + 'negotiate with '.toUpperCase()) && (mention)) {
                negotiate.channel.send(`<@${mention.id}>, do you want to negotiate with ` + `<@${userID}>`)
                .then(async (m) => {
                    await m.react(yesEmoji);
                    await m.react(noEmoji);

                    //get an answer from the mentioned user
                    const filter = (reaction, user) => user.id === mention.id;
                    const collector = negotiate.createReactionCollector(filter);
                    collector.on('collect', (reaction) => {
                         if (reaction.emoji.name === yesEmoji) {
                              negotiate.channel.send('The mentioned user is okay to negotiate with you!');

                         }
                         else {
                              negotiate.channel.send('The mentioned user is not okay to negotiate with you...')
                         }
                    })
                })
                negotiating = true;
            }
        })

So far, the code displays the reaction but it does not make the bot send a message whether the tagged user is ok or not ok to negotiate with the user that tagged them.

UPDATE:
I managed to get the bot to send a message whether the tagged user is ok or not ok to negotiate with the user that tagged them. Now there is an error in which is shown after 10 seconds (specified time). Here is the updated code below:
const yesEmoji = '✅';
const noEmoji = '❌';

client.on("message", async negotiate => {
    const listen = negotiate.content;
    let mention = negotiate.mentions.users.first();
    if(listen.toUpperCase().startsWith(prefix + 'negotiate with '.toUpperCase()) && (mention)) {
        let mention = negotiate.mentions.users.first();
        let msg = await negotiate.channel.send(`${mention} do you want to negotiate with ${negotiate.author}`);
        var negotiating = false;

        await msg.react(yesEmoji);
        await msg.react(noEmoji);

        const filter = (reaction, member) => {
        return reaction.emoji.name === yesEmoji || reaction.emoji.name === noEmoji && member.id === mention.id;
        };

        msg.awaitReactions(filter, { max: 1, time: 10000, errors: ['time'] })
        .then(collected => {
            const reaction = collected.first();
            if (reaction.emoji.name === yesEmoji) {
            negotiating = true;
            negotiate.reply('The mentioned user agreed to negotiate with you!');
            }
            else return negotiate.reply('The mentioned user did not agree to negotiate with you.')
        })
    }
})

A: I have a much easier solution to your problem:
    const yesEmoji = '✅';
    const noEmoji = '❌';

    let mention = negotiate.mentions.users.first();
    if(mention.id === negotiate.author.id) return message.channel.send("You cannot tag yourself!");
    let msg = await negotiate.channel.send(`${mention} do you want to negotiate with ${negotiate.author}`);
    var negotiating = false;

    await msg.react(yesEmoji);
    await msg.react(noEmoji);

    const filter = (reaction, member) => {
      return (member.id === mention.id && reaction.emoji.name === yesEmoji) || (member.id === mention.id && reaction.emoji.name === noEmoji);
    };

    msg.awaitReactions(filter, { max: 1, time: 10000, errors: ['time'] })
      .then(collected => {
        const reaction = collected.first();
        if (reaction.emoji.name === yesEmoji) {
          negotiating = true;
          negotiate.channel.send('The mentioned user is okay to negotiate with you!');
        }
        else if (reaction.emoji.name === noEmoji) return negotiate.channel.send('The mentioned user is not okay to negotiate with you...')
      }).catch(err => {
        if(err) return message.channel.send(`${mention} did not react within the 10 seconds!`);
      })

So first we got the two emojis, we want the user to react with. mention is our mentioned user, msg is the "yes or no" question and negotiating is set to false by default. At first we react to the question with our emojis. In this example I am using awaitReactions, because it is very simple to use. For this we need a filter. In this case I named the variable also filter. filter checks if the reaction wether is yesEmoji or noEmoji and if the user who reacted is mention (our mentioned user). Then in awaitReactions we want only 1 reaction (yes or no), and I set the time to 10 seconds, but you can change it if you want. After awaitReactions is set up we want to collect our reaction. This is done in .then(). collected gives us the reactions, and we only want the first one, so we store collected.first() in reaction. Now we have a really simple if-else statement. If the reacted emoji is yesEmoji, negotiating will be set to true and a message gets sent into the channel, otherwise it will only sent a message and return.
It is important to set negotiating only to true if the user reacted with yesEmoji. In your code it is true even if nothing happens, because as you run the command everything in that command code will be executed. and your last line there was negotiating = true;. And I think that is not what you wanted to do.


text:
Q: Fixed Width Font with LTXexample environment Not sure why this problem has eluded me but I can't seem to get fixed width font in the code portion.  I thought that this question on how to change code font would do the trick but it doesn't for me.
The following code for me produces non-aligned output (the & are not aligned in the code):
    \documentclass{article}

    \usepackage{amsmath}
    \usepackage{showexpl}
    \usepackage{xcolor}

    \usepackage{multirow} % Newly added for 2nd example.

    \lstset{
        backgroundcolor=\color{yellow},
        basicstyle=\small\ttfamily,% print whole listing small
        keywordstyle=\color{blue}\bfseries\underbar,
        numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt,
        %columns=fixed,
        %commentstyle=\color{red},
        showstringspaces=false
    }
    \lstloadlanguages{[LaTeX]TeX}

    \begin{document}
    Here is an example of LaTeX code and its output:

    \begin{LTXexample}[width=0.40\linewidth,preset=\vspace{1.5mm}]
    \begin{alignat*}{4}
        y &= -4   &+ 3 &+4     &-7      \\
        y &=      &+ 3 &       &-7      \\
        \intertext{Therefore}
        a &= b    &d   &= cccc &e  &= d \\
        a &= bbbb &d   &= c    &e  &= d
    \end{alignat*}
    \end{LTXexample}

    \begin{LTXexample}[width=0.40\linewidth,preset=\vspace{1.5mm},rframe={},pos=b]
    \begin{tabular}{|l|l|l|l|}
    \multicolumn{4}{c}{Dimensions} \\
    \multirow{4}{*}{Style}
            &\multirow{2}{*}{Portrait} & Width  \\
            &                          & Height \\
            &\multirow{2}{*}{Landscape}& Width  \\
            &                          & Height \\
    \end{tabular}
    \end{LTXexample}
    \end{document}

A: you should use a good looking typewriterfont like `beramono'
 \documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[scaled=0.82]{beramono}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{showexpl}
\usepackage{xcolor}
\usepackage{multirow} % Newly added for 2nd example.
\lstset{
     backgroundcolor=\color{yellow},
     basicstyle=\small\ttfamily\SetTracking{encoding=*}{-60}\lsstyle,
     basewidth=0.55em,
     keywordstyle=\color{blue}\bfseries\underbar,
    numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt,
    %columns=fixed,
        %commentstyle=\color{red},
        showstringspaces=false}
    \lstloadlanguages{[LaTeX]TeX}

\begin{document}
Here is an example of LaTeX code and its output:

\begin{LTXexample}[width=0.40\linewidth,preset=\vspace{1.5mm}]
\begin{alignat*}{4}
   y &= -4   &+ 3 &+4     &-7      \\
   y &=      &+ 3 &       &-7      \\
   \intertext{Therefore}
   a &= b    &d   &= cccc &e  &= d \\
   a &= bbbb &d   &= c    &e  &= d
\end{alignat*}
\end{LTXexample}

\begin{LTXexample}[width=0.40\linewidth,preset=\vspace{1.5mm},rframe={},pos=b]
\begin{tabular}{|l|l|l|l|}
\multicolumn{4}{c}{Dimensions} \\
\multirow{4}{*}{Style}
        &\multirow{2}{*}{Portrait} & Width  \\
        &                          & Height \\
        &\multirow{2}{*}{Landscape}& Width  \\
        &                          & Height \\
\end{tabular}
\end{LTXexample}
\end{document}

A: The problem is that the default setting of listings with "fixed columns" has a space 0.6em wide, while the characters in Computer Modern Typewriter are 0.5em wide. So you need only to add the options
columns=fixed,basewidth=.5em,

to \lstset.
One can do without knowing the character width by saying something like
\sbox0{\small\ttfamily A}
\edef\mybasewidth{\the\wd0 }
\lstset{
    basicstyle=\small\ttfamily,% print whole listing small
    columns=fixed,basewidth=\mybasewidth,
    ...}


text:
Q: ClassNotFoundException on Maven Dependency Class org.apache.http.client I'm trying to build a simple API client, which uses org.apache.httpfor connecting to the API server. Locally everything works fine. I'm successfully connecting to the server and receive the data I want.
But, when I deploy my application to the server. I'm getting following exception:
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.ClientProtocolException from [Module "deployment.adobe-livecycle-jboss.ear:main" from Service Module Loader]
I tried multiple different variants of versions of my depencies. Right now im using the following:
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
    <version>4.4.3</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.1</version>
    <scope>compile</scope>
</dependency>

Both of the JARs appear in my Java Build Path, also the class which is "missing" is found in there.
Even when I build the project and search the JAR files libs folder, I can find the class...
I know there are some solutions to find online but none of them helped me.

A: This is probably caused by a faulty maven local repository. Try looking for your maven local repository (It's generally a hidden folder like named.m2\repository), delete the folder org\apache\httpcomponents then clean compile your project.

Edit:
After further explanation of the problem, it seems that this is a deployment issue not a build one.
If it's the first time that you use this package in your build, then this package's jar must be defined somewhere in the deployment server, it seems that you are deploying in an Adobe environment which seems to be based on JBoss because of that line of log that you provided
[Module "deployment.adobe-livecycle-jboss.ear:main" from Service Module Loader]

Make sure to read the documentation of that environment on how to configure and define external modules.


text:
Q: multi select with check boxes using reactjs hi iam trying to implement multiselect with checkboxes(for each value populated in should proceed by check box for selecting the value).
when i am trying with simple select, all the list of values are displaying as expected.( nthis is for confirmation that the list of values are being populated to view from the controller as expected). while iam replacing the select with multi select tag the list of values are not getting populated in the box, instead nothing is coming in the box. please help me with the exact code.
similar example with bootstap is given in the below link.https://github.com/skratchdot/react-bootstrap-multiselect/pulls

A: Try sending data in this format [{value: 'one', selected: true}, {value: 'two'}]


text:
Q: Zend - Losing post values in Mapper I seem to be losing my post data when passing it from my Controller to my Mapper to insert into my DB. I'm new to this and using the Guestbook template but modified it to be adding a "deal". This is what I have:
Controller
public function newAction()
    {
      $request = $this->getRequest();

      $form    = new Application_Form_Deal();

      if ($this->getRequest()->isPost()) {

            if ($form->isValid($request->getPost())) {

                $posts = $form->getValues();
                //print_r($posts);
                $newdeal = new Application_Model_Deal($posts);
                $mapper  = new Application_Model_DealMapper();
                $mapper->save($newdeal);
                return $this->_helper->redirector('index');
            }
        }

        $this->view->form = $form;
    }

This is my Mapper
public function save(Application_Model_Deal $deal)
        {

            $data = array(
                'dealname'      => $deal->getDealName(),
                'dealclient'    => $deal->getDealClient(),
                'dealtelephone' => $deal->getDealTelephone(),
                'dealvalue'     => $deal->getDealValue(),
                'dealdescription' => $deal->getDealDescription(),
                'dealcreated'   => date('Y-m-d H:i:s'),
                'dealmodified'  => date('Y-m-d H:i:s'),
            );

            /*echo "<pre>";
            print_r($data);
            echo "</pre>";
            exit();*/

             if (null === ($dealid = $deal->getDealId())) {
                unset($data['dealid']);
                $this->getDbTable()->insert($data);
            } else {
                $this->getDbTable()->update($data, array('dealid = ?' => $dealid));
            }
        }

protected $_dealmodified;
    protected $_dealcreated;
    protected $_dealdescription;
    protected $_dealvalue;
    protected $_dealtelephone;
    protected $_dealclient;
    protected $_dealname;
    protected $_dealid;

    public function __construct(array $options = null)
    {
        if (is_array($options)) {
            $this->setOptions($options);
        }
    }

    public function __set($name, $value)
    {
        $method = 'set' . $name;
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Invalid deal property');
        }
        $this->$method($value);
    }

    public function __get($name)
    {
        $method = 'get' . $name;
        if (('mapper' == $name) || !method_exists($this, $method)) {
            throw new Exception('Invalid deal property');
        }
        return $this->$method($value);
    }

    public function setOptions(array $options)
    {
        $methods = get_class_methods($this);
        foreach ($options as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (in_array($method, $methods)) {
                $this->$method($value);
            }
        }
        return $this;
    }

     public function setDealModified($ts)
    {
        $this->_dealmodified = $ts;
        return $this;
    }

    public function getDealModified()
    {
        return $this->_dealmodified;
    }

    public function setDealCreated($ts)
    {
        $this->_dealcreated = $ts;
        return $this;
    }

    public function getDealCreated()
    {
        return $this->_dealcreated;
    }

    public function setDealDescription($text)
    {
        $this->_dealdescription = (string) $text;
        return $this;
    }

    public function getDealDescription()
    {
        return $this->_dealdescription;
    }

    public function setDealValue( $text)
    {
        $this->_dealvalue =  $text;
        return $this;
    }

    public function getDealValue()
    {
        return $this->_dealvalue;
    }

    public function setDealTelephone($text)
    {
        $this->_dealtelephone = $text;
        return $this;
    }

    public function getDealTelephone()
    {
        return $this->_dealtelephone;
    }

    public function setDealClient($text)
    {
        $this->_dealclient = $text;
        return $this;
    }

    public function getDealClient()
    {
        return $this->_dealclient;
    }

    public function setDealName($text)
    {
        $this->_dealname = $text;
        return $this;
    }

    public function getDealName()
    {
        return $this->_dealname;
    }

    public function setDealId($dealid)
    {
        $this->_dealid = (int) $dealid;
        return $this;
    }

    public function getDealId()
    {
        // $this->_dealid = (int) $value;
        return $this->_dealid;
    }

I am a complete loss as to why, when I print_r my $data var in the Mapper everything is gone.
Please help!

A: Your save() method in the mapper does not have a second argument which you used as your $post parameter.
Refactor:
public function save(Application_Model_Deal $deal, array $post)...

A: This looks odd $mapper->save($newdeal, $posts);
your api is save(Application_Model_Deal $deal)
so it should read $mapper->save($newdeal);.
if you really want to get a handle on mappers and models, these three links helped me alot:
http://survivethedeepend.com/
http://phpmaster.com/building-a-domain-model/
http://phpmaster.com/integrating-the-data-mappers/
You are after a specific work flow :

*

*present form

*collect from data (the $post)

*validate $post data (if(isValid())

*get valid and filtered form values ($form->getValues())

*instantiate your deal object ($newdeal = new Application_Model_Deal($posts);)

*save/update your deal with your mapper

*on success redirect

once your deal object is created the $post data has no further value and the deal object is the important thing to think about. Hope this helps a bit.
Ok I think I found it:
your problem revolves around this $method = 'set' . ucfirst($key); this line will try and call $this->setProperty(); your getters and setters are set up camel case so they won't work. The easiest way to fix this is to rename your getters and setters to:
 public function setDealmodified($ts)//not camel cased only first letter is capped.
    {
        $this->_dealmodified = $ts;
        return $this;
    }

or you have to camel case your array keys.


text:
Q: How can I attach an html5 file on outlook without changing it's encoding? I'm trying to send an email with an html5 file attached to it. The problem is that when I open the file with Outlook, the encoding changes from utf-8 to another configuration, once it has some text in brazilian portuguese written in the file it's very important to have the proper encoding.
Is it possible to solve this issue?
Thanks in advance!


text:
Q: DOM-like APIs for HTML string content inside a web worker  Is there any library that could help with html string manipulation inside a web worker ?
What I'd like to be able to do is, inside a worker, have sizzle-type selector tool that would allow me to do things like:
hString = "

"
imgSrc  = $(hString).find("img").attr("src")   // foo

, without the DOM interaction.

A: What you basically want is a pure Javascript DOM implementation on which top you could run jQuery and fellows
One such implementation exists for Node.js
https://github.com/tmpvar/jsdom
It can spoof DOM window object, APIs and such.
You could take the code, rip off the Node dependencies and try to apply jQuery on the top of that inside a web worker.


text:
Q: EventBus, register and registerSticky method I use greenrobot EventBus library to send data between two fragments in my android app and I want to know what is the diffeence between register(Object b) method and registerSticky(Object object) method?

A: EventBus allows you to post events that are "sticky" and by that EventBus understands events that "stick to the eventbus" for future access.
If you post a normal event when there are no subscribers registered at the moment of sending, this event will be discarded.
You can post a sticky event though, even if there are no subscribers to receive that at the moment, and it won't be discarded (unless there is another sticky event posted in the future). When a subscriber registers with registerSticky the delivery of the last sticky event is also triggered.


text:
Q: Cross origin iframe, Safari-only issue On domain www.maindomain.com I have the following page
<iframe src='https://www.otherdomain.com/somepage.php' />

The IIS webserver that hosts www.otherdomain.com has been properly configured with the necessary cross-origin headers.
In fact, there's no issue with any of the major browsers, desktop and mobile.
However, on Safari and on Safari only, the connection is rejected as insecure.
Is there a known workaround?
Thanks


text:
Q: make x y work the same on all devices android studio I just began to develop a app with java, and I only got some experience in C. In my code in Activity.java (in android studio) I got things like, just to give some examples:
    meteorite1.setX(meteoritePlacementX(meteorite1.getX()));
    meteorite1.setY(-2000);
    gnome.setX(330);
    gnome.setY(800);
    meteorite2.setX(meteoritePlacementX(meteorite2.getX()));
    meteorite2.setY(meteoritePlacementY(meteorite1.getY()));
    meteorite3.setX(meteoritePlacementX(meteorite3.getX()));
    meteorite3.setY(meteoritePlacementY(meteorite2.getY()));
    meteorite4.setX(meteoritePlacementX(meteorite4.getX()));
    meteorite4.setY(meteoritePlacementY(meteorite3.getY()));
    meteorite5.setX(meteoritePlacementX(meteorite5.getX()));
    meteorite5.setY(meteoritePlacementY(meteorite4.getY()));

    meteoritedestruction1.setX(0);
    meteoritedestruction1.setY(-2000);
    meteoritedestruction2.setX(0);
    meteoritedestruction2.setY(-2000);
    meteoritedestruction3.setX(0);
    meteoritedestruction3.setY(-2000);
    meteoritedestruction4.setX(0);
    meteoritedestruction4.setY(-2000);
    meteoritedestruction5.setX(0);
    meteoritedestruction5.setY(-2000);

    star1.setX(300);
    star2.setX(150);
    star3.setX(50);
    star4.setX(500);
    star5.setX(600);
    star6.setX(350);
    star7.setX(80);
    star8.setX(450);
    tinystar1.setX(302);
    tinystar2.setX(240);
    tinystar3.setX(57);
    tinystar4.setX(660);
    tinystar5.setX(400);

    star1.setY(300);
    star2.setY(-300);
    star3.setY(-100);
    star4.setY(100);
    star5.setY(300);
    star6.setY(500);
    star7.setY(700);
    star8.setY(900);
    tinystar1.setY(300);
    tinystar2.setY(-400);
    tinystar3.setY(-200);
    tinystar4.setY(150);
    tinystar5.setY(30);

and
public float meteoritePlacementX(float X){

    float MeteoriteNewX = 0f;

    int random = (int )(Math.random() * 480 - 50);

    MeteoriteNewX = random;

    return MeteoriteNewX;
}

Which workes fine, but just on my phone (720 x 1280 pixels (~294 ppi pixel density)) which I tested my code at. Now I published my app, but on other device, the layout of the app is totally out of sync (which makes sense to me now, cause x and y are different for every screen). Buttons and pictures workes fine, but moving object like
meteorite1.setY(meteorite1.getY() + 20);

where I use x and y are broken on other devices. I use the relative layout.
So long story short; Is there a way to change x and y, so it becomes relative to the screen? Otherwise I need to change the whole code.

A: In general using placement based on hard coded pixel values is not a good practice. Not only would this break with backwards compatibility but also think about what you would have to do when 2k+ phones come out, you would need an entire refactor. Look at this question and the answer by Guillaume Perrot you can get get the maximum and minimum pixel values relative to the user's phone and use those instead of the 480 - 50 and your star set functions.
For the movement do
DisplayMetrics displayMetrics = new DisplayMetrics();
WindowManager wm = (WindowManager)getApplicationContext().getSystemService(Context.WINDOW_SERVICE); // the results will be higher than using the activity context object or the getWindowManager() shortcut
wm.getDefaultDisplay().getMetrics(displayMetrics);
int maxWidth = displayMetrics.widthPixels;
//Make this percentage whatever you want
float movementPercentage = 0.02
//Will move the object 2 percent up the y axis
meteorite1.setY(meteorite1.getY() + maxWidth*movementPercentage);


text:
Q: Days Calculation Method (using ZK and MVVM) Well, well, step by step i'm chaining all my doubts about ZK framework and MVVM pattern on a simple series of questions, if someone is interested:
Selected Item data from a table to textbox in ZK
Textbox Enabling in ZK
Now, with all the data correctly binded, i decided to play around with the date of my form. So the idea is when i choose a date, it calculates the days with a operation and show it in another textbox, here is the code:
.zul File
 <datebox id="" format="medium" onCreate="" value="@bind(vm.fechaIngreso)" width="100%"
 onSelect="@command('calcularDias')" mold="rounded" readonly="true" constraint="no empty, no future"
 disabled="@load(empty vm.camaPaciente)"/>

Command on Viewmodel
@Command
@NotifyChange({"fechaIngreso"})
public void calcularDias(){
  long milisegundosPorDia = 24 * 60 * 60 * 1000;
  java.util.Date hoy = new Date();
  long tmp = (hoy.getTime() - this.getFechaRegistro().getTime())/milisegundosPorDia;
  this.setDiasEstancia((int)tmp);
}

where "hoy" = today date and getFechaRegistro = registration date, it suppose it has to calculate the number of days in another textbox, but it doesn't work. Maybe is a binding problem or a calculation problem. i appreciate any suggestion of solution to my problem. Thank you very much.

A: *

*I suppose your textbox is bound to the diasEstancia property? then
you should let the command notify a change of that value:
@NotifyChange({"diasEstancia"})

*You don't use the property fechaIngreso (which is bound to your datebox)  to calculate the day difference, but you use this.getFechaRegistro() which is not changed as far as I see from the code posted. Therefore, the value in diasEstancia never changes (at one day).


text:
Q: Navigation drawer icons (hamburger & arrow) animation when expand action view I'm using AppCompat and Toolbar.
I ensure there will be animation, when the navigation drawer icon transits from hamburger to arrow, or vice-verse.
I use the following technique https://stackoverflow.com/a/26469738/72437
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    </style>

    <style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
        <item name="spinBars">true</item>
        <item name="color">@android:color/white</item>
    </style>

</resources>

Animation happens when I press the navigation drawer, to slide in & slide out the menu. However, it isn't very useful. As according to material design guideline, the navigation drawer fragment should be full height. Hence, it will block the navigation drawer icon, when it starts to slide out.
I'm more interested to perform animation, when dealing with my search button (action_search), which acts as action view of my toolbar.
main_menu.xml

<item android:id="@+id/action_search"
    android:title="Search me"
    android:icon="@drawable/ic_add_white_24dp"
    app:showAsAction="always|collapseActionView"
    app:actionLayout="@layout/collapsible_searchtext" />

<item android:id="@+id/action_settings" android:title="@string/action_settings"
    android:orderInCategory="100" app:showAsAction="never" />

collapsible_searchtext.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    >
    <android.widget.AutoCompleteTextView
        android:id="@+id/search"
        android:dropDownWidth="match_parent"
        android:completionThreshold="1"
        android:inputType="textNoSuggestions"
        android:imeOptions="actionSearch|flagNoExtractUi"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:singleLine="true"
        android:hint="Search stock"
        android:layout_gravity="center_vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</RelativeLayout>

*

*When I press action_search, the search icon will expand to AutoCompleteTextView. At the same time, hamburger icon will animate to arrow icon

*When I press arrow icon, arrow icon will animate back to hamburger icon.

I try to achieve objective 1, by using the following code after reading https://stackoverflow.com/a/26480439/72437
private void animateHamburgerToArrow() {
    ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float slideOffset = (Float) valueAnimator.getAnimatedValue();
            actionBarDrawerToggle.onDrawerSlide(drawerLayout, slideOffset);
        }
    });
    anim.setInterpolator(new DecelerateInterpolator());
    // You can change this duration to more closely match that of the default animation.
    anim.setDuration(500);
    anim.start();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }

    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        animateHamburgerToArrow();
        return true;
    } else if (id == R.id.action_search) {
        animateHamburgerToArrow();
        return true;
    }

    return super.onOptionsItemSelected(item);
}

When I press action_search, hamburger icon does change to arrow icon. However, there's no animation. May I know is there anything I had missed?
Update
I suspect that, the left arrow used by navigation drawer, is different from the left arrow used by search action view. They are 2 different instances.
This is because if I click action_settings, I can observe the animation. However, if I click action_search, I will not observe the animation. I suspect the left arrow used by search action view, "block" navigation drawer's icons (both hamburger & arrow)

A: I achieved this effect without unrolling my own custom SearchView.
The thing is, there are really two separate buttons for burger and back arrow. So, while we can access the burger button with the public method setHomeAsUpIndicator(), the back button can only be reached with reflection. Then we just set the desired drawable on it as well, and play the animation on both button drawables simultaneously irrespective of whether the specific button is visble or not. This works as both buttons are positioned exactly in the same position in the layout.
For details see the post http://choruscode.blogspot.com/2015/09/morphing-animation-for-toolbar-back.html


text:
Q: AngularFire firestore not getting fresh written document I have a cloud functions that writes a user document, for example an access token
Then after that function is called and awaited I do a get to read the document.
However, the document read is old.
The cloud function writes the document like this:
    await admin.firestore().collection('garminHealthAPITokens').doc(userID).set({

    oauthToken: urlParams.get('oauth_token'),
    oauthTokenSecret: urlParams.get('oauth_token_secret'),
    state: crypto.randomBytes(20).toString('hex')
  })

  // Send the response wit hte prepeared stuff to the client and let him handle the state etc
  res.send({
    redirect_url: REQUEST_TOKEN_CONFIRMATION_URI,
  })

Here is part of the code on the client side that:
const redirectURI = await this.userService.getCurrentUserGarminHealthAPIRedirectURI(); // Function updates token
              // This doesn't return the written token of the above but rather an older (prev) one
              const token = await this.userService.getGarminHealthAPITokenAsPromise(this.user);

Here is how I call the the AngularFire document get
public async getGarminHealthAPITokenAsPromise(user: User): Promise<{oauthToken: string, oauthTokenSecret: string, state: string}> {
    return this.afs
      .collection('garminHealthAPITokens')
      .doc(user.uid)
      .get({source: 'server'})
      .pipe(catchError(error => {
        return [];
      }))
      .pipe(take(1))
      .pipe(map((doc) => doc.data()))
      .toPromise();
  }

There is an explicit get from the server there but the results are not fresh
What am I missing?


text:
Q: Database table creation dates 'self changed' I noticed today that a MySQL database I was working on had table creation dates only two days ago. They were actually created years earlier.
It quickly became apparent that the very recent creation date also matches down to the mili-second creation times for many tables across multiple databases on our server. Searching for what had taken place on the server at that specific time, I found that Plesk updated itself at that precise time.
If you're not familiar with it, Plesk is similar to cPanel. It helps manage everything from domain setup, down to creating databases. In that sense, it has rights to much of the server resources.
Is it typical that updating Plesk / cPanel, or other hosting management consoles with access to create databases resets table creation dates? Or, was this a poorly implemented Plesk update, and I should normally be able to trust the table creation date?


text:
Q: Java: round unix time (Long) to first day of the month I'm trying to round a unix time to the first day of the month in Java, but without success. Example:

1314057600 (Tue, 23 Aug 2011 00:00:00 GMT)

to

1312156800 (Mon, 01 Aug 2011 00:00:00 GMT)

The unix time I'm reading from a file and storing it as a Long inside a variable (variable named "valor").
So far I've been able to create a Java timestamp with it
LocalDateTime timestamp = LocalDateTime.ofInstant(Instant.ofEpochSecond(valor), ZoneId.systemDefault());

and create a new timestamp for the beggining of the month:
LocalDate key = LocalDate.of(timestamp.getYear(), timestamp.getMonthValue(), 1);

How do I get this new timestamp as a Long?

A: Something like this sounds like it would work:
key.atStartOfDay().atZone(ZoneId.systemDefault()).toEpochSecond()

(Assuming you want it in the system's default timezone).