text:
Q: rpmbuild can't change into directory I have been trying to figure out how to build an rpm for the past 6 months and I still struggle trying to understand what I am missing with my build. My goal is to have my rpm install a tar.gz file.
Here is my .rpmmacros file
%_topdir      %(echo $HOME)/rpmbuild
%_smp_mflags  -j3
%__arch_install_post   /usr/lib/rpm/check-rpaths   /usr/lib/rpm/check-buildroot
%_tmppath  %{_topdir}/tmp

Here is my spec file
Summary: Appadm Monitoring
Name: AppadmQ
Version: 1
Release: 1
Source0: AppadmQ-1-1.tar.gz
License: GPL
Group:
BuildArch: noarch
BuildRoot: %{_builddir}/%{name}_%{version}.%{release}-root/
%description
%prep
%setup -n AppadmQ-1
%build
%install
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
mkdir $RPM_BUILD_ROOT
if [ -d $RPM_BUILD_ROOT ]; then
   mkdir $RPM_BUILD_ROOT/tmp
   cp -af AppadmQ-1-1.tar.gz $RPM_BUILD_ROOT/tmp
   tar -xvzf $RPM_BUILD_ROOT/tmp/AppadmQ-1-1.tar.gz
else
   echo "NO BUILD ROOT... nothing built."
   exit 1
fi;

%clean
[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}

%post
echo " "
echo "SUCCESS!"
%files

Here is what happens when I try to build the rpm
 Executing(%prep): /bin/sh -e /root/rpmbuild/tmp/rpm-tmp.sC0xn6
 + umask 022
 + cd /root/rpmbuild/BUILD
 + LANG=C
 + export LANG
 + unset DISPLAY
 + cd /root/rpmbuild/BUILD
 + rm -rf AppadmQ-1
 + /usr/bin/gzip -dc /root/rpmbuild/SOURCES/AppadmQ-1-1.tar.gz
 + /bin/tar -xvvf -
 drwxr-xr-x appadm/appadm     0 2013-11-11 15:35 home/appadm/
 -rw-r--r-- appadm/users    121 2011-10-11 03:25 home/appadm/.kshrc
 drwxr-xr-x appadm/appadm     0 2013-07-17 18:07 home/appadm/orwell/
 -r--r--r-- appadm/users   1837 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20004.stub
 -r--r--r-- appadm/users   1892 2010-10-22 15:07 home/appadm/orwell/irco_orwell_20052.stub
 -r--r--r-- appadm/users   1841 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20003.stub
 -r--r--r-- appadm/users   1975 2010-11-04 22:52 home/appadm/orwell/irco_orwell_20053.stub
 -rw-r--r-- appadm/users    996 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00409.stub
 -r--r--r-- appadm/users   3087 2011-12-30 14:06 home/appadm/orwell/irco_orwell_20032.stub
 -rw-r--r-- appadm/users   1098 2011-06-02 12:52 home/appadm/orwell/sys_orwell_00413.stub
 -rw-r--r-- appadm/users    994 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00410.stub
 -r--r--r-- appadm/users   1159 2013-07-17 18:07 home/appadm/orwell/irco_orwell_20037.stub
 -rw-r--r-- appadm/users    994 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00411.stub
 -r--r--r-- appadm/users   1535 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20002.stub
 -r--r--r-- appadm/users     11 2013-07-02 18:31 home/appadm/lanetypeCksum_baseline
 drwxrwxr-x appadm/appadm     0 2013-11-11 15:19 home/appadm/rat/
 -rwxr-xr-x appadm/users    406 2008-08-24 21:00 home/appadm/j7.sh
 -rw------- appadm/users     51 2013-01-30 17:24 home/appadm/.lesshst
 -rw-r----- appadm/users    276 2011-10-11 03:25 home/appadm/.profile
 -rwxr-xr-x appadm/users     53 2008-10-06 22:28 home/appadm/to2.sh
 -rwxr-xr-x appadm/users    229 2008-11-03 17:27 home/appadm/ipl.sh
 -rwxr-xr-x appadm/users    263 2008-10-16 16:26 home/appadm/longsql.sh
 -rwxr-xr-x appadm/users    162 2008-10-06 21:51 home/appadm/to.sh
 drwxr-xr-x appadm/appadm     0 2013-11-11 15:10 home/appadm/logs/
 -rwxr-xr-x appadm/users    160 2012-01-21 13:55 home/appadm/j.sh
 drwxr-xr-x appadm/appadm     0 2013-11-11 15:09 home/appadm/copient/
 -rwxr-xr-x appadm/users    514 2013-10-30 18:45 home/appadm/copient/ops_coptidy.pl
 -rw-r--r-- appadm/users     20 2011-12-22 09:50 home/appadm/copient/co_monitor2.txt
 -rwxr-xr-x appadm/users    170 2005-09-28 10:53 home/appadm/copient/ops_chklog.sh
 -rwxr-xr-x appadm/users  23290 2013-10-30 18:45 home/appadm/copient/ops_copiphourly.pl
 -rwxr-xr-x appadm/users    610 2009-08-19 17:42 home/appadm/copient/ops_coptidy.sh
 -rwxr-xr-x appadm/users     65 2013-11-11 15:08 home/appadm/copient/copient_phpver.php
 -rwxr-xr-x appadm/users    538 2008-12-10 17:00 home/appadm/copient/ops_appadm.exp
 -rwxr-xr-x appadm/users    866 2010-01-21 14:17 home/appadm/copient/copIP.sh
 -rwxr-xr-x appadm/users    706 2010-06-04 17:18 home/appadm/copient/ops_coproid.sh
 -rwxr-xr-x appadm/users   6413 2013-10-30 18:45 home/appadm/copient/ops_copdiscount.pl
 -rwxr-xr-x appadm/users    642 2009-06-09 11:09 home/appadm/copient/ops_copiphourly.sh
 -rwxr-xr-x appadm/users    293 2008-11-18 17:16 home/appadm/copient/ops_cksum.sh
 -rwxr-xr-- appadm/users    688 2012-08-19 19:12 home/appadm/copient/dbCurebkup.sh
 -rwxr-xr-x appadm/users  21993 2013-10-30 18:45 home/appadm/copient/ops_copresponse.pl
 -rwxr-xr-x appadm/users    259 2006-01-09 19:58 home/appadm/copient/ops_appadm_survey.sh
 -rwxr-xr-x appadm/users   3553 2013-10-30 18:45 home/appadm/copient/ops_copcard.pl
 -rwxr-xr-x appadm/users    704 2010-02-12 09:46 home/appadm/copient/ops_copresponse.sh
 -rwxr-xr-x appadm/users    670 2011-04-17 23:19 home/appadm/copient/ops_corpBrand.sh
 -rwxr--r-- appadm/users    111 2013-06-11 21:59 home/appadm/copient/c96766_EOC_fix.sh
 -rwxr--r-- appadm/users     73 2013-06-18 18:14 home/appadm/copient/IncentiveFetch_fix.sh
 -rwxr-xr-x appadm/users   2486 2012-10-08 14:21 home/appadm/copient/cop_cksum.sh
 -rwxr-xr-x appadm/users    681 2010-08-13 14:35 home/appadm/copient/cop_incentiveFetch.sh
 -rwxr-xr-x appadm/users  13119 2012-10-08 14:21 home/appadm/copient/cksumList
 -rwxr-xr-x appadm/users   2571 2012-02-21 16:13 home/appadm/copient/toastClipStore.pl
 -rwxr-xr-x appadm/users    357 2008-11-12 14:36 home/appadm/copient/ops_conf1.sh
 -rwxr-xr-x appadm/users   3865 2013-10-30 18:45 home/appadm/copient/ops_cop_avg_roids_per_cust.pl
 -rwxr-xr-x appadm/users    109 2006-04-17 11:40 home/appadm/copient/copient_ver.php
 -rwxr-xr-x appadm/users    323 2008-11-11 16:28 home/appadm/copient/ops_pgsql_cksum.sh
 -rwxr-xr-x appadm/users  39326 2013-10-30 18:45 home/appadm/copient/ops_corpBrands.pl
 -rwxr-xr-x appadm/users    647 2010-08-19 16:18 home/appadm/copient/ops_copcard.sh
 -rwxr-xr-x appadm/users    663 2005-05-31 15:53 home/appadm/copient/ops_copient.exp
 -rwxr-x--- appadm/users    691 2006-03-24 12:40 home/appadm/copient/terminals.pl
 -rwxr-xr-x appadm/users   6847 2013-08-23 15:42 home/appadm/copient/co_monitor2.sh
 -rw-r--r-- appadm/users   1310 2008-09-21 13:45 home/appadm/tidy.pl
 drwx------ appadm/appadm     0 2013-11-11 15:19 home/appadm/.ssh/
 drwxr----- appadm/appadm     0 2012-04-30 14:42 home/appadm/.pki/
 drwxr----- appadm/appadm     0 2012-04-30 14:42 home/appadm/.pki/nssdb/
 -rw------- appadm/users   9703 2013-10-21 14:29 home/appadm/.viminfo
 -rwxr-xr-x appadm/users   1955 2008-10-06 21:51 home/appadm/to.pl
 -rw------- appadm/users     30 2012-10-19 17:16 home/appadm/.php_history
 drwxr-xr-x appadm/appadm     0 2013-11-11 15:05 home/appadm/bin/
 -rwxr-xr-x appadm/users    172 2007-07-16 18:30 home/appadm/bin/ops_chklog.sh
 -rwxr-xr-x appadm/users    190 2013-10-30 18:45 home/appadm/bin/ops_copPhonehome.sh
 -rwxr-xr-x appadm/users    229 2013-10-30 18:45 home/appadm/bin/ops_Q_coproid.sh
 -rwxr-xr-x appadm/users    362 2013-10-30 18:45 home/appadm/bin/ops_Q_copOld_customer_data.sh
 -rwxr-xr-x appadm/users    292 2011-07-26 09:14 home/appadm/bin/ops_appadm.exp
 -rwxr-xr-x appadm/users    167 2013-10-30 18:45 home/appadm/bin/ops_copSanity.sh
 -rwxr-xr-x appadm/users   4483 2013-10-30 18:45 home/appadm/bin/qtySCO.pl
 -rwxr-xr-x appadm/users    607 2013-10-30 18:45 home/appadm/bin/ops_Q_copLook_for_coupon_time_outs.sh
 -rwxr-xr-x appadm/users    426 2011-08-12 18:20 home/appadm/bin/ops_appadm_ssh.exp
 -rwxr-xr-x appadm/users    261 2007-07-16 18:30 home/appadm/bin/ops_appadm_survey.sh
 -rwxr-xr-x appadm/users    215 2013-10-30 18:45 home/appadm/bin/ops_Q_copBrand.sh
 -rwxr-xr-x appadm/users   1811 2013-10-30 18:45 home/appadm/bin/ops_copCksum.sh
 -rwxr-xr-x appadm/users    237 2013-10-30 18:45 home/appadm/bin/ops_Q_coptidy.sh
 -rwxr-xr-x appadm/users  39646 2013-10-30 18:45 home/appadm/bin/ops_Q.sh
 -rwxr-xr-x appadm/users   1238 2007-12-20 09:27 home/appadm/bin/ops_remote.pl
 -rwxr-xr-x appadm/users    222 2013-10-30 18:45 home/appadm/bin/ops_Q_copresponse.sh
 -rwxr-xr-x appadm/users   1297 2012-02-17 18:44 home/appadm/bin/cop_daily_IPL_time.sh
 -rwxr-xr-x appadm/users    602 2011-07-27 18:09 home/appadm/bin/ops_appadm_scp.exp
 -rwxr-xr-x appadm/users    206 2013-10-30 18:45 home/appadm/bin/ops_Q_copcard.sh
 -rwxr-xr-x appadm/users    665 2007-07-16 18:30 home/appadm/bin/ops_copient.exp
 -rwxr-xr-x appadm/users    694 2007-07-16 18:30 home/appadm/bin/terminals.pl
 -rwxr-xr-x appadm/users   2736 2007-07-16 18:30 home/appadm/bin/co_monitor2.sh
 -rwxr-xr-x appadm/users   6305 2006-06-02 14:21 home/appadm/bin/ccp
 -rwxr-xr-x appadm/users    217 2013-10-30 18:45 home/appadm/bin/ops_Q_copiphourly.sh
 -rwxr-xr-x appadm/users    501 2012-06-06 15:25 home/appadm/bin/ops_appadm_bb.exp
 -rwxr-xr-x appadm/users    785 2009-01-16 15:53 home/appadm/ops_emer.sh
 -rw-r----- appadm/users    281 2011-10-11 03:25 home/appadm/.bashrc
 -rw-r--r-- appadm/users   2535 2008-10-06 22:28 home/appadm/to2.pl
 -rw-r--r-- appadm/users    176 2011-10-11 03:25 home/appadm/.bash_profile
 -rw-r--r-- appadm/users   3205 2012-02-01 11:25 home/appadm/ipsort.pl
 + STATUS=0
 + '[' 0 -ne 0 ']'
 + cd AppadmQ-1
 /root/rpmbuild/tmp/rpm-tmp.sC0xn6: line 38: cd: AppadmQ-1: No such file or directory
 error: Bad exit status from /root/rpmbuild/tmp/rpm-tmp.sC0xn6 (%prep)

 RPM build errors:
 Bad exit status from /root/rpmbuild/tmp/rpm-tmp.sC0xn6 (%prep)

Here are the contents of the tmp file
 #!/bin/sh

  RPM_SOURCE_DIR="/root/rpmbuild/SOURCES"
  RPM_BUILD_DIR="/root/rpmbuild/BUILD"
  RPM_OPT_FLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic"
  RPM_ARCH="x86_64"
  RPM_OS="linux"
  export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
  RPM_DOC_DIR="/usr/share/doc"
  export RPM_DOC_DIR
  RPM_PACKAGE_NAME="AppadmQ"
  RPM_PACKAGE_VERSION="1"
  RPM_PACKAGE_RELEASE="1"
  export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
  LANG=C
  export LANG
  unset CDPATH DISPLAY ||:
  RPM_BUILD_ROOT="/root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64"
  export RPM_BUILD_ROOT

  PKG_CONFIG_PATH="/usr/lib64/pkgconfig:/usr/share/pkgconfig"
  export PKG_CONFIG_PATH

  set -x
  umask 022
  cd "/root/rpmbuild/BUILD"
LANG=C
export LANG
unset DISPLAY

cd '/root/rpmbuild/BUILD'
rm -rf 'AppadmQ-1'
/usr/bin/gzip -dc '/root/rpmbuild/SOURCES/AppadmQ-1-1.tar.gz' | /bin/tar -xvvf -
STATUS=$?
if [ $STATUS -ne 0 ]; then
  exit $STATUS
fi
cd 'AppadmQ-1'

The command is failing because it can't cd into AppadmQ-1. I'm confused if that is something I need to manually build when I tarball up my directory I want installed. I thought it was build based on the Name, version and release in the spec file. I read on another thread that you need to create it in the setup. I tried that but it still fails. My tar.gz file source is created from all the contents of the /home/appadm directory. When I install the rpm I want that rpm to unpack that source code and overlay it onto my desitation servers /home/appadm directory so I can maintain version control of all the files and folders in that directory. Any help is greatly appreciated. if this question has already been answered in another thread, redirection to that thread is greatly appreciated or even a book I could read to have a better understanding of how this all works would be of great assistance.

#

@glglgl Thank you for the feedback, I really appreciate it. I made your suggested changes below.
I modified my spec file so the line now reads
%setup -c -n AppadmQ-1

Here is the output after I ran the command
Executing(%prep): /bin/sh -e /root/rpmbuild/tmp/rpm-tmp.Hl0evU
+ umask 022
+ cd /root/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /root/rpmbuild/BUILD
+ rm -rf AppadmQ-1
+ /bin/mkdir -p AppadmQ-1
+ cd AppadmQ-1
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/AppadmQ-1-1.tar.gz
+ /bin/tar -xvvf -
drwxr-xr-x appadm/appadm     0 2013-11-11 15:35 home/appadm/
drwxr-xr-x                  Creating directory: home
-rw-r--r-- appadm/users    121 2011-10-11 03:25 home/appadm/.kshrc
drwxr-xr-x appadm/appadm     0 2013-07-17 18:07 home/appadm/orwell/
-r--r--r-- appadm/users   1837 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20004.stub
-r--r--r-- appadm/users   1892 2010-10-22 15:07 home/appadm/orwell/irco_orwell_20052.stub
-r--r--r-- appadm/users   1841 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20003.stub
-r--r--r-- appadm/users   1975 2010-11-04 22:52 home/appadm/orwell/irco_orwell_20053.stub
-rw-r--r-- appadm/users    996 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00409.stub
-r--r--r-- appadm/users   3087 2011-12-30 14:06 home/appadm/orwell/irco_orwell_20032.stub
-rw-r--r-- appadm/users   1098 2011-06-02 12:52 home/appadm/orwell/sys_orwell_00413.stub
-rw-r--r-- appadm/users    994 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00410.stub
-r--r--r-- appadm/users   1159 2013-07-17 18:07 home/appadm/orwell/irco_orwell_20037.stub
-rw-r--r-- appadm/users    994 2011-03-29 16:07 home/appadm/orwell/sys_orwell_00411.stub
-r--r--r-- appadm/users   1535 2009-12-01 16:07 home/appadm/orwell/irco_orwell_20002.stub
-r--r--r-- appadm/users     11 2013-07-02 18:31 home/appadm/lanetypeCksum_baseline
drwxrwxr-x appadm/appadm     0 2013-11-11 15:19 home/appadm/rat/
-rwxr-xr-x appadm/users    406 2008-08-24 21:00 home/appadm/j7.sh
-rw------- appadm/users     51 2013-01-30 17:24 home/appadm/.lesshst
-rw-r----- appadm/users    276 2011-10-11 03:25 home/appadm/.profile
-rwxr-xr-x appadm/users     53 2008-10-06 22:28 home/appadm/to2.sh
-rwxr-xr-x appadm/users    229 2008-11-03 17:27 home/appadm/ipl.sh
-rwxr-xr-x appadm/users    263 2008-10-16 16:26 home/appadm/longsql.sh
-rwxr-xr-x appadm/users    162 2008-10-06 21:51 home/appadm/to.sh
drwxr-xr-x appadm/appadm     0 2013-11-11 15:10 home/appadm/logs/
-rwxr-xr-x appadm/users    160 2012-01-21 13:55 home/appadm/j.sh
drwxr-xr-x appadm/appadm     0 2013-11-11 15:09 home/appadm/copient/
-rwxr-xr-x appadm/users    514 2013-10-30 18:45 home/appadm/copient/ops_coptidy.pl
-rw-r--r-- appadm/users     20 2011-12-22 09:50 home/appadm/copient/co_monitor2.txt
-rwxr-xr-x appadm/users    170 2005-09-28 10:53 home/appadm/copient/ops_chklog.sh
-rwxr-xr-x appadm/users  23290 2013-10-30 18:45 home/appadm/copient/ops_copiphourly.pl
-rwxr-xr-x appadm/users    610 2009-08-19 17:42 home/appadm/copient/ops_coptidy.sh
-rwxr-xr-x appadm/users     65 2013-11-11 15:08 home/appadm/copient/copient_phpver.php
-rwxr-xr-x appadm/users    538 2008-12-10 17:00 home/appadm/copient/ops_appadm.exp
-rwxr-xr-x appadm/users    866 2010-01-21 14:17 home/appadm/copient/copIP.sh
-rwxr-xr-x appadm/users    706 2010-06-04 17:18 home/appadm/copient/ops_coproid.sh
-rwxr-xr-x appadm/users   6413 2013-10-30 18:45 home/appadm/copient/ops_copdiscount.pl
-rwxr-xr-x appadm/users    642 2009-06-09 11:09 home/appadm/copient/ops_copiphourly.sh
-rwxr-xr-x appadm/users    293 2008-11-18 17:16 home/appadm/copient/ops_cksum.sh
-rwxr-xr-- appadm/users    688 2012-08-19 19:12 home/appadm/copient/dbCurebkup.sh
-rwxr-xr-x appadm/users  21993 2013-10-30 18:45 home/appadm/copient/ops_copresponse.pl
-rwxr-xr-x appadm/users    259 2006-01-09 19:58 home/appadm/copient/ops_appadm_survey.sh
-rwxr-xr-x appadm/users   3553 2013-10-30 18:45 home/appadm/copient/ops_copcard.pl
-rwxr-xr-x appadm/users    704 2010-02-12 09:46 home/appadm/copient/ops_copresponse.sh
-rwxr-xr-x appadm/users    670 2011-04-17 23:19 home/appadm/copient/ops_corpBrand.sh
-rwxr--r-- appadm/users    111 2013-06-11 21:59 home/appadm/copient/c96766_EOC_fix.sh
-rwxr--r-- appadm/users     73 2013-06-18 18:14 home/appadm/copient/IncentiveFetch_fix.sh
-rwxr-xr-x appadm/users   2486 2012-10-08 14:21 home/appadm/copient/cop_cksum.sh
-rwxr-xr-x appadm/users    681 2010-08-13 14:35 home/appadm/copient/cop_incentiveFetch.sh
-rwxr-xr-x appadm/users  13119 2012-10-08 14:21 home/appadm/copient/cksumList
-rwxr-xr-x appadm/users   2571 2012-02-21 16:13 home/appadm/copient/toastClipStore.pl
-rwxr-xr-x appadm/users    357 2008-11-12 14:36 home/appadm/copient/ops_conf1.sh
-rwxr-xr-x appadm/users   3865 2013-10-30 18:45 home/appadm/copient/ops_cop_avg_roids_per_cust.pl
-rwxr-xr-x appadm/users    109 2006-04-17 11:40 home/appadm/copient/copient_ver.php
-rwxr-xr-x appadm/users    323 2008-11-11 16:28 home/appadm/copient/ops_pgsql_cksum.sh
-rwxr-xr-x appadm/users  39326 2013-10-30 18:45 home/appadm/copient/ops_corpBrands.pl
-rwxr-xr-x appadm/users    647 2010-08-19 16:18 home/appadm/copient/ops_copcard.sh
-rwxr-xr-x appadm/users    663 2005-05-31 15:53 home/appadm/copient/ops_copient.exp
-rwxr-x--- appadm/users    691 2006-03-24 12:40 home/appadm/copient/terminals.pl
-rwxr-xr-x appadm/users   6847 2013-08-23 15:42 home/appadm/copient/co_monitor2.sh
-rw-r--r-- appadm/users   1310 2008-09-21 13:45 home/appadm/tidy.pl
drwx------ appadm/appadm     0 2013-11-11 15:19 home/appadm/.ssh/
drwxr----- appadm/appadm     0 2012-04-30 14:42 home/appadm/.pki/
drwxr----- appadm/appadm     0 2012-04-30 14:42 home/appadm/.pki/nssdb/
-rw------- appadm/users   9703 2013-10-21 14:29 home/appadm/.viminfo
-rwxr-xr-x appadm/users   1955 2008-10-06 21:51 home/appadm/to.pl
-rw------- appadm/users     30 2012-10-19 17:16 home/appadm/.php_history
drwxr-xr-x appadm/appadm     0 2013-11-11 15:05 home/appadm/bin/
-rwxr-xr-x appadm/users    172 2007-07-16 18:30 home/appadm/bin/ops_chklog.sh
-rwxr-xr-x appadm/users    190 2013-10-30 18:45 home/appadm/bin/ops_copPhonehome.sh
-rwxr-xr-x appadm/users    229 2013-10-30 18:45 home/appadm/bin/ops_Q_coproid.sh
-rwxr-xr-x appadm/users    362 2013-10-30 18:45 home/appadm/bin/ops_Q_copOld_customer_data.sh
-rwxr-xr-x appadm/users    292 2011-07-26 09:14 home/appadm/bin/ops_appadm.exp
-rwxr-xr-x appadm/users    167 2013-10-30 18:45 home/appadm/bin/ops_copSanity.sh
-rwxr-xr-x appadm/users   4483 2013-10-30 18:45 home/appadm/bin/qtySCO.pl
-rwxr-xr-x appadm/users    607 2013-10-30 18:45 home/appadm/bin/ops_Q_copLook_for_coupon_time_outs.sh
-rwxr-xr-x appadm/users    426 2011-08-12 18:20 home/appadm/bin/ops_appadm_ssh.exp
-rwxr-xr-x appadm/users    261 2007-07-16 18:30 home/appadm/bin/ops_appadm_survey.sh
-rwxr-xr-x appadm/users    215 2013-10-30 18:45 home/appadm/bin/ops_Q_copBrand.sh
-rwxr-xr-x appadm/users   1811 2013-10-30 18:45 home/appadm/bin/ops_copCksum.sh
-rwxr-xr-x appadm/users    237 2013-10-30 18:45 home/appadm/bin/ops_Q_coptidy.sh
-rwxr-xr-x appadm/users  39646 2013-10-30 18:45 home/appadm/bin/ops_Q.sh
-rwxr-xr-x appadm/users   1238 2007-12-20 09:27 home/appadm/bin/ops_remote.pl
-rwxr-xr-x appadm/users    222 2013-10-30 18:45 home/appadm/bin/ops_Q_copresponse.sh
-rwxr-xr-x appadm/users   1297 2012-02-17 18:44 home/appadm/bin/cop_daily_IPL_time.sh
-rwxr-xr-x appadm/users    602 2011-07-27 18:09 home/appadm/bin/ops_appadm_scp.exp
-rwxr-xr-x appadm/users    206 2013-10-30 18:45 home/appadm/bin/ops_Q_copcard.sh
-rwxr-xr-x appadm/users    665 2007-07-16 18:30 home/appadm/bin/ops_copient.exp
-rwxr-xr-x appadm/users    694 2007-07-16 18:30 home/appadm/bin/terminals.pl
-rwxr-xr-x appadm/users   2736 2007-07-16 18:30 home/appadm/bin/co_monitor2.sh
-rwxr-xr-x appadm/users   6305 2006-06-02 14:21 home/appadm/bin/ccp
-rwxr-xr-x appadm/users    217 2013-10-30 18:45 home/appadm/bin/ops_Q_copiphourly.sh
-rwxr-xr-x appadm/users    501 2012-06-06 15:25 home/appadm/bin/ops_appadm_bb.exp
-rwxr-xr-x appadm/users    785 2009-01-16 15:53 home/appadm/ops_emer.sh
-rw-r----- appadm/users    281 2011-10-11 03:25 home/appadm/.bashrc
-rw-r--r-- appadm/users   2535 2008-10-06 22:28 home/appadm/to2.pl
-rw-r--r-- appadm/users    176 2011-10-11 03:25 home/appadm/.bash_profile
-rw-r--r-- appadm/users   3205 2012-02-01 11:25 home/appadm/ipsort.pl
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /root/rpmbuild/tmp/rpm-tmp.5UPBZD
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd AppadmQ-1
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /root/rpmbuild/tmp/rpm-tmp.7AYovn
+ umask 022
+ cd /root/rpmbuild/BUILD
+ '[' /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64 '!=' / ']'
+ rm -rf /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
++ dirname /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
+ mkdir -p /root/rpmbuild/BUILDROOT
+ mkdir /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
+ cd AppadmQ-1
+ LANG=C
+ export LANG
+ unset DISPLAY
+ '[' /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64 '!=' / ']'
+ rm -rf /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
+ mkdir /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64
+ '[' -d /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64 ']'
+ mkdir /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64/tmp
+ cp -af AppadmQ-1-1.tar.gz /root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64/tmp
cp: cannot stat `AppadmQ-1-1.tar.gz': No such file or directory
error: Bad exit status from /root/rpmbuild/tmp/rpm-tmp.7AYovn (%install)

RPM build errors:
    Bad exit status from /root/rpmbuild/tmp/rpm-tmp.7AYovn (%install)

I can see the directory was created on my server
[root@ tmp]#pwd
/root/rpmbuild/BUILDROOT/AppadmQ-1-1.x86_64/tmp
[root@ tmp]#ls

The Source file is in the SOURCES directory. I assumed the rpmbuild command would copy that file into its temporary working directory from the SOURCES directory.
[root@j299848 SOURCES]#ls -la Ap*
-rw-r----- 1 root root 51158 Nov 11 15:54 AppadmQ-1-1.tar.gz

I guess what confuses me is how the temporary directories are created and used in the build process so I get a little lost in figuring out where my tar.gz should go and what I shoudld be naming things in my spec with the macros.

A:
The command is failing because it can't cd into AppadmQ-1.

Right. That is because you specified
%setup -n AppadmQ-1

which tells the %setup script that, well, it is supposed to cd AppadmQ-1.
If you don't want that, don't tell it to do so.
If you want setup to mkdir AppadmQ-1 before unpacking, do
    %setup -c -n AppadmQ-1

and your directory tree from the .tar.gz goes into that given subdirectory - which will as well be your working directory.
So, as you see, the .tar.gz file is unpacked during the %prep stagen via the %setup script.
Normally, this would be followed by some build process, but this seems not to be the case there.
Instead, that now follows is the %install process. It consists of putting all files which are supposed to be on the target system into the build root directory.
It could be done with a cp command. But, of course, not the .tar.gz file, but the unpacked directory tree:
cp -af . "$RPM_BUILD_ROOT" # I omit the tmp/ part because I think it is not the ight way to go.

Now you have a structure $RPM_BUILD_ROOT/home/... which will be put to /home/... upon installing that RPM.
Note that you'll have to mention the files under the %files directive in order to have them included. Here you have the opportunity to give some user, group and even mode to the files.
But note further that installing files under /home/... will surely not be the way to go.
Normally, one puts packages with a completely own directory under /opt/myapp/, or distributes it under /usr/, /var/, /srv or wherever it suits.
And, one further advise: It is absolutely not recommended to run rpmbuild as root. That's part of the whole point: you prepare the files where they are intended to go, and pack them together. Only the process of installing the .rpm files requires root rights.


text:
Q: C# ComboBox using a Property in a Dictionary value as DisplayMember, and the Dictionary value itself as ValueMember I have a Dictionary, and I'm trying to populate a ComboBox with it.  My Settings class has a string property called Symbol, which is what I want to display in the drop-down list, and I want comboBox.SelectedItem to be a Settings object. So far I've tried:
comboBox.DataSource = dictionary.Values.ToList();
comboBox.DisplayMember = "Symbol";
comboBox.ValueMember = null;

and
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = dictionary.Values.ToList();
comboBox.DataSource = bindingSource;
comboBox.DisplayMember = "Symbol";
comboBox.ValueMember = null;

I don't necessary need to bind the data for what I'm doing, I would be happy with adding everything one time in the constructor, but it seemed cleaner to use DataSource rather than looping through the dictionary.Values.  Thank you in advance for your help.

redpajama_set_name: RedPajamaStackExchange


text:
Q: AWS Java SDK credentials I am using the AWS Java SDK and trying to run some tests; getting:
Unable to load AWS credentials from the /AwsCredentials.properties file on the classpath
The credentials file @ ~/.aws/ is correct per AWS specs; 777'd it to ensure no access issues.
I am not using any IDE plug-ins; per AWS docs, having a credentials file @ ~/.aws/ should suffice. Anyone have this working with just the SDK installed?  If I hard-code the file path into the ClasspathPropertiesFileCredentialsProvider() request it spits the error back with the path instead of the AwsCredentials.properties string, which doesn't exist anywhere (yes, tried making one of those in ~/.aws/ as well).
Thanks much for any insights, code is below straight from Amazon:
import com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.sns.AmazonSNSClient;
import com.amazonaws.services.sns.model.PublishRequest;
import com.amazonaws.services.sns.model.PublishResult;

public class SNS {

    public static void main(String[] args) {
        AmazonSNSClient snsClient = new AmazonSNSClient(new ClasspathPropertiesFileCredentialsProvider());
        snsClient.setRegion(Region.getRegion(Regions.US_EAST_1));

        String msg = "this is a test";
        PublishRequest publishRequest = new PublishRequest("my arn", msg);
        PublishResult publishResult = snsClient.publish(publishRequest);
        System.out.println("MessageId - " + publishResult.getMessageId());
    }
}

A: If you use DefaultAWSCredentialsProviderChain instead of ClasspathPropertiesFileCredentialsProvider, it will automatically check various default locations for AWS credentials. (Documentation)

A: Have you verified that your $HOME environment variable is set for the process you are running? The AWS SDK relies on $HOME to determine the proper location of your .aws folder.

A: Well that didn't work the way I'd planned it; couldn't get the .aws path as a classpath (tried adding as an external class folder).
Ran the below to find the actual classpaths in my project:
    public static void main (String args[]) {

        ClassLoader cl = ClassLoader.getSystemClassLoader();

        URL[] urls = ((URLClassLoader)cl).getURLs();

        for(URL url: urls){
            System.out.println(url.getFile());
        }

   }

and then dropped my AWS credentials into a new AwsCredentials.properties file in one of the dirs from above (I had one; the rest were jar files).
Changed the tag values in the file to "accessKey" and "secretKey" from what was there (aws_access_key, aws_secret_access_key) and it worked.
Thanks to everyone for their inputs.


text:
Q: Stored Procedure: Update Int field passing in a Column parameter I am trying to update a int field while passing in a column parameter. This works successfully when I try to input a varchar, float or money field, but not for int.  I get this error when I try to execute this SP with an int value:

Error converting data type varchar to int.

CREATE PROCEDURE [dbo].[spUpdateField]
 @strOrderNumber nvarchar(50)
, @strField nvarchar(50)
, @strValue nvarchar(50)

AS
Declare
@sql nvarchar (1000);
set @sql = 'update tblOrder
SET ' + @strField + ' = ''' + @strValue + '''
WHERE strOrderNumber = ''' + @strOrderNumber + '''' ;

exec sp_executesql @sql;

GO

`

A: DECLARE @datatype varchar(max)
SELECT @datatype = DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
     TABLE_NAME = 'tblOrder' AND
     COLUMN_NAME = @strField

if @dataType = 'int' or @datatype = 'float' Or @datatype = 'tinyInt'
BEGIN
  Declare @sql nvarchar (1000);
  set @sql = 'update tblOrder
  SET ' + @strField + ' = '  + @strValue
  WHERE strOrderNumber = ''' + @strOrderNumber + '''' ;

  exec sp_executesql @sql;
END
ELSE
  Declare @sql nvarchar (1000);
  set @sql = 'update tblOrder
  SET ' + @strField + ' = ''' + @strValue + '''
  WHERE strOrderNumber = ''' + @strOrderNumber + '''' ;

  exec sp_executesql @sql;
END

One way would be to fill in the @dataTypes as needed or put them into a table and use an if statement to pick the proper query.


text:
Q: NASM counting program not working I want to use only the instructions I have already used. I am unable to get the output, seems the input is never being read.
Could anyone please help me figure out the problem in my code?
section .data
space:db ' '
size :equ $-space
num :db 4
no :db 4

section .text
global _start
_start:
mov eax,3 ;read input number
mov ebx,0
mov ecx,num
mov edx,4
int 80h

sub dword[num],30h ;convert from ASCII to integer
again:    ;incrementing the eax register value from 0(loop)
mov eax,0
cmp eax,dword[num]
ja finish

mov dword[no],eax ;store eax value to no
add eax,30h ;convert eax to ascii

mov edx,4. ;write eax value
mov ecx,eax
mov ebx,1
mov eax,4
int 80h

inc dword[no] ;incrementing no
mov eax,dword[no]
jmp again

finish:  ;exit
mov eax,1
mov ebx,0
int 80h


text:
Q: how to calculate worst-case time-complexity of this part of code int pick1 = ran.nextInt(num)+1;
int pick2 = ran.nextInt(num)+1;
int pick3 = ran.nextInt(num)+1;

if(pick1!=pick2&&pick1!=pick3) {
    while(pick1!=pick2) {
        pick2=ran.nextInt(num)+1;
     }
     while(pick1!=pick3) {
        pick3=ran.nextInt(num)+1;
     }
}

This is a part of my code; how do I calculate the worst case time complexity of this? Since it involves random numbers, I felt it was complicated.
I came up with
f(n) = 1+1+1+1((n*1)+(n*1)) = 3+n+n = 3+2n

but I don't know if it's correct.


text:
Q: TLS/SSL - C# - how to execute queries against a remote sql server? I have a winforms C# application which will have to send and receive information securely from a remote SQL Server.  At the moment I've just tested it with the database on my machine using the inbuilt classes e.g. SqlConnection.
I need to connecting my program to a remote SQL Server, execute queries against it.  Both computers are under my organisation's control, although the remote workers are off-site and may be using a 3G connection.
One option is to connect the two computers using a VPN, and then presumably the other computer is visible as if it was on the same network, then I can use my connection string as I have been doing so far, perhaps putting in the IP address. However the IT support people are grumbling about setting up VPNs.
I have heard of TLS/SSL but never used this before.  Can i use it to send sql queries to a SQL Server directly?

A: The SSL connectivity for SQL Server is encrypting the server socket connection.  With SQL Server, a temp certificate is created each time you start the SQL Server.  On the client side, you let the client accept any certificate, and this ensures your socket is encrypted (still open to Man in the Middle attack). You can also use your own signed certificate on both sides for the SSL connection.  The DBA's set this up, and there's nothing special to do on your end, other than possibly setting up your own certificate and changing the connection string.
MSDN Using SSL Encryption
Typically, the datacenters (or host-host) are connected via private lan / VPN tunneling, which is also encrypted, and in this case, it would be a second layer of protection.  If you have a VPN, you could probably get away with the Servers built in SSL certificate.  That saves you the work of having to maintain the certificates each year.


text:
Q: Iframe dinâmico mobile Preciso gerar um iframe dinâmico ao clicar em um botão em uma div para uma aplicação mobile só que quando tento carregar este mesmo iframe usando o método Onload no Body ele não carrega automático e apenas quando eu atualizo a página (F5).
Segue parte do meu código:

A: Renan, para acessar a div.map você precisa ter certeza que a mesma já se encontra carregada, para isto você pode usar uma das seguinte opções:
jQuery:
$(document).ready(function () {
  //seu codigo aqui.
});

JavaScript
document.addEventListener("readystatechange", function () {
  if (document.readyState == "interactive") {
    //seu codigo aqui.
  }
});

ou ponto, para que o iframe tenha um tamanho proporcional a tela com um decrecimo em px, você pode usar o calc()

html, body {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0px;
  margin: 0px;
}

#meuIframe {
  width: calc(100% - 20px);
  height: calc(100% - 100px);
  box-sizing: border-box;
  margin: 10px;
  padding: 0px;
  border: 0px none transparent;
}

para resolver o seu problema de forma imediata, remova o body.onload e use o $(handler).

function Map()
{
  var retorno;
  var largura;
  var altura;

  largura = ($(document).width()) - 20;
  altura = ($(document).height()) -100;

  retorno = '';
  $('.map').html(retorno);
}

$(function () {
  Map();
});

A:

A:


text:
Q: Recursive Query in MySQL using stored proceedure and CURSOR I'm expanding our user/group system to allow for dynamic groups which are made up of other groups members.  I have three tables users, groups, and relationships.
For simplicity sake, lets say users only contains one field user_id, and groups only contains group_id.  relationships uses three fields: user_id, group_id, related_group_id to represent both user to group and group to group relationships.
A dynamically populated group hierarchy would be something like:
Users A, B, C belong to Group 1 and Users D, E, F belong to Group 2. All of these are represented in the relationships table as (user_id,group_id):
A,1
B,1
C,1
D,2
E,2
F,2

The dynamic Group 3 would have two group to group relationship records (group_id,related_group_id):
3,1
3,2

To illustrate my problem better lets add a Dynamic Group 4 and have it include Group 3:
4,3

Piecing together what I've learned of MySQL CURSOR's, I've created the following stored procedure called fetch_inheritance_groups:
DROP PROCEDURE IF EXISTS `fetch_inheritance_groups`;

CREATE PROCEDURE `fetch_inheritance_groups`(IN parent_id INT)
    READS SQL DATA
    BEGIN

    DECLARE inherit_id char(32);
    DECLARE eol BOOLEAN;
    DECLARE inherit_cur CURSOR FOR SELECT r.Related_Group_ID FROM usr_relationships r WHERE r.Group_ID = parent_id AND r.Related_Group_ID IS NOT NULL;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET eol = TRUE;

    OPEN inherit_cur;
    inherited: LOOP
        FETCH inherit_cur INTO inherit_id;

        IF eol
            THEN
            CLOSE inherit_cur;
            LEAVE inherited;
        ELSE
            CALL fetch_inheritance_groups(inherit_id);
        END IF;

        SELECT inherit_id;

    END LOOP inherited;

END;

...which is called with...
CALL fetch_inheritance_groups(4);

...and returns the expected results of
3
2
1

Herein begins my problem, they're returned as three separate result sets rather than three rows in a single result set, and secondly, the results are meant to be used within a query like:
SELECT r.uer_id FROM relationships r WHERE r.group_id = 4 OR r.group_id IN (CALL fetch_inheritance_groups(4));

So the three questions I'm hoping someone can answer are:
1. Should I be using a CURSOR here or is there an alternative that will get the same recursive result?
2. How can I get the results back in a single result set so that it can be used in the same fashion as a subselect?
3. What is the proper way of using the results from the CALL because I can't at least as far as I've tried get the sample SELECT statement above to work?  I believe this is because I can't use CALL inline but I'm not sure.

UPDATE: In a related question here: How long will a temporary MEMORY table persist if I don't drop it (MySQL) I posted a set of updates to the stored proceedure used above which is still recursive, but provides the list of ID's back as a variable, and in a format compatible with FIND_IN_SET() giving me EXACTLY what I needed.

A: So the three questions I'm hoping someone can answer are:

1.Should I be using a CURSOR here or is there an alternative that will get the same recursive result?

No, you should not. The CURSOR keep being opened over and over. Thinking of the overhead make me cringe. Personally, I stay away from CURSORs.

2.How can I get the results back in a single result set so that it can be used in the same fashion as a subselect?
3.What is the proper way of using the results from the CALL because I can't at least as far as I've tried get the sample SELECT statement above to work? I believe this is because I can't use CALL inline but I'm not sure.

I would like to bail you out of this by suggesting something I learned from my college days when learning about data structures. You need to perform tree traversal using a queue. This allows you to start at a root and express all descendants of a tree.
The algorithm goes like this

*

*STEP 01 : Start with an empty queue

*STEP 02 : Dequeue Node From the Front of the Queue

*STEP 03 : Enqueue All Children of the Latest Node

*STEP 04 : Process Info From the Latest Node

*STEP 05 : If the Queue is Not Empty, Go Back to STEP 02

*STEP 06 : All Done

This allows you to traverse a recursive structure without using Programmatic Recursion. At this point, you are probably asking: How can I traverse a tree structure without recursion?
I wrote a post about how to script three Stored Procedures that can using a loop in a single CALL that will traverse a table with nodes and its parent in a table:

*

*GetParentIDByID

*GetAncestry

*GetFamilyTree

The post is Find highest level of a hierarchical field: with vs without CTEs (Oct 24, 2011). It contains the Stored Procedures already written that will traverse the following table structure:
+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| id         | int(11)      | NO   | PRI | NULL    | auto_increment |
| parent_id  | int(11)      | YES  |     | NULL    |                |
| name       | varchar(255) | YES  |     | NULL    |                |
| notes      | text         | YES  |     | NULL    |                |
+------------+--------------+------+-----+---------+----------------+

Please read the code carefully and apply the principles.
Give it a Try !!!


text:
Q: Drawing three balls from an urn with ten balls An urn contains four white balls and six black. Three balls are drawn with replacement. Let $x$ be the number of white balls. Calcaulate $E (x)$, $VAR(x)$ and $\sigma x$.
I don't know how to calculate $E(x) =\sum\limits_{i=1}^{n} X_i  P(X_i)$.

A: Let me give you some hints: let $X$ be a number of white balls

*

*Use combinatorics to find $p_0 = P(X = 0)$, $p_1 = P(X = 1)$, $p_2 = P(X = 2)$, $p_3 = P(X = 3)$. For example, the probability $p_0$ that there are no white balls at all is $b^3$ where $b = \frac{6}{10}$ is a probability to draw a black ball.

*For $E(X)$ you have $E(X) = \sum\limits_{k=0}^3 k\cdot p_k = p_1+2p_2+3p_3$.

A: Because you use replacement the probability of white will be 4/10 =2/5=0.40 each time you draw.  Each draw is independent of previous ones so for a given sequnce of white and black you can get the probability by multiplication.  So for example the sequence W B W has probability that is the following product: (2/5)x(3/5)x(2/5).  Since this os the set up the number of w balls drwn in three draws has a binomial distribution with p=2/5 and n=3.  With all those hints you should be able to solve this.


text:
Q: Mac OS X, 10.12.2, Command Line how to add Search Domains I do this all the time with the GUI and it does what I am looking for. No Problem.
System Preferences > Network > Select the LAN or Wi-Fi > Advanced > DNS > Search Domains and in that particular box field, I add all the search domains that I want. e.g. office, hq, ad.gwn, etc.
Question, how can I achieve the same process via command line with Terminal?
So far this is what I did:
Step #1 I run both these command line to get an overview of what I have:

*

*networksetup -listallnetworkservices

*networksetup -listnetworkserviceorder

and this is what I got:

*

*List item

*Apple USB Ethernet Adapter

*Thinkpad USB LAN

*Wi-Fi

*Bluetooth PAN

*Thunderbolt Bridge

*(1) Apple USB Ethernet Adapter
(Hardware Port: Apple USB Ethernet Adapter, Device: en4)

*(2) Thinkpad USB LAN
(Hardware Port: Thinkpad USB LAN, Device: en5)

*(3) Wi-Fi
(Hardware Port: Wi-Fi, Device: en0)

*(4) Bluetooth PAN
(Hardware Port: Bluetooth PAN, Device: en3)

*(5) Thunderbolt Bridge
(Hardware Port: Thunderbolt Bridge, Device: bridge0)

Step #2 I tried to add my search domains (hq, office, ad.gwn) but I received the following error message:
 - sudo networksetup -setsearchdomains en4 hq office ad.gwn
 - en4 is not a recognized network service
 - Error: The parameters were not valid
I am connected only with Ethernet cable. No WiFi.  I tried en4 and en5 same issue.

A: First list all network services to get an overview:
networksetup -listallnetworkservices

Output example:
An asterisk (*) denotes that a network service is disabled.
en0
en1

I renamed my two network services from "Ethernet" to en0 and "Ethernet Adapter (1)" to en1. You have to use your actual network service names of course! If the network service name contains spaces you have to use quotes (e.g. "Apple USB Ethernet Adapter") in the commands below.
To set search domains for a network service use:
sudo networksetup -setsearchdomains networkservice domain1 [domain2] [...]

Example:
sudo networksetup -setsearchdomains en0 example.home example.net example

Check with networksetup -getsearchdomains en0:
example.home
example.net
example

If you want to add search domains to already existing domains use:
SEARCHDOMAIN=$(networksetup -getsearchdomains en0)
sudo networksetup -setsearchdomains en0 $SEARCHDOMAIN domain1 domain2 ...


text:
Q: É possível enviar tags JSX do NodeJs(backend) para o ReactJs? Preciso enviar um dado ao frontend, mas preciso que ele já esteja com determina tag em volta dele, por exemplo...
dado backend:
Nome: Gabriel
preciso que chegue ao front dessa maneira:

Gabriel

A: Sim totalmente possível! no backend você pode trabalhar com json e enviar os dados assim:
no node temos uma variavel escrita com o nome header:
const header = "

meu menu

"

A unica coisa que precisamos fazer é devolver para o frontend essa variavel:
Algo nesse sentido:
return res.json({header})

e no frontend temos que usar no react um famoso carinha: (dangerouslySetInnerHTML), famoso por ser considerado perigoso rs mas se souber usar, não tem problema
function createMarkup() {
  // aqui você faz a request para o node e atribui ele a variavel header
  const {header} = request.get('header');
  return {__html: header};
}

function MyComponent() {
  return
;
}

link da documentação do react


text:
Q: A more efficient way of comparing two images in a python I have a task where i need to specify the upper left coordinate of the smaller image in the larger image.
I implemented this code, however it is too slow since I have a time limit of 20 seconds, and in some datasets I have 3000 images. How can this be implemented more effectively? I can use numpy, scipy and all packages from the standard python library.
import numpy as np
from PIL import Image

map_image_path = input()
map_image = Image.open(map_image_path)
map_ar = np.asarray(map_image)
map_ar_y, map_ar_x  = map_ar.shape[:2]

i = int(input())
dimensions = input()
patches=list()

for k in range(i):
  patch_image_path = input()
  patches.append(Image.open(patch_image_path))

for j in range(i):
  patch_ar = np.asarray(patches[j])
  patch_ar_y, patch_ar_x = patch_ar.shape[:2]
  stop_x = map_ar_x - patch_ar_x + 1
  stop_y = map_ar_y - patch_ar_y + 1

  for x in range(0, stop_x):
    for y in range(0, stop_y):
      x2 = x + patch_ar_x
      y2 = y + patch_ar_y
      picture = map_ar[y:y2, x:x2]
      if np.array_equal(picture, patch_ar):
        print(str(x) + "," + str(y))


text:
Q: How to support basic authentication and bearer authentication for the REST API project I am new to Spring Security & still learning it so my question can be naive please bear with it.
I have Sprint Boot Rest API project which exposes certain APIs. I have already implemented the bearer token based authentication for all the APIs.
e.g /user , /resource, /appointment
Now for few apis for a particular controller I would like to have the basic authentication implemented. These Apis will be consumed by another service which is not exposed to public.
In order to have the security for the APIs I would like to have basic authentication in place for these apis.
e.g /internal/api1 , internal/api2 .. and so on
I am not able to distinguished between urls in the ResourceServerConfigurerAdapter & WebSecurityConfigurerAdapter. Also not sure which should be used for adding basicAuth() using the antmatchers

A: What you want, by reading your problem, is to have two authentication types (token and httpBasic) for two diffetent endpoints. It can be achieved by creating two different WebSecurityConfigurerAdapter beans. Spring Boot enables this and can be done like bellow:

*

*@Order(1) - /resource|user|appointment/** protected by bearer token authentication.

*@Order(2) - /internal/** protected by basic auth.

View docs for Spring Boot and sample code here.
   @EnableWebSecurity
   public class SecurityConfig {

    @Configuration
    @Order(1)
    public class ApiSecurityConfig extends WebSecurityConfigurerAdapter {

        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
                .antMatcher("/resource/**")
                .antMatcher("/user/**")
                .antMatcher("/appointment/**")
                .authorizeRequests()
                    .anyRequest().authenticated()
                .and() .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
    .and().addFilterBefore(jwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
        }
    }

    @Configuration
    @Order(2)
    public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.csrf().disable()
                .authorizeRequests()
                .antMatchers("/internal/**")
                .and()
                .httpBasic();
        }
    }

}


text:
Q: Serializing shared field I have one class with a private static (shared, since I'm in VB.NET) field and its associated public static property, since it stores one variable that should be the same to all the instances of this class. So far, so good.
The problem arrives when trying to binary serialize these kind of objects, since this shared field is nos being properly stored and returns to its default value when deserializing.
I suppose this is the expected behaviour, so my question is... how can I make a shared field persistent?
I have read some comments to similar questions that say that this is a bad design, but it really makes sense (AFAIK) in my case, since this variable should be the same to all the object, but can be changed by the user and therefore should be stored.
Can you suggest another way of doing it?
Thanks!
EDIT: (sorry, I was in a hurry and couldn't complete my question until now)
My Class looks like this:
Public MustInherit Class NitrogenController
    Private _active As Boolean
    Private Shared _controlInterval As TimeSpan
    Private _lastControlTime As Date

    Public Property Active() As Boolean
    Public Shared Property ControlInterval() As System.TimeSpan

    'other properies that must be persisted

    Public Function Control() As Boolean
        If Not Now > _lastControlTime.Add(_controlInterval) Or Not _active Then
            Return False
        Else
            DoControl()
            _lastControlTime = Now
            Return True
        End If
    End Function
End Class

So, the problem is that I can have several nitrogen controllers, but they should all have the same _controlInterval. That's the reason why I used a shared variable for this. But it does not preserve its value after serialization/deserialization. So... any ideas about how to do this?
Thanks!


text:
Q: Jquery : Select option of dropdown based on textbox text I have tried to select option based on the textbox text.
Below is my html
<select id="select1">
    <option value="">-- Please Select --</option>
    <option value="277">12 +$2.99</option>
    <option value="278">25 +$2.75</option>
    <option value="279">50 +$2.50</option>
    <option value="280">100 +$2.00</option>
    <option value="281">250 +$1.90</option>
    <option value="282">500 +$1.70</option>
    <option value="283">1000 +$1.60</option>
    <option value="284">2500 +$1.50</option>
    <option value="285">5000 +$1.20</option>
    <option value="286">10000 +$1.00</option>
    <option value="287">25000 +$0.80</option>
</select>
<input type="text" id="pqr" />

And my js like bellow
 $(function(){
    $('#pqr').change(function(){
        $txt = $( "#select1 option:contains('"+$(this).val()+"')" ).text();
            $arr = $txt.split(" +");
            $( "#select1").val($txt);
            alert($arr[0])
            $( "#select1" ).filter(function() {
                 alert($( this ).text > $arr[0]);
            })
    });
});

so if user enter text 12 or greater than 12 and bellow 25 than i want to select option second 12 +$2.99 and if user enter 1500 than option 1000 +$1.60 get selected. Basically i have try to compare option text before (+) sign and try to select based on that.
Please give me hint or any good help so solve this problem

A: Loop through each option to compare the value. You can use something like this,
$(function () {
    $('#pqr').change(function () {
        var txtvalue = parseFloat($(this).val());
        $("#select1 option").each(function () {
            var splitText = $(this).next().text().split("+");
            if (splitText.length > 1) {
                if (txtvalue < parseFloat(splitText[0].trim())) {
                    $(this).prop("selected", true);
                    return false;
                }
            }
        });
    });
});

Fiddle

A: Try this :
$(function(){
    $('#pqr').change(function(){
       var inputVal = parseInt($(this).val());
        $('#select1 option').each(function(){
           var firstVal = $(this).text().split('+')[0];
           var nextVal = inputVal;
           if(!$(this).is(':last'))
            $(this).next().text().split('+')[0];

            if(parseInt(firstVal) <= inputVal && parseInt(nextVal) >=inputVal)
            {
                $(this).prop('selected',true);
            }
        });
    });
});

Demo

A: The $arr[0] in the change callback function will be containing a text value which is not yet parsed to integer so the statement alert($( this ).text > $arr[0]); would not give desired output.
For checking the value lying between a range of select lists option you can use data attributes as followed:
<select id="select1">
    <option value="" data-min="-" data-max="-"> Please Select </option>
    <option value="277" data-min="12" data-max="25">12 +$2.99</option>
    <option value="278" data-min="25" data-max="50">25 +$2.75</option>

This way you will not have to Parse the text of option into integer.
These data values can be retrieved for using jquery data function http://api.jquery.com/data/.
Also all the times you will not be getting the $('#pqr').val() as the text in the option's text so you will have to collect the value of text box and compare it with the range of each option(value >= data-max || value <= data-min).

A: At every change, iterate over all option elements and compare based on parseInt():
jQuery(function($) {
    $('#pqr').on('change', function() {
        var value = parseInt(this.value, 10),
        dd = document.getElementById('select1'),
        index = 0;

        $.each(dd.options, function(i) {
            if (parseInt(this.text, 10) <= value) {
                index = i;
            }
        });

        dd.selectedIndex = index; // set selected option
    });
});

Demo

A: $(function(){
  $('#pqr').on("input", function(){
    var text = this.value;
    var options = $("#select1 > option");
        var elementToSelect = options.eq(0);
    if (text.match(/[0-9]+/)) {
      elementToSelect = options.filter(function(){
        return Number(this.innerText.split("+")[0]) <= text;
      })
      .eq(-1);
    }
    elementToSelect.attr("selected",true);
  });
});


text:
Q: How can I display option text on the dropdown menu that is different than the selected text? Using a simple select, I want to display one text on the dropdown list and another text in the select control after the option was selected. It's pretty similar to option's label attribute in its concept.
I'm not sure if it's even possible. Here's a not-working example:
<select>
  <option select-text="-- EMPTY --"> </option>
  <option select-text="YES!!!">Yes</option>
  <option>No</option>
</select>

Update: I didn't mention that I need to incorporate this solution in a generated HTML (ng-table filters), so any solution that is not pure HTML will be very hard to use. I even consider to look for another table control as a simpler solution, which is pretty basic - placeholder text in select filter.
I've created a question more specific to my problem:How can I put a placeholder text on ng-table select filter?

A: Here's a relatively simple solution that relies on the standard value attribute and a custom data-* attribute:

function showDisplayValue(e) {
  var options = e.target.options,
      option = e.target.selectedOptions[0],
      i;

  // reset options
  for (i = 0; i < options.length; ++i) {
    options[i].innerText = options[i].value;
  }

  // change the selected option's text to its `data-display` attribute value
  option.innerText = option.getAttribute('data-display');
}

document.getElementById('foo').addEventListener('change', showDisplayValue, false);
<select id="foo">
  <option data-display="*** BAR ***" value="Bar">Bar</option>
  <option data-display="*** BAZ ***" value="Baz">Baz</option>
  <option data-display="*** QUX ***" value="Qux">Qux</option>
</select>

A: Found something similar to what you're asking for here:
https://stackoverflow.com/a/19184179/6555780
It basically needs to be organised in javascript, so that the selected option shows immediately on the screen, the below code was taken from David's answer and can be viewed here: http://jsfiddle.net/aCb73/
<select name="ref_rubrique" id="ref_rubrique">
    <option value="-- EMPTY --" selected> </option>
    <option value="YES!!!">Yes</option>
</select>

This basically targets the ref_rubique select tag and displays the code in the Javascript based on the selection (defaults as --EMPTY--)
Following our comments below, the following code could possibly help with ng-table:
  self.initialSorting = [
    { label: "Id ASC", value: { id: "asc"} },
    { label: "Id DESC", value: { id: "desc"} },
    { label: "Name ASC", value: { name: "asc"} },
    { label: "Name DESC", value: { name: "desc"} }
  ];

A: What I understand is you want to print the text in select-text attribute.
I've found this example if this is what you are looking for.
<select id="mySelect">
  <option select-text="-- EMPTY --"> </option>
  <option select-text="YES!!!">Yes</option>
  <option>No</option>
</select>

$("#mySelect").change(function(){
   $("#mySelect option:selected").text($("#mySelect").val());
});

This is where I found something similar.
HTML select shows value instead of text


text:
Q: how to launch or invoke microsoft tag reading app from within my android application? Hi I would like to know how to invoke Microsoft tag reader app from within my android application, like as soon as my application opens the tag reader should be invoked automatically. Any code snippet regarding this query is viable, I would appreciate it.

A: In your Activity onCreate, add the following lines:
Intent intent = new Intent("android.intent.action.MAIN");
PackageManager manager = getPackageManager();
intent = manager.getLaunchIntentForPackage("com.microsoft.tag.app.reader");
intent.addCategory("android.intent.category.LAUNCHER");
startActivity(intent);

The easiest way to figure out the correct package name for any application is by looking at LogCat while launching the activity (filter on ActivityManager).


text:
Q: Setting VideoView width and Height using code I want to set VideoView dimensions and I cannot figure out what am I doing wrong. I don't see dimensions change when I run this code
package com.nati_1.ImageGallerySwitching_v8;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageButton;
import android.widget.VideoView;

import java.util.Arrays;

public class VideoActivity extends AppCompatActivity {

    ImageButton floatButtonPlay;
    ImageButton floatButtonPause;
    ImageButton floatButtonBack;

    private Integer videos[];
    private Integer videos1[]={R.raw.vid4_1, R.raw.vid5_1_6m, R.raw.vid3_3m, R.raw.vid2_2_9m};
    private Integer videos2[]={R.raw.vts_0, R.raw.vts_1, R.raw.vts_5, R.raw.vts_6};

    @Override
    public void onBackPressed() {
        super.onBackPressed();

        overridePendingTransition(R.anim.mainfadein, R.anim.splashfadeout);

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video);

        floatButtonPlay=(ImageButton) findViewById(R.id.playButton);
        floatButtonPause=(ImageButton) findViewById(R.id.pauseButton);
        floatButtonPlay.setVisibility(View.INVISIBLE);
        floatButtonBack=(ImageButton) findViewById(R.id.backButton);

        final MyVideoView video1=(MyVideoView)findViewById(R.id.MyVideoView);

        videos= Arrays.copyOf(videos1,videos1.length);

        switch (MainActivity.AlbumChosed){

            case 1:
                videos= Arrays.copyOf(videos1,videos1.length);
                break;
            case 2:
                videos= Arrays.copyOf(videos2,videos2.length);
                break;

                default:
        }

        if (MainActivity.VidNum==MainActivity.vidPosition[0] ){
                                             setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

                    video1.setVideoSize(70,70);

                    video1.setVideoPath("android.resource://" + getPackageName() + "/" + videos[0]);
                }

                else if
    ........
    ........

        video1.start();

        video1.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                floatButtonPause.setVisibility(View.INVISIBLE);
                floatButtonPlay.setVisibility(View.VISIBLE);
                floatButtonBack.setVisibility(View.VISIBLE);

            }
        });

        floatButtonPlay.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                floatButtonPlay.setVisibility(View.INVISIBLE);
                floatButtonPause.setVisibility(View.VISIBLE);

                video1.start();

            }
        } );

        floatButtonPause.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                floatButtonPause.setVisibility(View.INVISIBLE);
               ....
                if(video1.isPlaying()){
                    video1.pause();
                }
            }
        } );

        floatButtonBack.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View view) {
                finish();
                overridePendingTransition(R.anim.mainfadein, R.anim.splashfadeout);

            }
        });

    }

    public class MyVideoView extends VideoView {

        private int mVideoWidth;
        private int mVideoHeight;

        public MyVideoView(Context context, AttributeSet attrs) {
            super(context, attrs);
        }

        public MyVideoView(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }

        public MyVideoView(Context context) {
            super(context);
        }

        public void setVideoSize(int width, int height) {
            mVideoWidth = width;
            mVideoHeight = height;
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            // Log.i("@@@", "onMeasure");
            int width = getDefaultSize(mVideoWidth, widthMeasureSpec);
            int height = getDefaultSize(mVideoHeight, heightMeasureSpec);
            if (mVideoWidth > 0 && mVideoHeight > 0) {
                if (mVideoWidth * height > width * mVideoHeight) {
                    // Log.i("@@@", "image too tall, correcting");
                    height = width * mVideoHeight / mVideoWidth;
                } else if (mVideoWidth * height < width * mVideoHeight) {
                    // Log.i("@@@", "image too wide, correcting");
                    width = height * mVideoWidth / mVideoHeight;
                } else {
                    // Log.i("@@@", "aspect ratio is correct: " +
                    // width+"/"+height+"="+
                    // mVideoWidth+"/"+mVideoHeight);
                }
            }
            // Log.i("@@@", "setting size: " + width + 'x' + height);
            setMeasuredDimension(width, height);
        }
    }

}

My XML is the next
 <?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background1"
    tools:context="com.nati_1.ImageGallerySwitching_v8.VideoActivity">

    <com.nati_1.ImageGallerySwitching_v8.VideoActivity.MyVideoView

        android:id="@+id/MyVideoView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginBottom="25dp"
        android:layout_marginTop="25dp"
        android:layout_marginLeft="25dp"
        app:layout_constraintVertical_bias="0.428"
        android:layout_marginRight="25dp"
        android:layout_marginStart="25dp"
        android:layout_marginEnd="25dp" />

    <!-- "play" was taken from https://www.flaticon.com/ -->
    <!--    android:src="@mipmap/pause128"-->
    <ImageButton
        android:id="@+id/playButton"
....
....

I get FATAL EXCEPTION
01-18 21:31:28.053 28639-28639/com.nati_1.ImageGallerySwitching_v6 E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: com.nati_1.ImageGallerySwitching_v6, PID: 28639
                                                                                java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nati_1.ImageGallerySwitching_v6/com.nati_1.ImageGallerySwitching_v8.VideoActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.nati_1.ImageGallerySwitching_v8.VideoActivity.MyVideoView
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                                                at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
                                                                                Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.nati_1.ImageGallerySwitching_v8.VideoActivity.MyVideoView
                                                                                Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.nati_1.ImageGallerySwitching_v8.VideoActivity.MyVideoView
                                                                                Caused by: java.lang.ClassNotFoundException: Didn't find class "com.nati_1.ImageGallerySwitching_v8.VideoActivity.MyVideoView" on path: DexPathList[[zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/base.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.nati_1.ImageGallerySwitching_v6-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.nati_1.ImageGallerySwitching_v6-2/lib/x86, /system/lib, /vendor/lib]]
                                                                                at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                                at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
                                                                                at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                                at android.view.LayoutInflater.createView(LayoutInflater.java:609)
                                                                                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
                                                                                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)


text:
Q: how to get all branches of my forked git repo I have cloned, pulled and fetched my remote git repo at BitBucket. But I could only get the master branch. My repo at BitBucket has 4 branches:

*

*master

*fix/cleanup

*etc/schema_note

*feature/sampledata

I have found the two questions this and that. I followed some of the instructions in those questions.
When I tried git branch -a, I could not see the other three branches.
*master
 remotes/origin/HEAD -> origin/master
 remotes/origin/master

I tried git checkout origin/fix/cleanup. I got an error message.

error: pathspec 'origin/fix/cleanup` did not match any file(s) known
  to git.

I tried checkout -b, but got another error.
$ git checkout -b fix/cleanup origin/fix/cleanup
fatal: Cannot update paths and switch to branch 'fix/cleanup' at the same time.
Did you intend to checkout 'origin/fix/cleanup' which can not be resolved as com
mit?

I also tried to execute the oneliner.
for remote in `git branch -r`; do git branch --track $remote; done

But it gave me the new branches origin/HEAD and origin/master in my local, not for the other 3 branches. What is going on my repo?
I tried git fetch --all and git pull --all. They gave me nothing changed.

A: I eventually found a fix. I tweaked the git config file.
I changed
fetch = +refs/heads/master:refs/remotes/origin/master
to
fetch = +refs/heads/*:refs/remotes/origin/*
Then, $ git fetch --all worked for the changes.
Fetching origin
Password for 'https://myusername@bitbucket.org':
remote: Counting objects: 993, done.
remote: Compressing objects: 100% (581/581), done.
Receiving objects: 100% (966/966), 723.76 KiB | 8.00 KiB/s, done.
emote: Total 966 (delta 324), reused 964 (delta 322)Resolving deltas:   0% (0/32

Resolving deltas: 100% (324/324), completed with 21 local objects.
From https://bitbucket.org/myusername/myproj
 * [new branch]      etc/schema_note -> origin/etc/schema_note
 * [new branch]      feature/sampledata -> origin/feature/sampledata
 * [new branch]      fix/cleanup -> origin/fix/cleanup

Now, $ git branch -a started to list all remote branches;
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/etc/schema_note
  remotes/origin/feature/sampledata
  remotes/origin/fix/cleanup
  remotes/origin/master

Finally, I checkout for every branch.
TPP@SITHU /d/xampp/htdocs/myproj (master)
$ git checkout etc/schema_note
Branch etc/schema_note set up to track remote branch etc/schema_note from origin.
Switched to a new branch 'etc/schema_note'

TPP@SITHU /d/xampp/htdocs/myproj (etc/schema_note)
$ git checkout feature/sampledata
Branch feature/sampledata set up to track remote branch feature/sampledata from
origin.
Switched to a new branch 'feature/sampledata'

TPP@SITHU /d/xampp/htdocs/myproj (feature/sampledata)
$ git checkout fix/cleanup
Branch fix/cleanup set up to track remote branch fix/cleanup from origin.
Switched to a new branch 'fix/cleanup'

Here is my final repo branch list:
$ git branch -a
  etc/schema_note
  feature/sampledata
* fix/cleanup
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/etc/schema_note
  remotes/origin/feature/sampledata
  remotes/origin/fix/cleanup
  remotes/origin/master

A: If you cloned the repo, you should already have all remote branches.
The way git works is every copy of the repository is basically the same. The moment you clone a repo, you get everything the remote server has, including all history.
If you see branches in one place but not another, (e.g. on one client but not another), then it can only mean:

*

*There are branches local to one location that hasn't been propagated to the remote server
and/or

*The local client hasn't fetched/pulled the propagated changes
edit
actually, could git namespaces be relevant here?


text:
Q: ML_Net It says 'Features' is there but it doesn't exist  public class TextData
{
    [LoadColumn(0)]
    public string Subject { get; set; }

    [LoadColumn(1), ColumnName("Valid")]
    public bool Valid { get; set; }

    [LoadColumn(2)]
    public string Text { get; set; }
}

public class Prediction_Subejct : TextData
{
    [ColumnName("PredictedLabel")]
    public bool Prediction { get; set; }

    public float Probability { get; set; }

    public float Score;

    [ColumnName("PredictedSub")]
    public string SubFeatures { get; set; }
}

The code above is the class I created.
static IEstimator<ITransformer> Subject_ProcessData()
    {
        var subjectModel = _mlContext.Transforms.Conversion.MapValueToKey(inputColumnName: "Subject", outputColumnName: "Labels")
           .Append(_mlContext.Transforms.Text.FeaturizeText(inputColumnName: "Text", outputColumnName: "TextFeaturized"))
           .Append(_mlContext.BinaryClassification.Trainers.SdcaLogisticRegression(labelColumnName: "Valid", featureColumnName: "Features"))
           // Features 에 데이터를 연결
           .Append(_mlContext.Transforms.Concatenate("Features", "TextFeaturized"))

           // DataView 캐쉬
           .AppendCacheCheckpoint(_mlContext);

        return subjectModel;
    }

The code above is the pipeline I created.
 var Pipeline = pipeline.Append(_mlContext.MulticlassClassification.Trainers.SdcaMaximumEntropy("Label", "Features"))
        .Append(_mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));

        var model = Pipeline.Fit(_trainingDataView);

Running Fit() gave an error.

Unhandled exception. System.ArgumentOutOfRangeException: Could not find feature column 'Features' (Parameter 'inputSchema')

Why does it say 'Features' doesn't exist?

A: "Features" is reserved in the Concatenate method, it expects an array of features after it. So you will need to change this name.
Do something like:
var subjectModel=_mlContext.Transforms.Conversion.MapValueToKey(inputColumnName: "Subject", outputColumnName: "Labels")
   .Append(_mlContext.Transforms.Text.FeaturizeText(inputColumnName: "Text", outputColumnName: "TextFeaturized"))
.Append(_mlContext.Concatenate("Features", new[] {"TextFeaturized"})


text:
Q: Как убрать расстояние между элементами в QVBoxLayout? В вертикальный контейнер box2 я добавляю 3 кнопки. Мне нужно избавиться от расстояния между ними:

Пытался передать параметр spacing = 0, но, как я понял, он убирает только горизонтальное расстояние. Пожалуйста, подскажите, как можно решить мою проблему?
from PyQt5 import QtCore, QtGui, QtWidgets

class MyWindow(QtWidgets.QWidget):
    def __init__(self, *args, **kwargs):
        super(MyWindow, self).__init__(*args, **kwargs)

        self.resize(100, 200)

        main_box = QtWidgets.QHBoxLayout(self)

        btn = QtWidgets.QPushButton('Button')
        main_box.addWidget(btn)

        box2 = QtWidgets.QVBoxLayout(spacing = 0)   # <---
        main_box.addLayout(box2)

        for i in range(0, 3):
            btn = QtWidgets.QPushButton('Button')
            box2.addWidget(btn)

if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    w = MyWindow()
    w.show()
    sys.exit(app.exec_())

A:
QBoxLayout::addStretch(int stretch = 0)
Добавляет растягиваемое пространство (QSpacerItem) с нулевым минимальным размером и коэффициентом растяжения растягивания до конца этого макета блока.

from PyQt5 import QtCore, QtGui, QtWidgets

class MyWindow(QtWidgets.QWidget):
    def __init__(self, *args, **kwargs):
        super(MyWindow, self).__init__(*args, **kwargs)

        self.resize(100, 200)

        main_box = QtWidgets.QHBoxLayout(self)

        btn = QtWidgets.QPushButton('Button')
        main_box.addWidget(btn)

        box2 = QtWidgets.QVBoxLayout(spacing = 0)
        box2.addStretch(1)                                 # <---

        main_box.addLayout(box2)

        for i in range(0, 3):
            btn = QtWidgets.QPushButton('Button')
            box2.addWidget(btn)
        box2.addStretch(1)                                 # <---

if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    w = MyWindow()
    w.show()
    sys.exit(app.exec_())

Update
Обратите внимание, я переименовал левую кнопку Button !, а кнопкам Button применил стиль.
from PyQt5 import QtCore, QtGui, QtWidgets

class MyWindow(QtWidgets.QWidget):
    def __init__(self, *args, **kwargs):
        super(MyWindow, self).__init__(*args, **kwargs)

        self.resize(100, 200)

        main_box = QtWidgets.QHBoxLayout(self)

        btn = QtWidgets.QPushButton('Button !')
        main_box.addWidget(btn)

        box2 = QtWidgets.QVBoxLayout(spacing = 0)

        box2.addStretch(1)                                 # <---

        main_box.addLayout(box2)

        for i in range(0, 3):
            btn = QtWidgets.QPushButton('Button')
            box2.addWidget(btn)
        box2.addStretch(1)                                 # <---

qss ='''
QPushButton[text="Button"] {
    background-color: #999;
    font-weight: bold;
    font-size: 15px;
}
'''

if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    app.setStyleSheet(qss)
    w = MyWindow()
    w.show()
    sys.exit(app.exec_())


text:
Q: how to plot images instead of dots in a 3d matplotlib figure? I have a list like this, image for the path of each image file, xyz for the coordination of each image in the 3d figure:
my list
I searched below is a solution for 2D, which works fine, but obviously not working for 3d:
Matplotlib: How to plot images instead of points?
I also searched for below- a solution for 3d, which works fine, but it only shows annotation text, rather than images:
Matplotlib: Annotating a 3D scatter plot
can someone help? thanks.


text:
Q: Is it feasible to support multiple applications of the same type that are all written in different languages? As much as we would all like to say it is a benefit to programmers to be language agnostic, is it really feasible to support multiple enterprise Web applications of the same type all written in different languages? Think about how complicated a CMS or e-commerce system can be -- now imagine supporting three different CMS platforms all written in different languages. I would hate to be known as a .NET or Java or PHP shop, but I also don't want to be the vendor who says they can support a solution they have never worked with, upsetting a client who wonders why we can't get something done right on time. Can anyone speak from experience on this? Does your company usually just suck it up, and try and to learn a new platform on the fly? Do you bill up-to-speed, or eat those costs?

A: I think it all depends on who your clients are and what they expect.  I think knowing about different technologies is good, but really when you're hired by someone, they expect you to know what you are doing.  Personally, I would much rather be known that I do a really good job with a certain type of technology and when hired, I get the job done well.
If you try and go after every contract without regard to what your core competencies are, you aren't going to succeed.  You'll anger the people who do hire you and make mistakes, and you'll potentially miss opportunities where you can really shine.  Sometimes you have to make compromises to pay the bills, but if you aren't careful, it can bite you in the end.
The large consulting firms I've worked with throw resources at it and hope they don't anger too many people.  They mainly do this because they know that the people who work with the consultants and get angry when they don't get the job done aren't the ones making the decisions to keep them hired.  To them (not all of them I know, but some definately), don't care if they screw up because they ultimately know they can convince the VPs and SVPs to keep them around.

A: To be honest, I think you tend to see this kind of thing happen over time, no matter how disciplined the organization is. It's natural for new methodologies to come bundled in the form of new libraries, frameworks, or even languages. Keep in mind that a .NET shop may well have been a ASP/VB shop at one time. They'll probably still maintain older systems for clients, because there's little benefit to rewriting everything from scratch.
I'm not sure anyone has the luxury to keep everything "the same," because language issues are minor compared to library or framework issues -- especially the ones you build yourself.


text:
Q: how the constructor of custom attribute take optional parameters Hi guys i surf on the internet for custom attributes. i grasp the concept but, surprise  and confuse to see that they set properties value through constructor of attribute class as parameter which is not taking any parameter as value from constructor. please clarify the core concept.
[DeBugInfo(45, "Zara Ali", "12/8/2012", **Message = "Return type mismatch"**)]
 //like the Message here.

    public class DeBugInfo : System.Attribute
{
private int bugNo;
private string developer;
private string lastReview;
public string message;
public DeBugInfo(int bg, string dev, string d)
  {
   this.bugNo = bg;
   this.developer = dev;
   this.lastReview = d;
  }
  public int BugNo
 {
 get
 {
 return bugNo;
 }

public string Developer
{
get
{
 return developer;
 }
 }
 public string LastReview
{
get
{
return lastReview;
}

public string Message
{
 get
{
 return message;
 }
  set
  {
    message = value;
  }
 }

 //////////////////////////

A: The attribute syntax is ... a bit different to regular C# code. In regular C#, if you were creating that object manually, that would be similar to an object initializer:
var obj = new DeBugInfo(45, "Zara Ali", "12/8/2012") {
    Message = "Return type mismatch"
};

However, in reality, attributes aren't really instantiated in this way, at least not until they are absolutely required. An attribute is actually raw metadata stamped into the IL, consisting of:

*

*a constructor token

*parameters for the constructor, composed of simple values

*additional property/field assignment mappings and corresponding simply values

You can actually inspect all this information without ever actually creating an instance of the type. But if you use Attribute.GetAttributes etc, it figures out what it represents, and essentially applies the constructor and mappings at runtime.
For a complete example:
using System;

class DeBugInfoAttribute : Attribute
{
    public string Message { get; set; }
    public DeBugInfoAttribute(int i, string j, string k)
    {
        // to show we never get here!
        throw new NotImplementedException();
    }
}

[DeBugInfo(45, "Zara Ali", "12/8/2012", Message = "Return type mismatch")]
static class Program
{
    static void Main()
    {
        // this doesn't create the attribute, so no exception
        foreach (var data in typeof(Program).GetCustomAttributesData())
        {
            Console.WriteLine(data.AttributeType.Name);
            var parameters = data.Constructor.GetParameters();
            int i = 0;
            foreach (var arg in data.ConstructorArguments)
            {
                Console.WriteLine("{0}: {1}",
                    parameters[i++].Name,
                    arg.Value);
            }
            foreach (var binding in data.NamedArguments)
            {
                Console.WriteLine("{0}: {1}",
                    binding.MemberInfo.Name,
                    binding.TypedValue);
            }
        }
        // but this does: BOOM!
        var attribs = Attribute.GetCustomAttributes(typeof(Program));
    }
}


text:
Q: Silencing broken pipe errors (`[Errno 32] Broken pipe`) in python with WSGI+Pyramid I have a rather simple, naive Python/WSGI/Pyramid web-server.
It's run using wsgiref.simple_server.make_server(), on a server built using pyramid.config.Configurator().make_wsgi_app(). This server works fine.
However, the application it's serving has a lot of javascript image mouseover popups. If you run the mouse across the page, it can generate 20+ image requests. This is fine as well (It's an internal thing, not a lot of users).
However, doing so causes the server to emit something like half a dozen error tracebacks:
10.1.1.4 - - [25/Apr/2014 01:56:42] "GET /*SNIP* 500 59
----------------------------------------
Exception happened during processing of request from ('10.1.1.4', 18338)
Traceback (most recent call last):
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 274, in write
    self.send_headers()
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 333, in send_headers
    self._write(bytes(self.headers))
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 453, in _write
    self.stdout.write(data)
  File "/usr/lib/python3.4/socket.py", line 391, in write
    return self._sock.send(b)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 141, in run
    self.handle_error()
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 368, in handle_error
    self.finish_response()
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 274, in write
    self.send_headers()
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/socketserver.py", line 306, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.4/socketserver.py", line 332, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.4/socketserver.py", line 345, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.4/socketserver.py", line 666, in __init__
    self.handle()
  File "/usr/lib/python3.4/wsgiref/simple_server.py", line 126, in handle
    handler.run(self.server.get_app())
  File "/usr/lib/python3.4/wsgiref/handlers.py", line 144, in run
    self.close()
  File "/usr/lib/python3.4/wsgiref/simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'

I understand why I'm getting broken pipe errors (the request for the image is canceled before the image has fully transfered, because the mouseover popup has closed), and it seems harmless.
However, I have no idea how to silence this traceback. There are thousands of them in my logs, and it makes debugging actual errors a nightmare. I don't care that I'm getting broken pipe errors, how can I catch them and swallow them silently?
It seems like wsgiref.simple_server.make_server() installs an internal handler that catches BrokenPipeError: [Errno 32] Broken pipe, prints the traceback, and then swallows the error. I've tried wrapping the run_server() call in a try-except clause, and it doesn't have any effect.

A: I wound up just switching to using the CherryPy WSGI Server. It doesn't suffer from the broken pipe log issues, and is probably far more robust as well.
It also uses a threadpool, so it's more performant as well (multiple requests aren't blocking!).

A: I didn't find a straightforward way for achieving this, however, you can always do some monkey patching:
from wsgiref.handlers import BaseHandler
import sys

def ignore_broken_pipes(self):
    if sys.exc_info()[0] != BrokenPipeError: BaseHandler.__handle_error_original_(self)

BaseHandler.__handle_error_original_ = BaseHandler.handle_error
BaseHandler.handle_error = ignore_broken_pipes

You will not see these annoyances after running this code somewhere in the beginning anymore.
For me, it looks like a bug somewhere in wsgiref implementation of BaseHandler:
def handle_error(self):
    """Log current error, and send error output to client if possible"""
    self.log_exception(sys.exc_info())
    if not self.headers_sent:
        self.result = self.error_output(self.environ, self.start_response)
        self.finish_response()
    # XXX else: attempt advanced recovery techniques for HTML or text?

if BrokenPipeError is handled by this method, finish_response crashes. Why do we ever want to finish response if pipe is broken? Where the data is sent to?


text:
Q: Printing GroupBox directly from label printer I have to create a label with a code39 barcode and some information text.
I create the label inside a GroupBox, which works perfectly fine. After the label creation is done, I have to print this GroupBox (or at least the controls inside) with a label printer (Meto SP40 II).
To print the GroupBox, I draw it to a bitmap and save the bitmap as jpg and print the jpg. When I print the jpg with a "normal" printer, the quality is fine and I can scan the bar-code without a problem. But when I print the jpg with the label printer, the quality is really bad and i can't scan the bar-code. This is the code I use to create and print the jpg.
public void PrintBarcodeGrpb()
{
     Bitmap bmp = new Bitmap(groupBox1.Width, groupBox1.Height);
     groupBox1.DrawToBitmap(bmp,groupBox1.ClientRectangle);
     bmp.Save(barcodeSavePath, ImageFormat.Jpeg);

     PrintDocument doc = new PrintDocument();
     doc.PrintPage += Doc_PrintPage;
     doc.PrinterSettings.DefaultPageSettings.PaperSize = new PaperSize("Etiketten", 75, 40);
     doc.Print();
     doc.Dispose();

}

private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{

     Image img = Image.FromFile(barcodeSavePath);
     Point loc = new Point(0,0);
     e.Graphics.DrawImage(img, loc);

}

I guess the quality problem occurs because the printer has a problem with the jpg. But even when I print the bitmap directly without saving it as jpg, the quality is the same. Is there a way to print the GroupBox without drawing it to a bitmap?
EDIT
When I create and print the label this way:
e.Graphics.DrawString(BarcodeLocation, textFont, Brushes.Black, 33,29);
        e.Graphics.DrawString(BarcodeText, barcodeFont, Brushes.Black, 15, 58);
        e.Graphics.DrawString(BarcodeText, textFont, Brushes.Black, 35, 97);
        e.Graphics.DrawString(lblKST.Text, textFont, Brushes.Black, 233, 29);
        e.Graphics.DrawString(lblKTR.Text, textFont, Brushes.Black, 233, 97);
        e.Graphics.DrawString(CostCentre, textFont, Brushes.Black, 233, 120);
        e.Graphics.DrawString(CostTypes, textFont, Brushes.Black, 33, 120);

the quality of the printed label is fine. It's a lot of testing and printing before everything is on the right place, but for me it was a lot easier then trying to print the whole GroupBox.


text:
Q: An efficient way to apply a function over a list of dataframes I have a list of dataframes in R. What I need to do is apply a function to each dataframe, in this case removing special characters, and have returned a list of dataframes.
Using lapply and as.data.frame the following works fine and delivers exactly what I need:
my_df =data.frame(names = seq(1,10), chars = c("abcabc!!", "abcabc234234!!"))
my_list = list(my_df, my_df, my_df)

#str(my_list)
List of 3
 $ :'data.frame':   10 obs. of  2 variables: ...

new_list <- lapply(my_list, function(y) as.data.frame(lapply(y, function(x) gsub("[^[:alnum:][:space:]']", "", x))))

# str(new_list)
List of 3
 $ :'data.frame':   10 obs. of  2 variables:
  ..$ names: Factor w/ 10 levels "1","10","2","3",..: 1 3 4 5 6 7 8 9 10 2
  ..$ chars: Factor w/ 2 levels "abcabc","abcabc234234": 1 2 1 2 1 2 1 2 1 2
 $ :'data.frame':   10 obs. of  2 variables:
  ..$ names: Factor w/ 10 levels "1","10","2","3",..: 1 3 4 5 6 7 8 9 10 2
  ..$ chars: Factor w/ 2 levels "abcabc","abcabc234234": 1 2 1 2 1 2 1 2 1 2
 $ :'data.frame':   10 obs. of  2 variables:
  ..$ names: Factor w/ 10 levels "1","10","2","3",..: 1 3 4 5 6 7 8 9 10 2
  ..$ chars: Factor w/ 2 levels "abcabc","abcabc234234": 1 2 1 2 1 2 1 2 1 2

But I am wondering if there is a more efficient way that doesn't require nested lapply. Perhaps a different apply-family function that returns the elements as a dataframe?

A: We don't need a nested lapply, just a single lapply with transform does it
lapply(my_list, transform, chars = gsub("[^[:alnum:][:space:]']", "", chars))

The pattern can be made compact to "[^[[:alnum:] ']"

A: While @akrun is right that your second lapply call is useless in this example, I think it does not solve the general case where many columns might be relevant, and it is unknown which might be.
What is inefficient here is the conversion back with as.data.frame, not the inner lapply call. The lapply call itself is almost just as fast as if you would apply the function to a single vector or a matrix of the same size.
If you really want to be more time-efficient here, I would suggest using data.table. I've made the example a bit larger so we can time it.
library(data.table)

f <- function(x) gsub("[^[:alnum:][:space:]']", "", x)

my_df <- as.data.frame(matrix(paste0(sample(c(letters,'!'), size=1000000, replace=T),
                                 sample(c(letters,'!'), size=1000000, replace=T)),
                                 ncol=250), stringsAsFactors = FALSE)
my_list = list(my_df, my_df, my_df)

system.time(lapply(my_list, function(y) as.data.frame(lapply(y, f))))
# 2.256 seconds

my_dt <- as.data.table(my_df)
my_list2 = list(my_dt, my_dt, my_dt)

system.time(lapply(my_list2, function(y) y[,lapply(.SD,f)]))
# 1.180 seconds


text:
Q: How to convert degrees minutes seconds to hour minutes seconds (and viceversa)? I'm reading the book "Practical Astronomy with your Calculator or Spreadsheet 4th Edition" and I want to implement formula 22: Converting between angles expressed in degrees and angles expressed in hours. It says that:

To convert between angles expressed in decimal hours and angles
  expressed in decimal degrees, simply multiply or divide by 15.

So, I have to convert a angle in degrees minutes and seconds into decimal degrees and then multiply it 15 (or divide it by 15?).
When do I have to multiply and when do I have to divide by 15?
Or
How to convert degrees minutes seconds to hour minutes seconds (and viceversa)?

A: Nope!  360 degrees is 24 hours.  360 divided by 24 is 15.  So 15 degrees is 1 hour of right ascension.

A: In one day = $24$ hours the sky ''rounds'' $360°$, so:
$$
24:360=h:\alpha°
$$

A: Each hour is $360^\circ/24=15^\circ$. Each minute of time is $15^\circ/60=15^\prime$, i.e. $15$ arcminutes. Each second of time is $15^\prime/60=15^{\prime\prime}$, i.e. $15$ arcseconds.

A: Most clocks feature a $12$ hours dial and a full turn is $360°$. Hence an hour is $30°$ !


text:
Q: Spring AMQP Responding to ReplyTo Queue from MessageListener If I am asynchronously listening to Spring AMQP messages how do I respond using the ReplyTo Queue and Correlation ID provided by the sender?
    @Override
public void onMessage(Message message) {

    byte[] bytes = message.getBody();

    String body = new String (bytes);

    logger.info(application + " processing message: \n" + body);

    //some business logic

    //now I want to respond to the replyto queue with the correlation ID
    //rabbitTemplate.????

}

A: Based on the helpful feedback here is the equivalent solution using Spring Messaging:
public void onMessage(Message message) {

//mock response body
String body = "{ \"processing\": \"123456789\"}";

//mock response properties
MessageProperties properties = new MessageProperties();
properties.setContentType(MediaType.APPLICATION_JSON.toString());
properties.setContentEncoding(StandardCharsets.UTF_8.name());

//return the Correlation ID if present
if (message.getMessageProperties().getCorrelationId() != null) {

    properties.setCorrelationId(message.getMessageProperties().getCorrelationId());
}

//create and return the response message
Message responseMessage = new Message(body.getBytes(), properties);

rabbitTemplate.send(message.getMessageProperties().getReplyTo(), responseMessage);

logger.info("Processed and returned message");

}
The confusing part for someone new to AMQP is knowing that the reply-to message property is the "Routing Key" value when replying (send or convertAndSend methods). And that temporary queues are created in the default exchange. This is not always the case with a permanent reply-to queue which would require a correlation-id (not necessary with temp reply-to queue).

A: One work-around I found was to extend ChannelAwareMessageListener and constructing the response as follows
@Override
public void onMessage(Message message, Channel channel) {

    String body = new String (message.getBody());

    String correlationId = new String (message.getMessageProperties().getCorrelationId());

    String replyTo = new String (message.getMessageProperties().getReplyTo());

    logger.info("Processing message with Correlation ID : "
            + correlationId + " Replying To: " + replyTo + " and Message: \n"
            + body);

    BasicProperties basicProperties = new BasicProperties
            .Builder()
            .correlationId(correlationId)
            .contentType(MediaType.APPLICATION_JSON.getType())
            .contentEncoding(StandardCharsets.UTF_8.name())
            .build();

    String response = "{\"response\":" + body + "}";

    try {

        channel.basicPublish( "", replyTo, basicProperties, response.getBytes());

    } catch (IOException e) {

        logger.error("Failed to send message: \n" + e.getMessage());
    }

    logger.info("Processed Message");
}

This works fine but it would be great if I could respond similarly using the RabbitMQTemplate.

A: You can simply call AmqpTemplate.send(routingKey, message).
As a routing key use the reply-to value. The template will publish to the default exchange and route the message to the queue specified as a routing key (which is your reply-to queue).
Also, you may want set the correlation id if the other side is doing request-reponse, so the response could be matched with request.


text:
Q: Concatenate class/id in jQuery I would like to know if you can actually concatenate class's/ID's in jQuery to DRY more effectively.
like this:
$(".div1").hover(function() {
        $(".title").hide();
    });

$(".div2").hover(function() {
        $(".title").hide();
    });

to this:
$(".div1 + .div2").hover(function() {
        $(".title").hide();
    });

Is there a way of doing that?
Thank you

A: $(".div1, .div2").hover(function() {

This will fix

A: Try This
    $(".div1, .div2").hover(function() {
            $(".title").hide();
     });

A: you can select more than one element by separating each element with a comma.
$(".div1, .div2").hover(function() {
   $(".title").hide();
});