Optimizing Apache

Question: I've been reading multiple optimization guide for apache and found a lot of data (Although I have no idea what is the experience of the authors).
I have a production server with apache 2.2.3, MySQL 5.1.36, Centos 5.3, nginx to act as a reverse proxy server (and handle the static files).
My main problem is I have around 10 processes of httpd each taking up to 56-60MB RAM, and every 15 minutes I fire 10 php processes via a crond (each taking up 30MB aswell).
Basically I am operating with the default httpd.conf (yeah I know, this is bad), I have just tweaked the MPM max clients and other properties controlling how many clients shoudld be forked, and installed nginx to reduce load on apache.
I'd be happy what kind of optimization I could do to my httpd (I know I should be unloading lot of modules but I'm kinda scared than removing something could break my application).
<code>21969 root      16   0  145m  30m 6872 S  1.3  0.9   0:00.75 php
 6031 apache    16   0  289m  59m  35m S  1.0  1.3   0:05.01 httpd
</code>
Another output for one of the process I am running:
<code>[root@www /]# pmap -d 6031
6031:   /usr/sbin/httpd
Address           Kbytes Mode  Offset           Device    Mapping
00002b8b622e4000     308 r-x-- 0000000000000000 008:00003 httpd
00002b8b62331000     100 rw-s- 0000000000000000 000:00023   [ anon ]
00002b8b6234a000      32 rw-s- 0000000000000000 000:00023   [ anon ]
00002b8b62531000      16 rw--- 000000000004d000 008:00003 httpd
00002b8b62535000      12 rw--- 00002b8b62535000 000:00000   [ anon ]
00002b8b62538000     112 r-x-- 0000000000000000 008:00003 ld-2.5.so
00002b8b62554000       4 rw--- 00002b8b62554000 000:00000   [ anon ]
00002b8b6255a000       4 rw--- 00002b8b6255a000 000:00000   [ anon ]
00002b8b62753000       4 r---- 000000000001b000 008:00003 ld-2.5.so
00002b8b62754000       4 rw--- 000000000001c000 008:00003 ld-2.5.so
00002b8b62755000     520 r-x-- 0000000000000000 008:00003 libm-2.5.so
00002b8b627d7000    2044 ----- 0000000000082000 008:00003 libm-2.5.so
00002b8b629d6000       4 r---- 0000000000081000 008:00003 libm-2.5.so
00002b8b629d7000       4 rw--- 0000000000082000 008:00003 libm-2.5.so
00002b8b629d8000     108 r-x-- 0000000000000000 008:00003 libpcre.so.0.0.1
00002b8b629f3000    2048 ----- 000000000001b000 008:00003 libpcre.so.0.0.1
00002b8b62bf3000       4 rw--- 000000000001b000 008:00003 libpcre.so.0.0.1
00002b8b62bf4000      84 r-x-- 0000000000000000 008:00003 libselinux.so.1
00002b8b62c09000    2048 ----- 0000000000015000 008:00003 libselinux.so.1
00002b8b62e09000       8 rw--- 0000000000015000 008:00003 libselinux.so.1
00002b8b62e0b000       8 rw--- 00002b8b62e0b000 000:00000   [ anon ]
00002b8b62e0d000     112 r-x-- 0000000000000000 008:00003 libaprutil-1.so.0.2.7
00002b8b62e29000    2044 ----- 000000000001c000 008:00003 libaprutil-1.so.0.2.7
00002b8b63028000       8 rw--- 000000000001b000 008:00003 libaprutil-1.so.0.2.7
00002b8b6302a000      36 r-x-- 0000000000000000 008:00003 libcrypt-2.5.so
00002b8b63033000    2044 ----- 0000000000009000 008:00003 libcrypt-2.5.so
00002b8b63232000       4 r---- 0000000000008000 008:00003 libcrypt-2.5.so
00002b8b63233000       4 rw--- 0000000000009000 008:00003 libcrypt-2.5.so
00002b8b63234000     184 rw--- 00002b8b63234000 000:00000   [ anon ]
00002b8b63262000     224 r-x-- 0000000000000000 008:00003 libldap-2.3.so.0.2.31
00002b8b6329a000    2048 ----- 0000000000038000 008:00003 libldap-2.3.so.0.2.31
00002b8b6349a000       8 rw--- 0000000000038000 008:00003 libldap-2.3.so.0.2.31
00002b8b6349c000       4 rw--- 00002b8b6349c000 000:00000   [ anon ]
00002b8b6349d000      52 r-x-- 0000000000000000 008:00003 liblber-2.3.so.0.2.31
00002b8b634aa000    2048 ----- 000000000000d000 008:00003 liblber-2.3.so.0.2.31
00002b8b636aa000       4 rw--- 000000000000d000 008:00003 liblber-2.3.so.0.2.31
00002b8b636ab000     964 r-x-- 0000000000000000 008:00003 libdb-4.3.so
00002b8b6379c000    2044 ----- 00000000000f1000 008:00003 libdb-4.3.so
00002b8b6399b000      20 rw--- 00000000000f0000 008:00003 libdb-4.3.so
00002b8b639a0000     128 r-x-- 0000000000000000 008:00003 libexpat.so.0.5.0
00002b8b639c0000    2044 ----- 0000000000020000 008:00003 libexpat.so.0.5.0
00002b8b63bbf000      12 rw--- 000000000001f000 008:00003 libexpat.so.0.5.0
00002b8b63bc2000       4 rw--- 00002b8b63bc2000 000:00000   [ anon ]
00002b8b63bc3000     152 r-x-- 0000000000000000 008:00003 libapr-1.so.0.2.7
00002b8b63be9000    2048 ----- 0000000000026000 008:00003 libapr-1.so.0.2.7
00002b8b63de9000       4 rw--- 0000000000026000 008:00003 libapr-1.so.0.2.7
00002b8b63dea000      88 r-x-- 0000000000000000 008:00003 libpthread-2.5.so
00002b8b63e00000    2044 ----- 0000000000016000 008:00003 libpthread-2.5.so
00002b8b63fff000       4 r---- 0000000000015000 008:00003 libpthread-2.5.so
00002b8b64000000       4 rw--- 0000000000016000 008:00003 libpthread-2.5.so
00002b8b64001000      16 rw--- 00002b8b64001000 000:00000   [ anon ]
00002b8b64005000       8 r-x-- 0000000000000000 008:00003 libdl-2.5.so
00002b8b64007000    2048 ----- 0000000000002000 008:00003 libdl-2.5.so
00002b8b64207000       4 r---- 0000000000002000 008:00003 libdl-2.5.so
00002b8b64208000       4 rw--- 0000000000003000 008:00003 libdl-2.5.so
00002b8b64209000       4 rw--- 00002b8b64209000 000:00000   [ anon ]
00002b8b6420a000    1328 r-x-- 0000000000000000 008:00003 libc-2.5.so
00002b8b64356000    2048 ----- 000000000014c000 008:00003 libc-2.5.so
00002b8b64556000      16 r---- 000000000014c000 008:00003 libc-2.5.so
00002b8b6455a000       4 rw--- 0000000000150000 008:00003 libc-2.5.so
00002b8b6455b000      20 rw--- 00002b8b6455b000 000:00000   [ anon ]
00002b8b64560000     236 r-x-- 0000000000000000 008:00003 libsepol.so.1
00002b8b6459b000    2048 ----- 000000000003b000 008:00003 libsepol.so.1
00002b8b6479b000       4 rw--- 000000000003b000 008:00003 libsepol.so.1
00002b8b6479c000      40 rw--- 00002b8b6479c000 000:00000   [ anon ]
00002b8b647a6000      12 r-x-- 0000000000000000 008:00003 libuuid.so.1.2
00002b8b647a9000    2048 ----- 0000000000003000 008:00003 libuuid.so.1.2
00002b8b649a9000       4 rw--- 0000000000003000 008:00003 libuuid.so.1.2
00002b8b649aa000       4 rw--- 00002b8b649aa000 000:00000   [ anon ]
00002b8b649ab000     128 r-x-- 0000000000000000 008:00003 libpq.so.4.1
00002b8b649cb000    2048 ----- 0000000000020000 008:00003 libpq.so.4.1
00002b8b64bcb000       8 rw--- 0000000000020000 008:00003 libpq.so.4.1
00002b8b64bcd000     352 r-x-- 0000000000000000 008:00003 libsqlite3.so.0.8.6
00002b8b64c25000    2048 ----- 0000000000058000 008:00003 libsqlite3.so.0.8.6
00002b8b64e25000       8 rw--- 0000000000058000 008:00003 libsqlite3.so.0.8.6
00002b8b64e27000      68 r-x-- 0000000000000000 008:00003 libresolv-2.5.so
00002b8b64e38000    2048 ----- 0000000000011000 008:00003 libresolv-2.5.so
00002b8b65038000       4 r---- 0000000000011000 008:00003 libresolv-2.5.so
00002b8b65039000       4 rw--- 0000000000012000 008:00003 libresolv-2.5.so
00002b8b6503a000      12 rw--- 00002b8b6503a000 000:00000   [ anon ]
00002b8b6503d000      96 r-x-- 0000000000000000 008:00003 libsasl2.so.2.0.22
00002b8b65055000    2048 ----- 0000000000018000 008:00003 libsasl2.so.2.0.22
00002b8b65255000       4 rw--- 0000000000018000 008:00003 libsasl2.so.2.0.22
00002b8b65256000     272 r-x-- 0000000000000000 008:00003 libssl.so.0.9.8e
00002b8b6529a000    2048 ----- 0000000000044000 008:00003 libssl.so.0.9.8e
00002b8b6549a000      24 rw--- 0000000000044000 008:00003 libssl.so.0.9.8e
00002b8b654a0000    1204 r-x-- 0000000000000000 008:00003 libcrypto.so.0.9.8e
00002b8b655cd000    2044 ----- 000000000012d000 008:00003 libcrypto.so.0.9.8e
00002b8b657cc000     132 rw--- 000000000012c000 008:00003 libcrypto.so.0.9.8e
00002b8b657ed000      20 rw--- 00002b8b657ed000 000:00000   [ anon ]
00002b8b657f2000     580 r-x-- 0000000000000000 008:00003 libkrb5.so.3.3
00002b8b65883000    2048 ----- 0000000000091000 008:00003 libkrb5.so.3.3
00002b8b65a83000      16 rw--- 0000000000091000 008:00003 libkrb5.so.3.3
00002b8b65a87000      84 r-x-- 0000000000000000 008:00003 libnsl-2.5.so
00002b8b65a9c000    2044 ----- 0000000000015000 008:00003 libnsl-2.5.so
00002b8b65c9b000       4 r---- 0000000000014000 008:00003 libnsl-2.5.so
00002b8b65c9c000       4 rw--- 0000000000015000 008:00003 libnsl-2.5.so
00002b8b65c9d000      12 rw--- 00002b8b65c9d000 000:00000   [ anon ]
00002b8b65ca0000     176 r-x-- 0000000000000000 008:00003 libgssapi_krb5.so.2.2
00002b8b65ccc000    2048 ----- 000000000002c000 008:00003 libgssapi_krb5.so.2.2
00002b8b65ecc000       8 rw--- 000000000002c000 008:00003 libgssapi_krb5.so.2.2
00002b8b65ece000       8 r-x-- 0000000000000000 008:00003 libcom_err.so.2.1
00002b8b65ed0000    2044 ----- 0000000000002000 008:00003 libcom_err.so.2.1
00002b8b660cf000       4 rw--- 0000000000001000 008:00003 libcom_err.so.2.1
00002b8b660d0000     144 r-x-- 0000000000000000 008:00003 libk5crypto.so.3.1
00002b8b660f4000    2044 ----- 0000000000024000 008:00003 libk5crypto.so.3.1
00002b8b662f3000       8 rw--- 0000000000023000 008:00003 libk5crypto.so.3.1
00002b8b662f5000       4 rw--- 00002b8b662f5000 000:00000   [ anon ]
00002b8b662f6000      80 r-x-- 0000000000000000 008:00003 libz.so.1.2.3
00002b8b6630a000    2044 ----- 0000000000014000 008:00003 libz.so.1.2.3
00002b8b66509000       4 rw--- 0000000000013000 008:00003 libz.so.1.2.3
00002b8b6650a000      32 r-x-- 0000000000000000 008:00003 libkrb5support.so.0.1
00002b8b66512000    2044 ----- 0000000000008000 008:00003 libkrb5support.so.0.1
00002b8b66711000       4 rw--- 0000000000007000 008:00003 libkrb5support.so.0.1
00002b8b66712000       8 r-x-- 0000000000000000 008:00003 libkeyutils-1.2.so
00002b8b66714000    2044 ----- 0000000000002000 008:00003 libkeyutils-1.2.so
00002b8b66913000       4 rw--- 0000000000001000 008:00003 libkeyutils-1.2.so
00002b8b66914000      12 rw--- 00002b8b66914000 000:00000   [ anon ]
00002b8b66917000       8 r-x-- 0000000000000000 008:00003 mod_auth_basic.so
00002b8b66919000    2044 ----- 0000000000002000 008:00003 mod_auth_basic.so
00002b8b66b18000       8 rw--- 0000000000001000 008:00003 mod_auth_basic.so
00002b8b66b1a000      24 r-x-- 0000000000000000 008:00003 mod_auth_digest.so
00002b8b66b20000    2044 ----- 0000000000006000 008:00003 mod_auth_digest.so
00002b8b66d1f000       8 rw--- 0000000000005000 008:00003 mod_auth_digest.so
00002b8b66d21000       8 r-x-- 0000000000000000 008:00003 mod_authn_file.so
00002b8b66d23000    2044 ----- 0000000000002000 008:00003 mod_authn_file.so
00002b8b66f22000       8 rw--- 0000000000001000 008:00003 mod_authn_file.so
00002b8b66f24000       8 r-x-- 0000000000000000 008:00003 mod_authn_alias.so
00002b8b66f26000    2044 ----- 0000000000002000 008:00003 mod_authn_alias.so
00002b8b67125000       8 rw--- 0000000000001000 008:00003 mod_authn_alias.so
00002b8b67127000       4 r-x-- 0000000000000000 008:00003 mod_authn_anon.so
00002b8b67128000    2048 ----- 0000000000001000 008:00003 mod_authn_anon.so
00002b8b67328000       8 rw--- 0000000000001000 008:00003 mod_authn_anon.so
00002b8b6732a000       4 r-x-- 0000000000000000 008:00003 mod_authn_dbm.so
00002b8b6732b000    2048 ----- 0000000000001000 008:00003 mod_authn_dbm.so
00002b8b6752b000       8 rw--- 0000000000001000 008:00003 mod_authn_dbm.so
00002b8b6752d000       4 r-x-- 0000000000000000 008:00003 mod_authn_default.so
00002b8b6752e000    2044 ----- 0000000000001000 008:00003 mod_authn_default.so
00002b8b6772d000       8 rw--- 0000000000000000 008:00003 mod_authn_default.so
00002b8b6772f000       8 r-x-- 0000000000000000 008:00003 mod_authz_host.so
00002b8b67731000    2044 ----- 0000000000002000 008:00003 mod_authz_host.so
00002b8b67930000       8 rw--- 0000000000001000 008:00003 mod_authz_host.so
00002b8b67932000       4 r-x-- 0000000000000000 008:00003 mod_authz_user.so
00002b8b67933000    2044 ----- 0000000000001000 008:00003 mod_authz_user.so
00002b8b67b32000       8 rw--- 0000000000000000 008:00003 mod_authz_user.so
00002b8b67b34000       8 r-x-- 0000000000000000 008:00003 mod_authz_owner.so
00002b8b67b36000    2044 ----- 0000000000002000 008:00003 mod_authz_owner.so
00002b8b67d35000       8 rw--- 0000000000001000 008:00003 mod_authz_owner.so
00002b8b67d37000       8 r-x-- 0000000000000000 008:00003 mod_authz_groupfile.so
00002b8b67d39000    2044 ----- 0000000000002000 008:00003 mod_authz_groupfile.so
00002b8b67f38000       8 rw--- 0000000000001000 008:00003 mod_authz_groupfile.so
00002b8b67f3a000       8 r-x-- 0000000000000000 008:00003 mod_authz_dbm.so
00002b8b67f3c000    2044 ----- 0000000000002000 008:00003 mod_authz_dbm.so
00002b8b6813b000       8 rw--- 0000000000001000 008:00003 mod_authz_dbm.so
00002b8b6813d000       4 r-x-- 0000000000000000 008:00003 mod_authz_default.so
00002b8b6813e000    2044 ----- 0000000000001000 008:00003 mod_authz_default.so
00002b8b6833d000       8 rw--- 0000000000000000 008:00003 mod_authz_default.so
00002b8b6833f000      44 r-x-- 0000000000000000 008:00003 mod_ldap.so
00002b8b6834a000    2048 ----- 000000000000b000 008:00003 mod_ldap.so
00002b8b6854a000       8 rw--- 000000000000b000 008:00003 mod_ldap.so
00002b8b6854c000      24 r-x-- 0000000000000000 008:00003 mod_authnz_ldap.so
00002b8b68552000    2044 ----- 0000000000006000 008:00003 mod_authnz_ldap.so
00002b8b68751000       8 rw--- 0000000000005000 008:00003 mod_authnz_ldap.so
00002b8b68753000      36 r-x-- 0000000000000000 008:00003 mod_include.so
00002b8b6875c000    2048 ----- 0000000000009000 008:00003 mod_include.so
00002b8b6895c000       8 rw--- 0000000000009000 008:00003 mod_include.so
00002b8b6895e000      20 r-x-- 0000000000000000 008:00003 mod_log_config.so
00002b8b68963000    2044 ----- 0000000000005000 008:00003 mod_log_config.so
00002b8b68b62000       8 rw--- 0000000000004000 008:00003 mod_log_config.so
00002b8b68b64000       8 r-x-- 0000000000000000 008:00003 mod_logio.so
00002b8b68b66000    2044 ----- 0000000000002000 008:00003 mod_logio.so
00002b8b68d65000       8 rw--- 0000000000001000 008:00003 mod_logio.so
00002b8b68d67000       4 r-x-- 0000000000000000 008:00003 mod_env.so
00002b8b68d68000    2048 ----- 0000000000001000 008:00003 mod_env.so
00002b8b68f68000       8 rw--- 0000000000001000 008:00003 mod_env.so
00002b8b68f6a000      16 r-x-- 0000000000000000 008:00003 mod_ext_filter.so
00002b8b68f6e000    2044 ----- 0000000000004000 008:00003 mod_ext_filter.so
00002b8b6916d000       8 rw--- 0000000000003000 008:00003 mod_ext_filter.so
00002b8b6916f000      20 r-x-- 0000000000000000 008:00003 mod_mime_magic.so
00002b8b69174000    2044 ----- 0000000000005000 008:00003 mod_mime_magic.so
00002b8b69373000       8 rw--- 0000000000004000 008:00003 mod_mime_magic.so
00002b8b69375000       8 r-x-- 0000000000000000 008:00003 mod_expires.so
00002b8b69377000    2044 ----- 0000000000002000 008:00003 mod_expires.so
00002b8b69576000       8 rw--- 0000000000001000 008:00003 mod_expires.so
00002b8b69578000      16 r-x-- 0000000000000000 008:00003 mod_deflate.so
00002b8b6957c000    2044 ----- 0000000000004000 008:00003 mod_deflate.so
00002b8b6977b000       8 rw--- 0000000000003000 008:00003 mod_deflate.so
00002b8b6977d000      12 r-x-- 0000000000000000 008:00003 mod_headers.so
00002b8b69780000    2048 ----- 0000000000003000 008:00003 mod_headers.so
00002b8b69980000       8 rw--- 0000000000003000 008:00003 mod_headers.so
00002b8b69982000       8 r-x-- 0000000000000000 008:00003 mod_usertrack.so
00002b8b69984000    2048 ----- 0000000000002000 008:00003 mod_usertrack.so
00002b8b69b84000       8 rw--- 0000000000002000 008:00003 mod_usertrack.so
00002b8b69b86000       8 r-x-- 0000000000000000 008:00003 mod_setenvif.so
00002b8b69b88000    2048 ----- 0000000000002000 008:00003 mod_setenvif.so
00002b8b69d88000       8 rw--- 0000000000002000 008:00003 mod_setenvif.so
00002b8b69d8a000      16 r-x-- 0000000000000000 008:00003 mod_mime.so
00002b8b69d8e000    2044 ----- 0000000000004000 008:00003 mod_mime.so
00002b8b69f8d000       8 rw--- 0000000000003000 008:00003 mod_mime.so
00002b8b69f8f000      84 r-x-- 0000000000000000 008:00003 mod_dav.so
00002b8b69fa4000    2044 ----- 0000000000015000 008:00003 mod_dav.so
00002b8b6a1a3000       8 rw--- 0000000000014000 008:00003 mod_dav.so
00002b8b6a1a5000      16 r-x-- 0000000000000000 008:00003 mod_status.so
00002b8b6a1a9000    2044 ----- 0000000000004000 008:00003 mod_status.so
00002b8b6a3a8000       8 rw--- 0000000000003000 008:00003 mod_status.so
00002b8b6a3aa000      32 r-x-- 0000000000000000 008:00003 mod_autoindex.so
00002b8b6a3b2000    2044 ----- 0000000000008000 008:00003 mod_autoindex.so
00002b8b6a5b1000       8 rw--- 0000000000007000 008:00003 mod_autoindex.so
00002b8b6a5b3000      16 r-x-- 0000000000000000 008:00003 mod_info.so
00002b8b6a5b7000    2044 ----- 0000000000004000 008:00003 mod_info.so
00002b8b6a7b6000       8 rw--- 0000000000003000 008:00003 mod_info.so
00002b8b6a7b8000      44 r-x-- 0000000000000000 008:00003 mod_dav_fs.so
00002b8b6a7c3000    2044 ----- 000000000000b000 008:00003 mod_dav_fs.so
00002b8b6a9c2000       8 rw--- 000000000000a000 008:00003 mod_dav_fs.so
00002b8b6a9c4000       8 r-x-- 0000000000000000 008:00003 mod_vhost_alias.so
00002b8b6a9c6000    2044 ----- 0000000000002000 008:00003 mod_vhost_alias.so
00002b8b6abc5000       8 rw--- 0000000000001000 008:00003 mod_vhost_alias.so
00002b8b6abc7000      28 r-x-- 0000000000000000 008:00003 mod_negotiation.so
00002b8b6abce000    2044 ----- 0000000000007000 008:00003 mod_negotiation.so
00002b8b6adcd000       8 rw--- 0000000000006000 008:00003 mod_negotiation.so
00002b8b6adcf000       8 r-x-- 0000000000000000 008:00003 mod_dir.so
00002b8b6add1000    2044 ----- 0000000000002000 008:00003 mod_dir.so
00002b8b6afd0000       8 rw--- 0000000000001000 008:00003 mod_dir.so
00002b8b6afd2000       8 r-x-- 0000000000000000 008:00003 mod_actions.so
00002b8b6afd4000    2044 ----- 0000000000002000 008:00003 mod_actions.so
00002b8b6b1d3000       8 rw--- 0000000000001000 008:00003 mod_actions.so
00002b8b6b1d5000       8 r-x-- 0000000000000000 008:00003 mod_speling.so
00002b8b6b1d7000    2048 ----- 0000000000002000 008:00003 mod_speling.so
00002b8b6b3d7000       8 rw--- 0000000000002000 008:00003 mod_speling.so
00002b8b6b3d9000       8 r-x-- 0000000000000000 008:00003 mod_userdir.so
00002b8b6b3db000    2044 ----- 0000000000002000 008:00003 mod_userdir.so
00002b8b6b5da000       8 rw--- 0000000000001000 008:00003 mod_userdir.so
00002b8b6b5dc000      12 r-x-- 0000000000000000 008:00003 mod_alias.so
00002b8b6b5df000    2044 ----- 0000000000003000 008:00003 mod_alias.so
00002b8b6b7de000       8 rw--- 0000000000002000 008:00003 mod_alias.so
00002b8b6b7e0000      56 r-x-- 0000000000000000 008:00003 mod_rewrite.so
00002b8b6b7ee000    2044 ----- 000000000000e000 008:00003 mod_rewrite.so
00002b8b6b9ed000       8 rw--- 000000000000d000 008:00003 mod_rewrite.so
00002b8b6b9ef000      72 r-x-- 0000000000000000 008:00003 mod_proxy.so
00002b8b6ba01000    2044 ----- 0000000000012000 008:00003 mod_proxy.so
00002b8b6bc00000       8 rw--- 0000000000011000 008:00003 mod_proxy.so
00002b8b6bc02000      20 r-x-- 0000000000000000 008:00003 mod_proxy_balancer.so
00002b8b6bc07000    2044 ----- 0000000000005000 008:00003 mod_proxy_balancer.so
00002b8b6be06000       8 rw--- 0000000000004000 008:00003 mod_proxy_balancer.so
00002b8b6be08000      28 r-x-- 0000000000000000 008:00003 mod_proxy_ftp.so
00002b8b6be0f000    2044 ----- 0000000000007000 008:00003 mod_proxy_ftp.so
00002b8b6c00e000       8 rw--- 0000000000006000 008:00003 mod_proxy_ftp.so
00002b8b6c010000      28 r-x-- 0000000000000000 008:00003 mod_proxy_http.so
00002b8b6c017000    2044 ----- 0000000000007000 008:00003 mod_proxy_http.so
00002b8b6c216000       8 rw--- 0000000000006000 008:00003 mod_proxy_http.so
00002b8b6c218000       8 r-x-- 0000000000000000 008:00003 mod_proxy_connect.so
00002b8b6c21a000    2044 ----- 0000000000002000 008:00003 mod_proxy_connect.so
00002b8b6c419000       8 rw--- 0000000000001000 008:00003 mod_proxy_connect.so
00002b8b6c41b000      28 r-x-- 0000000000000000 008:00003 mod_cache.so
00002b8b6c422000    2044 ----- 0000000000007000 008:00003 mod_cache.so
00002b8b6c621000       8 rw--- 0000000000006000 008:00003 mod_cache.so
00002b8b6c623000       4 r-x-- 0000000000000000 008:00003 mod_suexec.so
00002b8b6c624000    2048 ----- 0000000000001000 008:00003 mod_suexec.so
00002b8b6c824000       8 rw--- 0000000000001000 008:00003 mod_suexec.so
00002b8b6c826000      16 r-x-- 0000000000000000 008:00003 mod_disk_cache.so
00002b8b6c82a000    2048 ----- 0000000000004000 008:00003 mod_disk_cache.so
00002b8b6ca2a000       8 rw--- 0000000000004000 008:00003 mod_disk_cache.so
00002b8b6ca2c000       8 r-x-- 0000000000000000 008:00003 mod_file_cache.so
00002b8b6ca2e000    2044 ----- 0000000000002000 008:00003 mod_file_cache.so
00002b8b6cc2d000       8 rw--- 0000000000001000 008:00003 mod_file_cache.so
00002b8b6cc2f000      24 r-x-- 0000000000000000 008:00003 mod_mem_cache.so
00002b8b6cc35000    2044 ----- 0000000000006000 008:00003 mod_mem_cache.so
00002b8b6ce34000       8 rw--- 0000000000005000 008:00003 mod_mem_cache.so
00002b8b6ce36000      20 r-x-- 0000000000000000 008:00003 mod_cgi.so
00002b8b6ce3b000    2048 ----- 0000000000005000 008:00003 mod_cgi.so
00002b8b6d03b000       8 rw--- 0000000000005000 008:00003 mod_cgi.so
00002b8b6d03d000       8 r-x-- 0000000000000000 008:00003 mod_version.so
00002b8b6d03f000    2044 ----- 0000000000002000 008:00003 mod_version.so
00002b8b6d23e000       8 rw--- 0000000000001000 008:00003 mod_version.so
00002b8b6d240000    3180 r-x-- 0000000000000000 008:00003 libphp5.so
00002b8b6d55b000    2044 ----- 000000000031b000 008:00003 libphp5.so
00002b8b6d75a000     288 rw--- 000000000031a000 008:00003 libphp5.so
00002b8b6d7a2000      32 rw--- 00002b8b6d7a2000 000:00000   [ anon ]
00002b8b6d7af000     224 r-x-- 0000000000000000 008:00003 libgmp.so.3.3.3
00002b8b6d7e7000    2048 ----- 0000000000038000 008:00003 libgmp.so.3.3.3
00002b8b6d9e7000       4 rw--- 0000000000038000 008:00003 libgmp.so.3.3.3
00002b8b6d9e8000      60 r-x-- 0000000000000000 008:00003 libbz2.so.1.0.3
00002b8b6d9f7000    2044 ----- 000000000000f000 008:00003 libbz2.so.1.0.3
00002b8b6dbf6000       8 rw--- 000000000000e000 008:00003 libbz2.so.1.0.3
00002b8b6dbf8000    1228 r-x-- 0000000000000000 008:00003 libxml2.so.2.6.26
00002b8b6dd2b000    2048 ----- 0000000000133000 008:00003 libxml2.so.2.6.26
00002b8b6df2b000      36 rw--- 0000000000133000 008:00003 libxml2.so.2.6.26
00002b8b6df34000       4 rw--- 00002b8b6df34000 000:00000   [ anon ]
00002b8b6df35000      32 r-x-- 0000000000000000 008:00003 mod_proxy_ajp.so
00002b8b6df3d000    2044 ----- 0000000000008000 008:00003 mod_proxy_ajp.so
00002b8b6e13c000       8 rw--- 0000000000007000 008:00003 mod_proxy_ajp.so
00002b8b6e143000      40 r-x-- 0000000000000000 008:00003 libnss_files-2.5.so
00002b8b6e14d000    2044 ----- 000000000000a000 008:00003 libnss_files-2.5.so
00002b8b6e34c000       4 r---- 0000000000009000 008:00003 libnss_files-2.5.so
00002b8b6e34d000       4 rw--- 000000000000a000 008:00003 libnss_files-2.5.so
00002b8b6e34e000      84 r-x-- 0000000000000000 008:00003 apc.so
00002b8b6e363000    2048 ----- 0000000000015000 008:00003 apc.so
00002b8b6e563000       8 rw--- 0000000000015000 008:00003 apc.so
00002b8b6e565000      32 rw--- 00002b8b6e565000 000:00000   [ anon ]
00002b8b6e572000      28 r-x-- 0000000000000000 008:00003 librt-2.5.so
00002b8b6e579000    2048 ----- 0000000000007000 008:00003 librt-2.5.so
00002b8b6e779000       4 r---- 0000000000007000 008:00003 librt-2.5.so
00002b8b6e77a000       4 rw--- 0000000000008000 008:00003 librt-2.5.so
00002b8b6e77b000      56 r-x-- 0000000000000000 008:00003 curl.so
00002b8b6e789000    2044 ----- 000000000000e000 008:00003 curl.so
00002b8b6e988000       8 rw--- 000000000000d000 008:00003 curl.so
00002b8b6e98f000     236 r-x-- 0000000000000000 008:00003 libcurl.so.3.0.0
00002b8b6e9ca000    2048 ----- 000000000003b000 008:00003 libcurl.so.3.0.0
00002b8b6ebca000       8 rw--- 000000000003b000 008:00003 libcurl.so.3.0.0
00002b8b6ebcc000     196 r-x-- 0000000000000000 008:00003 libidn.so.11.5.19
00002b8b6ebfd000    2044 ----- 0000000000031000 008:00003 libidn.so.11.5.19
00002b8b6edfc000       4 rw--- 0000000000030000 008:00003 libidn.so.11.5.19
00002b8b6edfd000      28 r-x-- 0000000000000000 008:00003 dbase.so
00002b8b6ee04000    2048 ----- 0000000000007000 008:00003 dbase.so
00002b8b6f004000       4 rw--- 0000000000007000 008:00003 dbase.so
00002b8b6f005000     156 r-x-- 0000000000000000 008:00003 dom.so
00002b8b6f02c000    2044 ----- 0000000000027000 008:00003 dom.so
00002b8b6f22b000      24 rw--- 0000000000026000 008:00003 dom.so
00002b8b6f231000       4 rw--- 00002b8b6f231000 000:00000   [ anon ]
00002b8b6f232000      28 r-x-- 0000000000000000 008:00003 json.so
00002b8b6f239000    2044 ----- 0000000000007000 008:00003 json.so
00002b8b6f438000       4 rw--- 0000000000006000 008:00003 json.so
00002b8b6f439000    1944 r-x-- 0000000000000000 008:00003 mbstring.so
00002b8b6f61f000    2048 ----- 00000000001e6000 008:00003 mbstring.so
00002b8b6f81f000      36 rw--- 00000000001e6000 008:00003 mbstring.so
00002b8b6f828000      44 r-x-- 0000000000000000 008:00003 mysql.so
00002b8b6f833000    2044 ----- 000000000000b000 008:00003 mysql.so
00002b8b6fa32000       8 rw--- 000000000000a000 008:00003 mysql.so
00002b8b6fa39000    1220 r-x-- 0000000000000000 008:00003 libmysqlclient.so.16.0.0
00002b8b6fb6a000    2044 ----- 0000000000131000 008:00003 libmysqlclient.so.16.0.0
00002b8b6fd69000     308 rw--- 0000000000130000 008:00003 libmysqlclient.so.16.0.0
00002b8b6fdb6000       4 rw--- 00002b8b6fdb6000 000:00000   [ anon ]
00002b8b6fdb7000     104 r-x-- 0000000000000000 008:00003 mysqli.so
00002b8b6fdd1000    2044 ----- 000000000001a000 008:00003 mysqli.so
00002b8b6ffd0000      12 rw--- 0000000000019000 008:00003 mysqli.so
00002b8b6ffd3000       4 rw--- 00002b8b6ffd3000 000:00000   [ anon ]
00002b8b6ffd4000      88 r-x-- 0000000000000000 008:00003 pdo.so
00002b8b6ffea000    2048 ----- 0000000000016000 008:00003 pdo.so
00002b8b701ea000      12 rw--- 0000000000016000 008:00003 pdo.so
00002b8b701ed000      24 r-x-- 0000000000000000 008:00003 pdo_mysql.so
00002b8b701f3000    2048 ----- 0000000000006000 008:00003 pdo_mysql.so
00002b8b703f3000       4 rw--- 0000000000006000 008:00003 pdo_mysql.so
00002b8b703f4000      20 r-x-- 0000000000000000 008:00003 pdo_sqlite.so
00002b8b703f9000    2048 ----- 0000000000005000 008:00003 pdo_sqlite.so
00002b8b705f9000       4 rw--- 0000000000005000 008:00003 pdo_sqlite.so
00002b8b705fa000      64 r-x-- 0000000000000000 008:00003 sqlite.so
00002b8b7060a000    2044 ----- 0000000000010000 008:00003 sqlite.so
00002b8b70809000       8 rw--- 000000000000f000 008:00003 sqlite.so
00002b8b70810000     284 r-x-- 0000000000000000 008:00003 libsqlite.so.0.8.6
00002b8b70857000    2044 ----- 0000000000047000 008:00003 libsqlite.so.0.8.6
00002b8b70a56000      12 rw--- 0000000000046000 008:00003 libsqlite.so.0.8.6
00002b8b70a59000      28 r-x-- 0000000000000000 008:00003 wddx.so
00002b8b70a60000    2048 ----- 0000000000007000 008:00003 wddx.so
00002b8b70c60000       4 rw--- 0000000000007000 008:00003 wddx.so
00002b8b70c61000      28 r-x-- 0000000000000000 008:00003 xmlreader.so
00002b8b70c68000    2044 ----- 0000000000007000 008:00003 xmlreader.so
00002b8b70e67000       8 rw--- 0000000000006000 008:00003 xmlreader.so
00002b8b70e69000      28 r-x-- 0000000000000000 008:00003 xmlwriter.so
00002b8b70e70000    2044 ----- 0000000000007000 008:00003 xmlwriter.so
00002b8b7106f000       8 rw--- 0000000000006000 008:00003 xmlwriter.so
00002b8b71071000      28 r-x-- 0000000000000000 008:00003 xsl.so
00002b8b71078000    2044 ----- 0000000000007000 008:00003 xsl.so
00002b8b71277000       4 rw--- 0000000000006000 008:00003 xsl.so
00002b8b7127d000      68 r-x-- 0000000000000000 008:00003 libexslt.so.0.8.13
00002b8b7128e000    2048 ----- 0000000000011000 008:00003 libexslt.so.0.8.13
00002b8b7148e000       4 rw--- 0000000000011000 008:00003 libexslt.
</code>
Answer: Using the default http.conf (or very close to it) is actually usually a good thing.  You'd be surprised how much better at this apache developers and redhat engineers are than most of us :)
First off, and I apologize if this sounds dumb, but are you certain that nginx is configured in front of apache?  I can't tell you how many times I've seen people read a blog post recommending nginx and gone and setup their existing apache's to mod_proxy /images back to nginx.
Second, most apache modules, especially the ones that come in a redhat/centos build, are very well written to use shared libraries and the apr runtime, so they're not likely to buy you much commenting them out.
I think the biggest thing you probably want to look at is a php op cache.   It can have a dramatic affect on both the performance and the burst-memory-usage of php scripts.  Fortunatly as a CentOS user you can setup the EPEL repo and "yum install php-pecl-apc" and have it setup in moments.  See how that helps.
Comment: Hey Cagenut, thanks for the comment - I did configure nginx in front of apache, meaning that all traffic passes through ngninx. static content are being served by nginx, the dynamic content is being served by nginx after requesting it by apache (currently nginx is on port 80 and apache 8080), I also installed apc long time ago using pecl.
Any more tips?

Optimizing Apache


Como passar múltiplos arquivos com click python?

Question: Tenho um diretório com vários arquivos:
arquivo.txt
arquivo1.txt
arquivo2.txt...

E tenho esse código:
import click
@click.command()
@click.argument("file", type=click.File('r'))

def cat(file):
    click.echo(f.read())

cat()

Porém esse código só pega um arquivo. Ele não faz um for no diretório. Gostaria de abrir e ler cada um dos arquivos do diretório...
Tentei alguns outros códigos mas não estão funcionando também
@click.command()
@click.argument("file", type=click.File())
lista = open(file, 'r')
lista_lines = lista.readlines()
for lista_line in lista_lines:
     cat(lista_line)

 def cat(lista_line):
        click.echo(f.read())

Como posso rodar o script uma vez de modo que ele consiga abrir todos arquivos do diretório?
Answer:
Eu fiz de cabeça pois não vou instalar o módulo click em meu sistema.
Teste os exemplos....

A biblioteca padrão do Python inclui o módulo os — Diversas interfaces de sistema operacional, que inclui em seu acervo a função listdir() que segundo a documentação:

os.listdir(path='.')
Retorna uma lista contendo os nomes das entradas no diretório fornecido por path. A lista está em ordem arbitrária e não inclui as
entradas especiais '.' e '..' mesmo se estiverem presentes no
diretório. Se um arquivo for removido ou adicionado ao diretório
durante a chamada desta função, não é especificado se um nome para
esse arquivo deve ser incluído.
path pode ser um objeto caminho ou similar. Se path for do tipo bytes (direta ou indiretamente por meio da interface PathLike), os
nomes de arquivo retornados também serão do tipo bytes; em todas as
outras circunstâncias, eles serão do tipo str.
Esta função também pode ter suporte a especificar um descritor de arquivo; o descritor de arquivo deve fazer referência a um diretório.

import os

@click.command()
@click.option("--path", default=".", help="Path para ser listado.")
def ls1(path):
  for f in os.listdir("path"):
     print(f)

O módulo os também fornece a função scandir() que segundo a documentação:

os.scandir(path='.')
Retorna um iterador de objetos os.DirEntry correspondentes às entradas
no diretório fornecido por path. As entradas são produzidas em ordem
arbitrária, e as entradas especiais '.' e '..' não são incluídas. Se
um arquivo for removido ou adicionado ao diretório após a criação do
iterador, não é especificado se uma entrada para esse arquivo deve ser
incluída.
Usar scandir() em vez de listdir() pode aumentar significativamente o
desempenho do código que também precisa de tipo de arquivo ou
informações de atributo de arquivo, porque os objetos os.DirEntry
expõem essas informações se o sistema operacional fornecer ao
digitalizar um diretório. Todos os métodos de os.DirEntry podem
realizar uma chamada de sistema, mas is_dir() e is_file() normalmente
requerem apenas uma chamada de sistema para links simbólicos;
os.DirEntry.stat() sempre requer uma chamada de sistema no Unix, mas
requer apenas uma para links simbólicos no Windows.
path pode ser um objeto caminho ou similar. Se path for do tipo bytes
(direta ou indiretamente por meio da interface PathLike), o tipo do
atributo name e path de cada os.DirEntry serão bytes; em todas as
outras circunstâncias, eles serão do tipo str.

import os

@click.command()
@click.option("--path", default=".", help="Path para ser listado.")
def ls2(path):
  with os.scandir(path) as d:
    for e in d:
        if not e.name.startswith('.') and e.is_file():
            print(f'{"f" if e.is_file() else "*"}->{e.name}')

Comment: ....Tentei resolver o problema como sugeriu, mas não consigo inserir todos os arquivos...
Comment: @Lara vamos e quem quiser participar vamos conversar [nessa sala de chat](https://chat.stackexchange.com/rooms/120201/listar-aquivos-de-lara) para debater o seu código.


playing sound files in resources folder

Question: I have some mp3 files in my resources folder, how can i play those mp3 files? I just know their name.
Answer: You can use the AVAudioPlayer. To get the URL for the files use NSBundles -URLForResource:withExtension: (or downward compatible alternatives, see Kennys answer):
NSURL *url = [[NSBundle mainBundle] URLForResource:@"myFile" withExtension:@"mp3"];
NSError *error = 0;
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
// check error ...
[player play];
// ...

And don't forget to read the Multimedia Programming Guides section on using audio.
Answer: Just to supplement @Georg's answer.
As you can see from the doc, -URLForResource:withExtension: is available only since 4.0. As 3.x is still widespread, it's better to use the backward-compatible methods:

By converting a path to NSURL:
NSString* path = [[NSBundle mainBundle] pathForResource:@"myFile" ofType:@"mp3"];
NSURL* url = [NSURL fileURLWithPath:path];
....

or, by CoreFoundation methods:
CFURLRef url = CFBundleCopyResourceURL(CFBundleGetMain(),
                                       CFSTR("myFile"), CFSTR("mp3"), NULL);
....
CFRelease(url);

Comment: Oops, thats what i get for quickly throwing it together :)

playing sound files in resources folder


Qual o motivo Trying to get property of non-object in?

Question: Galera estou tentando retornar dados do banco usando este código:
//avoid Undefined variable
$errors = [];

if (Input::exists('post'))
{
    $validate = new Validate;

    $validation = $validate->check($_POST, array(
        'username' => array(
            'required' => true
        ),

        'password' => array(
            'required' => true
        )
    ));

    if ($validation->passed())
    {

        $data = $this->_model->get_member_hash(Input::get('username'));

        if (Password::password_verify(Input::get('password'), $data[0]->admin_password))
        {
            echo 'correct data';
        }
        else
        {
            echo 'incorrect data';
        }
    }
    else
    {
        $errors = $validation->errors();
    }

Só que ele está me retornando esses dois erros

Notice: Undefined offset: 0
Notice: Trying to get property of non-object in

Qual motivo?
Meu model:
public function get_member_hash($username)
    {
        return $this->_db->read('SELECT * FROM ' . DATABASE_PREFIX . 'admins WHERE admin_email=:email OR admin_username=:username', array(
            ':email'    => $username,
            ':username' => $username,
        ));
    }

Classe de validação
<?php

/**
 *
 */
class Input
{

    /**
     *
     */
    public static function exists($type = 'post')
    {
        switch ($type)
        {
            case 'post':
                return (!empty($_POST)) ? true : false;
                break;

            case 'get':
                return (!empty($_GET)) ? true : false;
                break;

            default :
                return false;
                break;
        }
    }

    /**
     *
     */
    public static function get($item)
    {
        if (isset($_POST[$item]))
        {
            return trim(strip_tags(filter_input(INPUT_POST, $item)));
        }
        else if (isset($_GET[$item]))
        {
            return trim(strip_tags(filter_input(INPUT_GET, $item)));
        }

        //By default return string
        return '';
    }
}

Comment: ele alega que vc esta tenntado acessar uma propriedade que nao existe...ja olhou se esqueceu de declarar algum meodo?
Comment: Sim, todos os métodos que estou usando estão sendo declarados.
Comment: Vamos [continuar esta discussão no chat](http://chat.stackexchange.com/rooms/39694/discussion-between-guilherme-spinxo-and-rray).
Answer: Não sei o que esse método retorna:
public function get_member_hash($username)
    {
        return $this->_db->read('SELECT * FROM ' . DATABASE_PREFIX . 'admins WHERE admin_email=:email OR admin_username=:username', array(
            ':email'    => $username,
            ':username' => $username,
        ));
    }

No seu código você trata como se tivesse certeza que ele retorna um array quando você chama $data[0]
O problema é que esse método não está retornando um array, pois creio que a consulta não retornou nem um valor.
antes de chamar $data[0] você precisa fazer uma checagem, tipo:

if(is_array($data){
//faz algo
} else {
 //não retornou nenhum valor
}


Using Yii-user with Opauth

Question: I have been trying to get Opauth to pass params in a sane way to Yii-User. Here is the extension git repos for which ones I am using:
Opauth (via Yii Framework module) with updated libs from official Opauth repo
Yii-User Module repo
I have gotten proper array from Opauth showing my Google account information directly on the page after modifying the Callback controller for Opauth.
Here's the code in the Callback controller:

    class CallbackController extends Controller {

        public $defaultAction = 'callback';

            public function actionCallBack() {
                if ( $this->module->getConfig() ) {

                    /**
                     * Instantiate Opauth with the loaded config but no run automatically
                     * Only create Opauth if one is not already there
                     */
                    if (!$this->module->getOpauth()) {
                        $this->module->setOpauth (new Opauth($this->module->getConfig(), false));
                        $Opauth = $this->module->getOpauth();
                    } else {
                        $Opauth = $this->module->getOpauth();
                    }

                    /**
                     * Fetch auth response, based on transport configuration for callback
                     */
                    $response = null;

                    switch($Opauth->env['callback_transport']) {
                        case 'session':
                            session_start();
                            $response = $_SESSION['opauth'];
                            unset($_SESSION['opauth']);
                            break;
                        case 'post':
                            $response = unserialize(base64_decode( $_POST['opauth'] ));
                            break;
                        case 'get':
                            $response = unserialize(base64_decode( $_GET['opauth'] ));
                            break;
                        default:
                            echo 'Error: Unsupported callback_transport.'."\n";
                            break;
                    }

                    /**
                     * Check if it's an error callback
                     */
                    if (array_key_exists('error', $response)) {
                        echo 'Authentication error:  Opauth returns error auth response.'."\n";
                    }

                    /**
                     * Auth response validation
                     *
                     * To validate that the auth response received is unaltered, especially auth response that
                     * is sent through GET or POST.
                     */
                    else{
                        if (empty($response['auth']) || empty($response['timestamp']) || empty($response['signature']) || empty($response['auth']['provider']) || empty($response['auth']['uid'])) {
                            echo 'Invalid auth response: Missing key auth response components.'."\n";
                        } elseif (!$Opauth->validate(sha1(print_r($response['auth'], true)), $response['timestamp'], $response['signature'], $reason)) {
                            echo 'Invalid auth response: '.$reason.".\n";
                        } else {
                            echo 'OK: Auth response is validated.'."\n";

                            /**
                             * It's all good. Go ahead with your application-specific authentication logic
                             */
                            $Opauth->response = $response;
                            Yii::app()->getModule('opauth')->setOpauth($Opauth);
                            $this->redirect(Yii::app()->getModule('user')->returnUrl);
                        }
                    }
                } else {
                    echo 'No configuration loaded!';
                }
            }

        }

I have tried saving the response to the module (shown at the end of the controller) directly but this doesn't work -- I think the module class gets created every run. I am unsure how to move the response directly into the yii-user module.
Edit: I am trying something like this in the Callback controller:

$identity = new UserIdentity($response);
if ($identity->authenticate()) {
     Yii::app()->user->login($identity);
     $this->redirect('/');
} else {
     $this->redirect(Yii::app()->getModule('user')->returnUrl);
}

For the $identity->authenticate(), I have this:

    public function authenticate()
        {
            if (strpos($this->username,"@")) {
                $user=User::model()->notsafe()->findByAttributes(array('email'=>$this->username));
            } else {
                $user=User::model()->notsafe()->findByAttributes(array('username'=>$this->username));
            }
            if($user===null)
                if (strpos($this->username,"@")) {
                    $this->errorCode=self::ERROR_EMAIL_INVALID;
                } else {
                    $this->errorCode=self::ERROR_USERNAME_INVALID;
                }
            //else if(Yii::app()->getModule('user')->encrypting($this->password)!==$user->password)
            //  $this->errorCode=self::ERROR_PASSWORD_INVALID;
            else if($user->status==0&&Yii::app()->getModule('user')->loginNotActiv==false)
                $this->errorCode=self::ERROR_STATUS_NOTACTIV;
            else if($user->status==-1)
                $this->errorCode=self::ERROR_STATUS_BAN;
            else {
                $this->_id=$user->id;
                $this->username=$user->username;
                $this->errorCode=self::ERROR_NONE;
            }
            return !$this->errorCode;
        }

Answer: Here's what I did to get this part to work:
$identity = new UserIdentity($response);
$identity->authenticate();

switch($identity->errorCode) {
    case $identity::ERROR_NONE:
        Yii::app()->user->login($identity);
        $this->redirect(array("page_after_login"));
        break;
     case $identity::ERROR_USERNAME_INVALID:
        $this->redirect(Yii::app()->user->registrationUrl);
        break;
     default:
        throw new CException ($identity->errorCode);
}

Using Yii-user with Opauth


Dependency Injection in Custom Field Widget

Question: I am trying to inject the entity query service into a custom field widget.  This is the relevant code:
<code>/**
 * Plugin implementation of the 'address_options' widget.
 *
 * @FieldWidget(
 *   id = "address_options",
 *   label = @Translation("Addresses"),
 *   field_types = {
 *     "entity_reference"
 *   }
 * )
 */
class MyCustomWidget extends WidgetBase {

  /**
   * The entity query factory service.
   *
   * @var \Drupal\Core\Entity\Query\QueryFactory
   */
  protected $entityQuery;

  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, QueryFactory $entity_query) {
    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
    $this->entityQuery = $entity_query;
  }

  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $plugin_id,
      $plugin_definition,
      $configuration['field_definition'],
      $configuration['settings'],
      $configuration['third_party_settings'],
      $container->get('entity.query')
    );
  }
</code>
The following error results:

Recoverable fatal error: Argument 6 passed to
  Drupal\custom_module\Plugin\Field\FieldWidget\AddressWidget::__construct()
  must be an instance of Drupal\Core\Entity\Query\QueryFactory, none
  given, called in
  /homedir/core/lib/Drupal/Core/Field/WidgetPluginManager.php on line
  130.

Is it not possible to use dependency injection in this case or am I missing something?
Answer: What you are missing is to implement \Drupal\Core\Plugin\ContainerFactoryPluginInterface, which defines the create() method.
See \Drupal\file\Plugin\Field\FieldWidget\FileWidget for an example.
Comment: Awesome! Just made my day. :)


Does GCP MFA Allow For Trusted Devices?

Question: Okay so recently I started working with Firebase and I noticed that on GCP's Identity Platform there is the option to enable MFA for your users. Given the fact that I needed this in my app I thought this would be a great fit. However after reading the very limited documentation (found here: https://cloud.google.com/identity-platform/docs/web/mfa)and implementing this solution I do not see any real way to add an option to trust a users device, hence not bothering the user to have to verify with the second step every time they log in.
So my question is does this feature exist within GCP's MFA or does this have to be worked out some other way? If this feature exists does anyone know how to implement it?
Answer: Trusted device is currently not supported by GCP Identity Platform.
I recently had the same question when implementing MFA for a web app. My research included contacting GCP with this question and got the answer that there is currently no feature for trusted client/device and therefor not possible to avoid the second factor authentication (even with a custom implementation). Once you have enabled MFA you cannot temporarily disable it.

Does GCP MFA Allow For Trusted Devices?


Image of a closed unit ball of non-reflexive space

Question:
Let $A:c_0\to L_2[0,1]$, $Ax(t)=\displaystyle\sum\limits_{k=1}^\infty\dfrac{x(k)}{ k!+ t}$ -- is linear operator. It is required to prove or disprove the closedness of the set $A(B_1(0))$, where $B_1(0)$ -- closed unit ball in $c_0$.

What I already know about this operator: it's well defined, bounded, compact. I can find his adjoint. If instead of $c_0$ there was a reflexive space, I could say that the set $A(B_1(0))$ is closed (even compact). Is it possible to use the above information for this case, or should I act somehow differently?
Answer: Hint:
Consider the function
$$
f(t)=\sum_{k=1}^\infty \frac{1}{k!+t},
\qquad
t\in[0,1].
$$
To show this is not in $A(B_1(0))$, one can use monotonicity arguments.
For example, it turns out that $(Ax)(t)\leq f(t)$ for all $t\in[0,1]$
and $x\in B_1(0)$ holds. Similar ideas can be used to show that $f\not\in A(B_1(0))$.
Comment: I think i understand. If $\sum\frac{1-x_0(k)}{k!+t}=0$, then, by nonnegativity of $1-x_0(k)$, $x_0(k)=1$.
Comment: I thought about it, but how to show that she does not have a preimage? I mean, what if exists $x\in c_0$ such that $\sum\frac{x(k)}{k!+t}=\sum\frac{1}{k!+t}$?
Comment: @thing I edited my answer to provide a hint for the questions in your comment.
Comment: If $\forall x\in B_1(0)$ $\sum\frac{x(k)}{k!+t}\leq\sum\frac{1}{k!+t}=\sum\frac{x_0(k)}{k!+t}$ for some $x_0\in B_1(0)$, then what does it give? I don't see how to get a contradiction.
Comment: Sorry, could you please tell me one more thing: if instead of $c_0$ there was a $c$, I would like to consider $x_0(k)=(-1)^k$. But the same reasoning does not work out for him. Maybe there are other reasoning, or even a completely different example?
Comment: @thing this seems to be more complicated. I am not sure but I would still guess that the image of the closed unit ball is not closed.


Determine if entity type is fieldable

Question: Given an $entityTypeId as string, how can I determine if this entity type is fieldable? That is, if entities of that type implement FieldableEntityInterface?
Comment: Next question here, https://drupal.stackexchange.com/questions/243736/get-field-definitions-across-bundles-including-base-fields
Answer: There might be a simpler way but I think this should be pretty reliable:
<code>// Inject the entity_type.manager service instead if possible.
$class = \Drupal::entityTypeManager()
    ->getDefinition($entity_type_id)
    ->getOriginalClass();

$interface = 'Drupal\Core\Entity\FieldableEntityInterface';

if (in_array($interface, class_implements($class))) {
    ...
}
</code>
Comment: And even easier is to use the predefined method entityClassImplements() on the entity_type definition object, ->getDefinition()->entityClassImplements(FieldableEntityInterface::class)
Comment: Nice! Maybe `is_a($class, $interface, TRUE)` would be faster than `in_array()`?
Comment: @ya.teck it is quite correct, actually. That flag no longer exists. any content entity consists of fields. To be extra correct, you could check whether the storage implements https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21DynamicallyFieldableEntityStorageInterface.php/interface/DynamicallyFieldableEntityStorageInterface/8.3.x, but all content entities using the standard storage do. The field_ui flag key, as the name implies, only defines if and where field_ui should expose the UI. But even without UI, configurable fields will work as long as the storage implements it
Comment: I would clarify first what _fieldable_ stands for. In Drupal 7 terminology entity type becomes fieldable if it has "_fieldable_" key in its definition. Which means it accepts fields being attached to it. From this point the answer is not correct because in Drupal 8 **all** content entities implement _FieldableEntityInterface_ but not all of them are truly fieldable. You can check for _field_ui_ route to find out if it is possible to attach fields to a given entity type `$entity_type_definition->get('field_ui_base_route')`.
Comment: @donquixote Forgot that function even existed! Yeah it'd almost definitely be a bit faster to use `is_a`. Probably nothing earth shattering though
Comment: @Berdir Unrelated observation: I found that entityClassImplements() uses is_subclass_of(), not is_a(). See https://3v4l.org/ovN2g. This means that $definition->entityClassImplements(Node::class) will return false for node entity type. This is not a problem in this case because we are calling it with FieldableEntityInterface::class, and no entity type has this as the entity class.
Comment: @ya.teck In my case I am happy with any entity that implements FieldableEntityInterface. But the distinction is worth mentioning.
Comment: @donquixote yeah, that is an interesting thing to be aware of but very unlikely to be used that way, if you'd want to check for that, you could use getClass() or getOriginalClass() and just compare against that.
Answer: This might be a bit simpler:
<code>if (method_exists(\Drupal::entityTypeManager()->getDefinition($entity_type_id)->getOriginalClass(), 'hasField')) {
...
}
</code>

Determine if entity type is fieldable


What will happen to the current Bowl games when the playoff system commences?

Question: In 2014, the NCAA will switch from the current Bowl Game system for Division 1 football to a four-team playoff format wherein the top 4 teams will compete for the championship. Will the current Bowl Games (e.g: Rose Bowl, Cotton Bowl, Capitol One Bowl) still be played when this format change happens or will they disappear? It seems like if they disappear, only four teams would be competing at the end of the season, rather than the multitude of games that currently take place in the Bowl Game format. If it is the case that the Bowl Games no longer exist, are they also being replaced with another system to allow more teams opportunities for post-season play?
Answer: The NCAA states that the National Championship game will become the "Super Bowl" of college football...meaning any city can bid to host.
Two bowls will rotate among six in existence to host the playoff semifinals. The other four bowls who will not host a playoff semifinal in a given year will be host to bowl games among the best non-playoff teams.

Will the current Bowl Games (e.g: Rose Bowl, Cotton Bowl, Capitol One Bowl) still be played when this format change happens or will they disappear?

Yes, current bowl games will still be played.

Where will the games be played?
The two semifinals will rotate among
  six sites. The current BCS games are the Rose Bowl (Pasadena, Calif.),
  Sugar Bowl (New Orleans), Fiesta Bowl (Glendale, Ariz.) and Orange
  Bowl (Miami). The Cotton Bowl, now played at the state-of-the-art
  Cowboys Stadium in Arlington, Texas, has to be considered a
  front-runner to land one of the other two spots. Candidates for the
  other one? Try Atlanta and Jacksonville, Fla.
The championship game will become college football's Super Bowl. Any
  city can bid on it, even ones that host the semifinals and those that
  have not been traditional bowl sites. Expect most to be played in dome
  stadiums or warm-weather sites.
Comment: Does this also refer to all the smaller Bowl Games, like the Little Caesar's Pizza Bowl? I couldn't find anything saying either way on these.
Comment: As far as I understood, the other bowls not included with the playoff will continue untouched. Just speculation, but if the Little Caesar's Pizza Bowl is pushed out of Bowl season, it would most likely be due to bowl organizers and sponsoring vs. being excluded due to the playoff system.


An Inequality about complex numbers with non-negative real and imaginary parts

Question: Let $z_1,z_2  \dots dots z_n \in \mathbb{C} $ be such that the real and imaginary parts of each z_i are non-negative. Show that
$\Big|\sum_{i=1}^{n} z_i\Big| \geq\frac{1}{\sqrt{2}}\sum_{i=1}^{n} |z_i|$
I couldn't start this problem. I tried to get a geometric view of this but that didn't help
Comment: Does this answer your question? [A problem regarding the in-equality of complex numbers .](https://math.stackexchange.com/questions/3568751/a-problem-regarding-the-in-equality-of-complex-numbers)
Answer: You may use

$\sqrt{a+b}\leq \sqrt a + \sqrt b$ for $a,b \geq 0$ and
$(x+y)^2 \leq 2(x^2+y^2)$ (This is $2$-dimensional Cauchy-Schwarz inequality)

Let $z_k = x_k + iy_k$ for $k=1, \ldots , n$ where $x_k,y_k\geq 0$.
$$\left(\sum_{k=1}^n \lvert z_k \rvert\right)^2 =\left(\sum_{k=1}^n \sqrt{x_k^2 + y_k^2}\right)^2 \leq \left(\sum_{k=1}^n \left(x_k + y_k\right)\right)^2$$
$$= \left(\sum_{k=1}^n x_k + \sum_{k=1}^n  y_k\right)^2$$
$$\leq 2\left(\left(\sum_{k=1}^n x_k\right)^2 + \left(\sum_{k=1}^n  y_k\right)^2\right) = 2 \lvert \sum_{k=1}^n z_k \rvert^2$$


Como criar um sub submenu usando megamenu do bootstrap

Question: Alguém sabe como deva criar um sub submenu com megamenus?
Obrigado

        .navbar-default {
            color: #fff;
            background-color: #39b3d7;
            border-color: #269abc;
        }

        .navbar-default .navbar-nav > li > a {
            color: #fff;
        }

        .navbar-default .navbar-nav > .dropdown > a .caret {
            border-top-color: #fff;
            border-bottom-color: #fff;
        }

        .navbar-default .navbar-brand {
            color: #fff;
        }

        .menu-large {
            position: static !important;
        }

        .megamenu {
            padding: 20px 0px;
            width: 100%;
        }

        .megamenu> li > ul {
            padding: 0;
            margin: 0;
        }

        .megamenu> li > ul > li {
            list-style: none;
        }

        .megamenu> li > ul > li > a {
            display: block;
            padding: 3px 20px;
            clear: both;
            font-weight: normal;
            line-height: 1.428571429;
            color: #333333;
            white-space: normal;
        }

        .megamenu> li ul > li > a:hover,
        .megamenu> li ul > li > a:focus {
            text-decoration: none;
            color: #262626;
            background-color: #f5f5f5;
        }

        .megamenu.disabled > a,
        .megamenu.disabled > a:hover,
        .megamenu.disabled > a:focus {
            color: #999999;
        }

        .megamenu.disabled > a:hover,
        .megamenu.disabled > a:focus {
            text-decoration: none;
            background-color: transparent;
            background-image: none;
            filter: progid: DXImageTransform.Microsoft.gradient(enabled=false);
            cursor: not-allowed;
        }

        .megamenu.dropdown-header {
            color: #428bca;
            font-size: 18px;
        }

        @media (max-width: 768px) {
            .megamenu {
                margin-left: 0;
                margin-right: 0;
            }
            .megamenu> li {
                margin-bottom: 30px;
            }
            .megamenu> li:last-child {
                margin-bottom: 0;
            }
            .megamenu.dropdown-header {
                padding: 3px 15px !important;
            }
            .navbar-nav .open .dropdown-menu .dropdown-header {
                color: #fff;
            }
        }

Home

                         Dropdown

Answer: Por questões de design, não faz sentido por um submenu num mega-menu.
Depois, dê uma olhada nesse exemplo.
Comment: Não respondeu a pergunta principal amigo.
Comment: @GuilhermeSpinXO Ah, você é daqueles que gostam de respostas longas e digressivas. Desculpa! E não eu não sou seu amigo e nem vou incentivar PÉSSIMAS práticas de design, não se preocupe com isso. Bom senso quer dizer que nem todas as respostas devem ser respondidas ao pé da letra, você deveria saber disso, não?! A minha resposta final é essa: não coloque um submenu num MEGA MENU. Problemas de luso-brasileiros: sempre esquecem do conceito, das regras, do bom senso, dos princípios, dos fundamentos. Pare de ser um desses, faça-se um favor.
Comment: Opa, só falei por que talvez pessoas novas em design podem ficarem na dúvida. mas valeu por ser grosso deste jeito.


When does the singular value decomposition fail?

Question: Does the singular value decomposition ever not work? The statement of the associated theorem, here from Wikipedia, is surprisingly general. Are there certain conditions of the matrix $M$ that would make the decomposition fail to exist? The matrix M in question is a random matrix that is point-wise convergent.
Thanks so much!
Answer: Every real matrix has an SVD with real entries, every complex matrix has an SVD with complex entries. There are no further conditions.
Comment: That is amazing! Thank you!


Interval of convergence of $\sum^\infty_{n=1} \frac 1n (\frac{x-1}x)^n$

Question: $$\sum^\infty_{n=1} \frac 1n \left(\frac{x-1}x\right)^n$$
Questions: How to find interval of convergence? And is sum of the series continuous on the interval of convergence?
I know how to use ratio test for power series, but it's kind of strange power series. Give me advice, please.
addition: I notice that $x \neq 0 \notin $ interval of convergence.
Comment: This isn't a power series because you are dividing by $x^n$ terms.
Answer: Hint. Let $z=\frac{x-1}{x}$ and view it as a power series in $z$. Use what you know to find the interval convergence as a power series in $z$. Then solve for the interval of convergence in terms of $x$.
Answer: For $y=(x-1)/x$ you get the power series $\sum \frac{1}{n}y^n$ it will converge in a set of the form $|y|<R$. Then you can solve the inequality $|(x-1)/x|<R$ to get your answer.
Answer: Substitute some variable in for $\frac{x-1}{x}$, for example, $y=\frac{x-1}{x}$ Then use the ratio test, as you know how to do, to determine the interval of convergence for this:
$\sum_{n=1}^{\infty}\frac{y^n}{n}$
You will need to substitute $\frac{x-1}{x}$ back in for y when you have completed applying the test. Embedded expressions like that usually call for some kind of substitution.
It can be done like this:
$\lim_{n\rightarrow \infty}\left | \frac{\frac{y^{n+1}}{n+1}}{\frac{y^n}{n}} \right |= \lim_{n\rightarrow \infty}\left | \left ( \frac{n}{y^n}\left ( \frac{y^{n+1}}{n+1} \right ) \right ) \right |=\lim_{n\rightarrow \infty}\left | \frac{ny}{n+1} \right |=\left | y \right |\lim_{n\rightarrow \infty}\frac{n}{n+1}$.
Since the last limit above evaluates to 1, you are simply looking at $\left |y \right |$ < 1. (I set it less than one, because the ratio test definitely converges when the limit is less than one.) We can solve this by substituting our original value of $y$, which was $(x+1)/x$, back into the absolute value inequality and find the values of x that make the inequality true.


improving performance of behave tests

Question: We run behave BDD tests in our pipeline. We run the tests in the docker container as part of the jenkins pipeline. Currently it takes ~10 minutes to run all the tests. We are adding a lot of tests and in few months, it might go upto 30 minutes. It is outputting a lot of information. I believe that if I reduce the amount of information it outputs, I can get the tests to run faster. Is there a way to control the amount of information behave outputs? I want to print the information only if something fails.
I took a look at behave-parallel. Looks like it is in python 2.7. We are in python3.
I was looking at various options behave provides.
behave -verbose=false folderName  (I assumed that it will not output all the steps)
behave --logging-level=ERROR TQXYQ (I assumed it will print only if there is an error)
behave --logging-filter="Test Step" TQXYQ (I assumed it will print only the tests that has "Test Step" in it)
None of the above worked.
The current output looks like this
Scenario Outline: IsError is populated correctly based on Test Id -- @1.7   # TestName/Test.feature:187
    Given the test file folder is set to /TestName/steps/                              # common/common_steps.py:22 0.000s
    And Service is running                                                          # common/common_steps.py:10 0.000s
    Given request used is current.json                                              # common/common_steps.py:26 0.000s
    And request is modified to set X to q of type str                               # common/common_steps.py:111 0.000s
    And request is modified to set Y to null of type str                            # common/common_steps.py:111 0.000s
    And request is modified to set Z to USD of type str                             # common/common_steps.py:111 0.000s
    When make a modification request                                                # common/common_steps.py:37 0.203s
    Then it returns 200 status code                                                 # common/common_steps.py:47 0.000s
    And transformed result has IsError with 0 of type int                           # common/common_steps.py:92 0.000s
    And transformed result has ErrorMessages contain []                             # common/common_steps.py:52 0.000s
I want to print only all these things only if there is an error. If everything is passing, I don't want to display this information.
Comment: As you can see from the output the latency comes from a request while all other steps finish within a millisecond. So, don't expect the speed to increase significantly if you reduce the output.
Comment: Thanks Klaus. I can also run the tests in separate containers to see whether it reduces the time.
Answer: I think the default log level INFO will not impact the performance of your tests.
I am also using docker container to run the regression suite and it takes about 2 hours to run 2300 test scenarios. It took nearly a day before and here is what I did :
1. Run all test suite parallel.
This is the most important reason that will reduce the execution time.
We spent a lot of efforts to turn the regression suite to be parallel-able.
- make atomic, autonomous and independent tests so that you can run all your tests in parallel effectively.
- create a parallel runner to run tests on multiple processes. I am using multiprocessing and subprocessing libraries to do this.
I would not recommend behave-parallel because it is no longer active supported.
You can refer to this link :
http://blog.crevise.com/2018/02/executing-parallel-tests-using-behave.html?m=1
- using Docker Swarm to add more nodes into Selenium Grid.
You can scale up to add more nodes and the maximum numbers of nodes depend on the number of cpus. The best practice is number of node = number of cpu.
I have 4 PCs , each has 4 cores so I can scale up to  1 hub and 15 nodes.
2. Optimize synchronization in your framework.
Remove time.sleep()
Remove implicitly wait. Use explicitly wait instead.
Hope it helps.
Comment: Hi Thach Hoang. Thanks for your response. I am starting with running the same test in multiple containers to check whether it works ok. Unfortunately the containers become slower when running in parallel. We have 2 services (one for running the test and the other for actual service to be tested). I have 4 containers (2 containers for each service). First test container talks to first service. second test container talks to second service. They are running in parallel. Have you come across this? I read that, there is a chance this can happen as containers share the same kernel space.
Comment: Hi @Bala , I assume that you have 4 containers on the same docker host. 2 containers for testing and the others for AUT. In this scenario, you need to create 2 separate network for each application using user-defined bridge networks. $ docker network create --driver bridge custom-net1 . The first test container and the first app container will be assigned to this network. The second test container and second app container need to be assigned in different network like custom-net2. So test1 can only reach app1, test2 only reaches app2. Hope it helps.
Comment: Also, please make sure your PC performance is still good  when running all containers, check your CPU percentages. If you have other PCs available , I would suggest to use Docker Swarm for more resources.
Comment: reference link for you: https://docs.docker.com/network/network-tutorial-standalone/#use-user-defined-bridge-networks
Comment: Thank you so much Thach. That makes sense. I missed the part where we need to create different networks. I will do that and let you know. Thanks again.
Comment: @ThachHoang can you share what you did for : `- create a parallel runner to run tests on multiple processes. I am using multiprocessing and subprocessing libraries to do this.`
Answer: Well I have solved this in a traditional way, but I m not sure how effective it could be. I just started this yesterday and now trying to work on building the reports out of it. Approach as below, suggestions welcome
this solves the parallel execution at the example driven as well.
parallel_behave.py
Run command (mimics all the params of behave command)
py parallel_behave.py -t -d -f ......
initial_command = 'behave -d -t <tags>'
'''
the above command returns the eligible cases. may not be the right approach,                  but works well for me
'''

r = subprocess.Popen(initial_command.split(' '), stdout=subprocess.PIPE, bufsize=0)
finalsclist = []

_tmpstr=''
for out in r.stdout:
    out = out.decode('utf-8')
    # print(out.decode('utf-8'))
    if shellout.startswith('[') :
        _tmpstr+=out
    if shellout.startswith('{') :
        _tmpstr+=out
    if shellout.startswith(']'):
        _tmpstr+=out
        break

scenarionamedt = json.loads(_tmpstr)

for sc in scenarionamedt:
    [finalsclist.append(s['name']) for s in sc['elements']]

now the finalsclist contains the scenario name
ts = int(timestamp.timestamp)
def foo:
   cmd = "behave -n '{}' -o ./report/output{}.json".format(scenarioname,ts)

pool = Pool(<derive based on the power of the processor>)
pool.map(foo, finalsclist)

this will create that many processes of individual behave calls and generate the json output under report folder
*** there was a reference from https://github.com/hugeinc/behave-parallel but this is at the feature level. I just extended it to the scenarios and example ****

improving performance of behave tests


How can I prevent clipping when using a microphone with a tube amp into a PA?

Question: This weekend I played electric guitar through a 25 watt tube amp through a PA system. This was the setup (telecaster > tube amp > microphone > PA). The sound guys asked me to turn my tube amp down to prevent clipping. However, tube amps have to be played at a higher volume to get the best tone. I bought a low wattage amp so that I could turn it up and get that sweet tube tone. How can I prevent clipping when using a microphone with a tube amp into a PA, without turning the volume down so low that the tubes don't sound their best?
Comment: What constitutes the best tone is subjective, and regardless of that, in a live show with a whole band, would you say that having the best possible tone for one instrument is more important than any other part of the sound?
Comment: The sound guys' job is to reproduce your sound exactly through the p.a. That's it - unless you ask for anything different. If your sound is already clipping, that's what the p.a. has to emulate. If it's clipping again, the main reason is the gain on that mic is too high. For a lot of folks, distortion = too loud. Used to be true, 60 yrs ago...
Comment: Need details: What kind of mic(s) were they using? Did you have an independent channel allocated to your amp? What kind of wattage was the PA system? How big is the venue? Is there a low power mode on your amp? 25 is actually a lot of watts to push breakup and expect sane volumes at the same time.
Answer: As already said, mic-preamp clipping cannot possibly be an issue if you use any amp that's legal to operate without a strategic weapons license, and the sound guys know what they're doing. I would add three possible things to joseem's list, that might be the real issue:

The sound guys were using the same channel for different purposes (e.g. before you for an acoustic guitar with low-output DI), and didn't want to recalibrate the gain. That boils down to lazyness on their part.
The sound guys were pure classical-music tonmeisters and are adamant that all distortion is wrong. Note that amp overdrive is in fact clipping too, only, tubes clip much more subtly and guitar cabinets are designed so this is no actual problem (indeed it's of course desired in many styles!). Still, if you considered a guitar amp a pure sound-transmission device, this distortion would be a technical error. This was certainly a problem many of the early psychedelic bands had: record companies would send back demos with extreme distortion and feedback as "damaged". But... that any sound guy today – classical or otherwise – would still be oblivious of artistic use of distortion, seems highly unlikely.
Perhaps not quite so unlikely: the sound guys outright lied at you. They just wanted your amp quieter, and used the clipping pretence so you couldn't be personally offended at this. Granted, 25 W is on the low end of the amps power scale, but these can still be pretty loud. And as a sound engineer, you usually want the sound level on stage as quiet as possible. Perhaps you had a singer who struggled hearing themselves in the monitors? Or some hard-to-mic acoustic instrument?
These are good reasons not to have even a 25 W amp turned full up bleeding in the mics, and it's quite possible that the overall sound did in fact benefit from turning the amp down. Tube-powerstage distortion may be the ne plus ultra in terms of guitar sound, but overall a cheap amp with transistor power stage may still serve a band better if it can be better balanced in the mix.
Comment: If this weren't here, I would have just answered with point 6. Either the sound guys were incompetent or they were lying. Assuming they were competent, it's always good to trust the sound staff and accommodate their requests as best as possible.
Comment: I support the thesis that the sound guy tried to keep the general stage volume low. 25W is (technically) not much quieter than 100W. Solutions include: Power Surges and Isolation Speakers :)
Comment: It always pays out to be nice to them ... in the end they can completely ruin your gig if you get on the wrong terms with them.
Answer: Get better sound guys.
Clipping is an electronic phenomenon when the input signal is too hot for the circuitry, so the tops and bottoms of the waveform are getting shaved off. (This is bad because speakers don't like constant voltages at anything other than 0V.) Microphone signals are far below the line level that the mixer is operating on, so the only way this could be happening is if the microphone preamp is set too high. Any sound guy who knows how a mixer works should be able to make the appropriate adjustment to bring the level down to within bounds.
The only other thing that could be happening is that if the microphone was being overdriven by sheer volume of output from your guitar amp. This would be a mechanical phenomenon (at the point of the element in the microphone that picks up sound vibrations from the air), not an electronic one, and would result in a bad sound from the mic no matter how low the preamp is set. But this shouldn't be called clipping, it should be called a broken or bad choice of microphone.
Sound techs routinely mic 100 watt cabinets turned up to 11 with a microphone placed right next to the speaker cone. There's only so much energy that can be transmitted over an air gap to a microphone capsule, and the mechanical limits of a microphone capsule should tolerate all reasonable ranges of this.
One more thing. It's possible that vibrations from your amp were being transmitted to the capsule through the floor and mic stand to the mic, or from the front grille of your amp to the capsule if they were physically in contact with one another. The air gap is important, and if the floor is a problem this can usually be solved with a piece of foam under the mic stand, but I've rarely seen this to be necessary. Some sound techs will actually suspend a mic in front of a speaker cabinet with the mic cable itself, just taping the cable to the top of the cab.
Comment: Well, maybe you can help them find the gain knob on the mixer
Comment: @Tarzan yes man, in that case of good natured volunteers: sometimes you need to step up and do their job for them. The amount of times I have had to do this at smaller shows or indie events is more than i can remember. Its easier to swap geetar then walk up and cool down the signal than it is to play "telephone" back and forth from stage while they fumble with levels. They don't necessarily like it....but....that's the reality.
Comment: I wish I could get better sound guys but they are all volunteers. This has its pros and cons.
Answer: Clipping in this situation could be caused by:
1) the microphone not being the most appropriate to the task at hand, and not being able to capture your audio without, well, clipping. Positioning the mike further away from the amp could possibly lead to some working solution, but could bring other problems, like capturing other sources or ruining your sound any way (as mike distance and positioning in relation to the amp are very important factores in the overall resulting sound). So ensuring that a proper mike for guitar amping (the Sure SM57 would be the default) is used is the only sure proof solution for this part of the problem
2) the PA system is not very good and is not able to deal with the incoming signal. I find this highly improbable, as any mixer worthy of the name will have a combination of inputs for different levels of input signal and an input gain control for each chanel. If the input signal is to loud, you just lower the knob, that's what it's there for.
3) The PA guys didn't have a clue to what they were doing, didn't understand what you were trying to achieve, or didn't care (or any combination of these).
Comment: I think we are using a Sure SM57 microphone. I will try lowering the input signal knob since that's what it's there for. It's very probable that the PA guys are clueless. I appreciate your insight.
Comment: @Tarzan There is no way that an SM57 would clip so easily. That mic is designed to take crushing levels of pressure -- like, an inch away from a pegged 100w cab or heavy handed snare, np.
Answer: Two options not mentioned so far are:

Run another amp and cab offstage and mic that one. This does require a signal splitter, so you can get the tone you want on stage, while doing something different offstage. This doubles the kit, so can double your costs, as well as requiring somewhere to mic up that other amp...
Use an attenuator (often called Power Brakes) before your cabinet, so you still run your power amp hot, but don't drive the speaker cones as loud. These can be really good (look for Marshall Power Brake, or Gibson Power Stealth)

These both require a bit of extra kit - an attenuator isn't big, but it can cost a couple of hundred pounds (or dollars)
Comment: We use Aviom in ear monitors so that's not a concern. I will look into the power brakes. Thanks!
Comment: @Tarzan I would be *EXTREMELY* worried about combining IEMs with inexperienced and clueless soundmen.  At least with a pair of monitor wedges you know where you are, and they only have to run at most two foldback channels.  If they're inexperienced, trying to handle a half-dozen sets of IEM feeds *and* FOH is likely to push them over the edge.  KISS... :)
Answer: If your board has VU meters (input level meters), that would be a great way to determine if the mic is clipping your signal. If there is audible clipping before your meter indicates your signal is in the red or reaching 0dB then you know your mic is the problem, or the signal before the mic (which seems unlikely unless your amp is actually acting up). If the VU meter is actually in the red or above 0dB, then your gain is too high. Pull the gain back because everything the mixer does to the signal happens after gain.
Make sure your fader is at 0 or nominal, turn off all processing, effects, gating, compression, EQ, etc. before the test so you can hear clearly what the signal coming in to the board (plus gain) is like. Make your gain adjustments off the raw signal, then turn anything else back on once you have your source signal squared away. Keep playing as the board operator turns things back on so you can hear if something else is giving you trouble.
Edit: During your test you should play as hard as you expect the peak of your music to be so the gain structure is based off the peak signal, not the average.


Detect existance of function using `concepts` and not `type_traits`

Question: In a c++ program decisions are made compile time depending on if a specific overload of the function func exists.
Examples of func overload signatures are
void func(M);
void func(M, C);
void func(M<D>, E, F);
...

where M and A - F are user defined types.
This is solved with the use of type_traits and specifically std::void_t as illustrated in the following self contained program.
#include <type_traits>
#include <iostream>

// Dummy structs
struct A{};
struct B{};
struct C{};
struct D{};
struct E{};
struct F{};

template<typename I>
struct M{};

namespace fun {
// Functions we lik to detect compile time
  void func(M){}
  void func(M, C){}
  void func(M<D>, E, F){}
}

// Compile time check if 'func' with specific arguments exists.
//
namespace find_function {
namespace internal {

// Template variable func that defaults to false.
//
template <typename, typename = void, typename...>
constexpr bool func = false;

// Specialization of template variable func.
// The template argument std::void_t<decltype(transform::func(std::declval<Arg1>(), std::declval<SomeState>()...))>
// has the type 'void' if the decltype expression is valid after substitution.
//
template <typename Arg1, typename... SomeState>
constexpr bool func<Arg1,
                    std::void_t<decltype(fun::func(std::declval<Arg1>(), std::declval<SomeState>()...))>,
                    SomeState...> = true;
} // namespace internal

// Interface variable to internal::func.
// template arguments, Arg1, void, SomeState..., will match the specialization above if the decltype expression can be evaluated and
// find_function::func will evaluate to true. Else find_function::func will be false.
//
template <typename Arg1, typename... SomeState>
constexpr bool func = internal::func<Arg1, void, SomeState...>;

} // namespace find_function

int main() {
  if constexpr (find_function::func<M> && find_function::func<M, C> && find_function::func<M<D>, E, F>) {
    std::cout << "Exists" << std::endl;
  }
  if constexpr (!find_function::func<M, B, C>) {
    std::cout << "Does not exist" << std::endl;
  }
}

Note that main contains a rather ridiculous use of the functionality. In a real situation the template arguments of find_function::func would be deduced in recursive template context.
My question is if there is a way of writing this code using concepts and not std::void_t? I'm not looking for a solution using enable_if that I find even more difficult to read compared to the presented solution.
Comment: `requires (M ma, B b, C c) { fun::func(ma, b, c); }`?
Comment: @Jarod42, Maybe I could have been more clear. I'm looking for a solution that has the ability to detect the complete set of overloads described `void func(M);` `void func(M, C);`, void `func(M, E, F);` etc. Just like the presented solution. I will update `main` to make that more clear.
Answer: As Jarod42 said (and adjusting for the slightly changed question), you can just do it like this:
template <class... Ts>
concept func = requires(Ts ... vs)
{
    fun::func(vs...);
};

demo


Debugging custom database queries

Question: Is there a convenient way to ask a particular database object to print its query?
Every now and then, I write a DBTNG db_op() in a module, and far to often, I don't quite get the queries right.
I know that devel can output the query log, but that's all queries, which, in this type of situation, is a problem more often than not.
I want to do
$result = db_select('node', 'n')->fields('n')->execute();
dpm($result->queryWithParameters);
dpm($result->finalQuery);

Answer: There is a dpq() function in the devel module which seems to fulfill this need.

Print a SQL string from a DBTNG Query object. Includes quoted arguments.
Comment: I'd give this +100 if I could, never seen that function before
Comment: You could have had, if you offered a bounty. `;)`
Answer: I know this is an old question but hopefully this answer might be useful to other people: basically Drupal core has its own DatabaseLog class. You could use it in cases where you don't have Devel module available (like maybe production debugging of slow queries?):
Database::startLog('my_custom_key');
// do some SQL operations here...
// print the queries
print_r(Database::getLog('my_custom_key'));

Debugging custom database queries


form_comment_form_alter modify comment body

Question: I am using hook_form_comment_form_alter to add values to the textboxes in the commenting form. But in the comment body I can seem to add a default value
and can't seem to find a value that I can change. Does anyone have any ideas?
function mytheme_form_comment_form_alter(&$form, &$form_state, $form_id) {
  dpm(get_defined_vars());
  $form['author']['name']['#title'] = "";
  $form['author']['name']['#default_value'] = "Name";
  $form['author']['name']['#title'] = "";
  $form['author']['mail']['#default_value'] = "Email";
  $form['author']['mail']['#title'] = "";
  $form['author']['homepage']['#default_value'] = "Website";
  $form['author']['homepage']['#title'] = "";
  $form['author']['subject']['#default_value'] = "Subject";
  //$form['comment_body']['need default value']= 'I need to add a value';
}

Answer: To add default value to your comment form body use the following snippet,
 $form['comment_body'][LANGUAGE_NONE][0]['#default_value'] = "Your default value";

Comment: I think you should use *LANGUAGE_NONE* constant instead of directly using 'und'
Comment: @mathan you re right, i edited my answer


Views 3 | How to programatically unset or add new value to a view's footer / header display?

Question: I have added 1 view display into my view's footer via "Global: View area | The view to insert into this area." and a regular "Global: Text area".
So my view has 2 footer displays, one being another view display and the other a normal text area.
Now I want to unset/hide either one of the footer display based on a condition, perhaps via hook_views_pre_render()
I was expecting to find documentation on something like:
$view->display['MY_VIEW_DISPLAY_ID']->handler->handlers['footer']['FOOTER_DISPLAY_ID']->unset_display();

But obviously that is not the way to go. Is it possible to accomplish that via hook_views_pre_render() or any other means? If so, how?
Answer: The snap code below has been tested only on D7. In case this code does not work on D6, check out the comments on this post here.
function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == 'VIEW_NAME' && $display_id == 'DISPLAY_ID') {

    // To find out the DISPLAY_NAME, FIELD_NAME and FIELD_VALUE use the devel module function
    // below to print them out.
    // Replacing 'footer' by 'header' works the same way.
    dpm($view->display_handler->options['footer']['DISPLAY_NAME']['FIELD_NAME']);

    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'FIELD_NAME', 'FIELD_VALUE');

    // In this case scenario you needed to unset the footer display.
    // For the embedded view display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'view_to_insert', '');
    // For the normal text area display you do like this:
    $view->set_item_option($display_id, 'footer', 'DISPLAY_NAME', 'content', '');
  }
}

Due to comments, to determine what views name and display came to this function, make next (of course, "devel" module should be enabled)
    function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
      dsm($view->name);
      dsm($display_id);
      if ($view->name == 'VIEW_NAME' && $display_id == 'DISPLAY_ID') {
...
      }
    }

And update views page.
Comment: The snap code you've posted initially did not work but the link you posted along with it led me to the answer I was looking for. Thank you.

I have updated your answer.
Comment: To find out the `DISPLAY_NAME`, you can use `dpm($view->display_handler->get_option('footer'));`.
Comment: Make sure you are implementing hook_views_pre_view() --- this code only seems to work there, and not in other hooks like hook_views_pre_render().
Answer: Views 3 example of adding some text to existing header programatically:
/**
 * Implements hook_views_pre_render().
 */
function MYMODULE_views_pre_render(&$view) {
  $header_item = $view->get_item('default', 'header', 'text');
  $view->set_item_option('default', 'header', 'text', 'content', 'MY TEXT' . $header_item['content']);
}

Here is another example using hook_views_pre_view:
/**
 * Implements hook_views_pre_view().
 */
function MYMODULE_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == 'my_view') {
    // Unset: Global: Text area
    $view->display_handler->set_option('empty', NULL);

    /* Programatically update the 'No results behavior' by inserting another view. */

    // Example 1
    $options = array(
        'id' => 'view',
        'table' => 'views',
        'field' => 'view',
        'empty' => TRUE,
        'view_to_insert' => 'new_view:page',
    );
    $view->display_handler->set_option('empty', array('view' => $options));

    // Example 2
    $view->set_item_option($display_id, 'empty', 'view', 'id', 'view');
    $view->set_item_option($display_id, 'empty', 'view', 'table', 'views');
    $view->set_item_option($display_id, 'empty', 'view', 'field', 'view');
    $view->set_item_option($display_id, 'empty', 'view', 'empty', TRUE);
    $view->set_item_option($display_id, 'empty', 'view', 'view_to_insert', 'new_view:page');
  }
}


Estimation Error Calculation

Question: I'm learning about variance reduction for Monte Carlo methods and I am confused about how to calculate the "estimation error" of a given method.
My question is how should I interpret "Estimation Error" given the context below?
In my textbook, there is the following setup:
We have a Random Variable ${X}$ with a given distribution. Our goal is to approximate ${E[h(X)]}$ via Monte-Carlo and calculate the "Estimation Error" of our estimate.
First Approach
Using Simple Random Sample (naive) Monte Carlo, we draw a simple random sample of size ${N}$ from the target distribution of ${X}$ (in the textbook example this is a normal distribution and we use an R function to get the random draws). We then approximate ${E[h(X)]}$ via ${\Sigma_i \frac{h(X_i)}{N}}$.
Then the textbook gives the "Estimation Error" as ${\sqrt{\frac{s^2(h(\dot{X}))}{N}}}$, where ${\dot{X}}$ is the vector of sample points and ${s^2(*)}$ is the sample variance function.
To me this makes sense. Because we are sampling directly from the distribution of ${X}$, variation within a sample will be the same as the variation across samples. So, ${\hat{Var}(\hat{E}[h(X)])}$ can be approximated with just one sample.
Second Approach (Stratified Sampling)
In place of Simple Random Sampling, we now divide the distribution of ${X}$ into ${N}$ strata and take a single sample point ${X_i}$ from each stratum. The sample points are chosen uniformly within the limits of each stratum. (For example if the target distribution was uniform between 0 and 10 and we divided the space into 5 strata, then the second sample point would be taken uniformly between 2 and 4. these are sampled uniformly between the limits of the stratum). The strata are chosen by evenly dividing the interval ${(0,1)}$ into ${N}$ segments, then computing ${F^{-1}(p_i)}$ where ${p_i}$ are the end points of the ${N}$ segments. This makes ${P(X_i \epsilon A_i)}$ equal to ${1/N}$ for each strata ${A_i}$
The textbook says to use the same formula from the first approach for both the estimator of ${E[h(X)]}$ and the "estimation error" of the second approach.
To me it makes sense that, under stratified sampling, ${\hat{E}[h(X)]}$ is still ${\Sigma_i \frac{h(X_i)}{N}}$. This is because we've chosen the strata in such a way that ${P(X_i\epsilon A_i) = \frac{1}{N}}$ and we only have a single sample point from each stratum.
However, using the same "estimation error" calculation doesn't make sense to me. The variance within a particular stratified sample (one run of the experiment), ${s^2(h(\dot{X}))}$ must be quite a bit wider than the variance across multiple samples, ${s^2(\hat{E}[h(X)])}$ because stratification ensures our samples spread the whole distribution each time; So ${h(\dot{X})}$ will be very wide in a single sample. However, ${\dot{X}}$ won't jiggle around much across samples so we will get very nearly the same value for ${\hat{E}[h(X)]}$ in each run of the experiment (i.e. the "estimation error" doesn't seem to capture the variation of the estimator).
Is the book misusing "estimation error", or am I missing something?
Comment: It seems indeed most bizarre to suggest using the stratified sample in the standard deviation as if nothing changed from iid sampling circumstances...
Comment: Could you please provide the reference of the textbook and/or a screenshot of the quote?
Answer:
The mean of the stratified estimator is
$$\frac{1}{N}\sum_i \mathbb{E}[h(X_i)] = \frac{1}{N}\sum_i \int_{A_i}h(x_i)Nf(x_i)\text dx_i=\int_{\cup_iA_i}h(x)f(x)\text dx=\mathbb{E}[h(X)]$$
The variance of the stratified estimator is
$$\frac{1}{N^2}\sum_i \text{var}[h(X_i)]$$
and also
$$\frac{1}{N^2}\sum_i \mathbb{E}[h(X_i)^2]
+ \frac{1}{N^2}\sum_{i\ne j} \mathbb{E}[h(X_i)]\mathbb{E}[h(X_j)]
-\frac{1}{N} \mathbb{E}[h(X)]^2\\
=\frac{1}{N^2}\sum_i \mathbb{E}[h(X_i)^2] + \frac{1}{N}\sum_{i} \mathbb{E}[h(X_i)] \mathbb{E}[h(X)]\\
- \frac{1}{N^2}\sum_{i} \mathbb{E}[h(X_i)]^2 -\frac{1}{N} \mathbb{E}[h(X)]^2\\
=\frac{1}{N^2}\sum_i \mathbb{E}[h(X_i)^2] + \frac{N-1}{N}\mathbb{E}[h(X)]^2- \frac{1}{N^2}\sum_{i} \mathbb{E}[h(X_i)]^2
$$
While the first term can be (unbiasedly) estimated by a single stratified sample, both other terms require two single stratified samples to produce an unbiased estimate, as requested in the above 1973 JASA paper. (If the strata are regular enough to enjoy symmetry a second sample could be deduced from the first one by applying this (or these) symmetry move(s) but I am unsure a reliable variance could be deduced because of the symmetry and hence dependence between both samples.)
Comment: This makes sense to me. I wondered if maybe they were meaning that the estimate of the population variance also converges or something like that. I think it is probably an error though.

Estimation Error Calculation


Why I'm getting this error in swift 3.0

Question:
binary operator '&' cannot be applied to two bool operands

Here I'm sharing my code.
@IBOutlet weak var fnameTxt: UITextField!
@IBOutlet weak var lnameTxt: UITextField!
@IBOutlet weak var addrsTxt: UITextField!

if (fnameTxt.validate()) & (lnameTxt.validate()) & (addrsTxt.validate()){
 print("successfully validated")
}else{
 print("validation failed")
}

-(BOOL)validate{
    if(isMandatory){
        if([self.text length]==0){
            [self showErrorIconForMsg:strLengthValidationMsg];
            return NO;
        }
    }
    for (int i=0; i<[arrRegx count]; i++) {
        NSDictionary *dic=[arrRegx objectAtIndex:i];
        if([dic objectForKey:@"confirm"]){
            TextFieldValidator *txtConfirm=[dic objectForKey:@"confirm"];
            if(![txtConfirm.text isEqualToString:self.text]){
                [self showErrorIconForMsg:[dic objectForKey:@"msg"]];
                return NO;
            }
        }else if(![[dic objectForKey:@"regx"] isEqualToString:@""] && [self.text length]!=0 && ![self validateString:self.text withRegex:[dic objectForKey:@"regx"]]){
            [self showErrorIconForMsg:[dic objectForKey:@"msg"]];
            return NO;
        }
    }
    self.rightView=nil;
    return YES;
}

Here, validate() returns boolean value,any idea on this??
Comment: Replace `&` with `&&`
Comment: see this for e.g https://stackoverflow.com/questions/44154040/binary-operator-cannot-be-applied-to-two-bool-operands-in-swift
Comment: @Jon Snow when i replace &&, It's not validating all three input textfields. I want to validate three at a time
Comment: That's your logical error please add code of  `validate()`
Comment: @JonSnow, I added my validate().. plz check
Answer: A single ampersand ('&') is for doing bitwise operations. From the question that you have asked it seems you intended to use the logical AND operator ('&&'). So replace & with && like
if (fnameTxt.validate()) && (lnameTxt.validate()) && (addrsTxt.validate()){
 print("successfully validated")
}else{
 print("validation failed")
}

Comment: Good explanation.
Comment: @Aravind, I tried with && also, when I use &&, it validating one after other. i.e, 'fnameTxt' is validated then only it checking the 'lnameTxt'. I want to validate 3 at a time..
Comment: @Nagaraju yup when you use && it will be validated one after the other, I don't think there is any operation that could allow you to validate all the 3 at a time.
Answer: Pleas use && instead &.
i.e,
if ((fnameTxt.validate()) && (lnameTxt.validate()) && (addrsTxt.validate())){
 print("successfully validated")
}else{
 print("validation failed")
}

Comment: Hi Karthik, when I use &&, it validating one after other. i.e, 'fnameTxt' is validated then only it checking the 'lnameTxt'. I want to validate 3 at a time..
Comment: We cannot simultaneously do  all the validation stuff together. I think you have three textfields and a button. If you enable the button after validating all the three textfields(means all the fields are mandatory), then the above code is enough. If you show any error message or red border around the textfield to inform the user about the validation. Then you can use textfields textchange events and put the desired code there(please see the link https://stackoverflow.com/questions/28394933/how-do-i-check-when-a-uitextfield-changes)
Answer:
You can't use bitwise operators to compare two operands, if you want to compare, you should use logical operators. So instead of & use &&.

Also, I would like to suggest you:
As you have a common validate() function for all of your UITextFields I would suggest you make a function signature like this.
class func validates(textFields: Array<UITextField>) -> Bool {
    //Return true or false based on the validation.
    textFields.forEach { (textField) in {
        //do something with each of the textField in textFields array.
    }
}

In that way, you can simply, check like this
if UITextField.validates([fnameTxt, lnameTxt, addrsTxt]) {
    //Go ahead!
} else {
   //Handle the invalidation.
}

Note: As validates() is a class function you can directly access it with the class name.

Why I'm getting this error in swift 3.0


Cron expression in Spring, validation?

Question: So I need a Cron expression which will run my service in following interval:
-every 2h;
-during work hours 9-17h;
-only on work days MON-FRI;
-every month;
-of every year;
I've come up with this:
@Scheduled(* * 0/2 * * MON-FRI)
public Object updateDB() {

    controllerImpl.updateDB();

    return new Object();

}

Answer: I think the problem here s every 2 hours between 9-17h, isn't it?
Try this:
@Scheduled(* * 9-17/2 * * MON-FRI)

Comment: As in above comment, service annotated with `@Scheduled(cron="* * 9-17/2 * * MON-FRI", zone="Europe/someCapitalCity")`   is not working
Answer: You can try following cron expression:
@Scheduled(* * 9-17/2 ? * MON-FRI)

For future references you can use following to create your cron expression:
https://www.freeformatter.com/cron-expression-generator-quartz.html
Comment: If you have tested it, can you please share what does it results in?
Comment: Thanks for the link. Expression looks correct. I'll test it and once I confirm, I'll upvote you answer.
Comment: Sorry for the late response bud, well I just set some simple `System,.out::println` just to see will the service be called and it didn't...
Comment: Are you using springboot. If yes, is the class where you have @Scheduled, annotated as @Component?
Comment: The class which contains `@Scheduled` method, is annotated with `@Controller` which is in turn a `@Component`, if I'm not mistaken...And main class has `@EnableScheduling`...

Cron expression in Spring, validation?