text:
Q: How do I include libxslt in my iPhone app? I've heard that including libxslt.dylib is grounds for getting your app rejected. I don't know how accurate that is.
Nevertheless, I would like to include the latest version of libxslt. I'd like to do the same thing with libxml2, as well as other libraries in the future.
What is the correct way to include a code library like this in my app?

A: My app was rejected with the following message from Apple.

XYZ app cannot be posted to the App Store because it is using private or undocumented APIs:
Private Symbol References
xsltApplyStylesheet
xsltCleanupGlobals
xsltFreeStylesheet
xsltInit
xsltParseStylesheetFile
xsltSaveResultToString
As you know, as outlined in the iPhone Developer Program License Agreement section 3.3.1, the use of non-public APIs is not permitted. Before your application can be reviewed by the App Review Team, please resolve this issue and upload a new binary to iTunes Connect.

It was my understanding that the libxslt and libxml2 libraries were in fact present on the device and are available via the pull down menu in Xcode. I dynamically link link with these two libraries and my app works beautifully on the device. Hence, the libraries must be on the device.  Why would I need to build these libraries from scratch as static libraries and increase the size of my app?
I can't find any clear way to work around this, aside from not using xml and xslt. That makes no sense at all!
Hilton, have you succeeded in submitting an app to iTunes that uses xslt?

A: I finally got libxslt to build in Xcode, link to my app, and evade the app store rejectionbot.
Basically you have to build libxslt statically and change the symbol names so they don't match the ones that Apple looks for. All symbols xsltFoo() must be changed to zsltFoo(). Also the name of the library itself must be changed from libxslt.a to libzslt.a.
Here's a how to do it in 10 easy steps :)

*

*Create a libxslt subdirectory and put libxslt-1.1.26.tar.gz into it.

*Right click on Target -> YourApp and select Add -> New Build Phase -> New Run Script Build Phase

*Copy the build script below

*Rename the the build phase from "Run Script" to "Build libxslt" and make it first in the list

*Build your project, which will cause libxslt to be configured and built and installed in libxslt/dist

*Right click on Frameworks and select Add -> Existing Files... and then select libxslt/dist/lib/libzslt.a

*Go to Project -> Edit Project Settings -> Build

*Under Search Paths, edit Header Search Paths and add libxslt/dist/include

*Add #include <libxslt/whatever.h> to your code as needed normally

*Use zsltFoo instead of xsltFoo everywhere in your code

Here is the libxslt build script referenced in step #3:
#!/bin/sh

# Setup
LIBXSLT_VERSION="1.1.26"
LIBXSLT_SHA1_CHECKSUM="69f74df8228b504a87e2b257c2d5238281c65154"
GCC_VERSION="4.2.1"
ARCH="arm-apple-darwin10"

# Bail on any error
set -e

# Function that patches a file using sed(1).
# First argument is filename, subsequent arguments are passed to sed(1).
sed_patch_file()
{
    FILE="${1}"
    shift
    sed ${1+"$@"} < "${FILE}" > "${FILE}".new
    if ! diff -q "${FILE}" "${FILE}".new >/dev/null; then
        cat "${FILE}".new > "${FILE}"
    fi
    rm "${FILE}".new
}

# Function that displays the command and then executes it
show_cmd()
{
    echo ${1+"$@"}
    ${1+"$@"}
}

# Dump environment variables
#echo '***************************************************'
#env | sort
#echo '***************************************************'

# Files
SRCBALL="${SOURCE_ROOT}/libxslt/libxslt-${LIBXSLT_VERSION}.tar.gz"
SRCDIR="${SOURCE_ROOT}/libxslt/libxslt-${LIBXSLT_VERSION}"
DISTDIR="${SOURCE_ROOT}/libxslt/dist"

# Verify source is installed
if ! [ -f "${SRCBALL}" ]; then
    echo "ERROR: please download and install ${SRCBALL}" 2>&1
    echo "The SHA1 checksum should be: ${LIBXSLT_SHA1_CHECKSUM}" 2>&1
    exit 1
fi

# Unpack the archive if necessary
if ! [ -e "${SRCDIR}" ]; then

    # Unpack archive
    echo "*** Unpacking archive ${SRCBALL}"
    tar zxf "${SRCBALL}" -C libxslt

    # Rename all symbols xsltFoobar -> zsltFoobar to avoid broken app store link analyzer
    echo "*** Changing symbol names"
    find libxslt/libxslt-"${LIBXSLT_VERSION}" -name '*.[ch]' -print | while read FILE; do
        sed_patch_file "${FILE}" -E 's%([^[:alnum:]_/"]|^)xslt([A-Z])%\1zslt\2%g'
    done

    # Disable build of xsltproc which fails to link
    sed_patch_file libxslt/libxslt-"${LIBXSLT_VERSION}"/Makefile.in -E '/^[[:space:]]xsltproc \\$/d'
fi

# Build and install
if ! [ -e "${DISTDIR}" ]; then

    # Set up autoconf environment variables
    export CPP="${PLATFORM_DEVELOPER_BIN_DIR}/${ARCH}-gcc-${GCC_VERSION} -E"
    export  CC="${PLATFORM_DEVELOPER_BIN_DIR}/${ARCH}-gcc-${GCC_VERSION}"
    export CXX="${PLATFORM_DEVELOPER_BIN_DIR}/${ARCH}-g++-${GCC_VERSION}"
    export CPPFLAGS="-I${SDKROOT}/usr/lib/gcc/${ARCH}/${GCC_VERSION}/include -I${SDKROOT}/usr/include"
    export LDFLAGS="--sysroot=${SDKROOT}"
    export CFLAGS="-Os -pipe ${CPPFLAGS} ${LDFLAGS}"
    export CXXFLAGS="${CFLAGS}"
    export ARCH

    # Configure libxslt
    echo "*** Configuring libxslt-${LIBXSLT_VERSION}"
    ( cd "${SRCDIR}" && show_cmd ./configure \
      --prefix="${DISTDIR}" \
      --build=i386-apple-darwin10 \
      --host="${ARCH}" \
      --enable-static \
      --disable-shared \
      --with-libxml-include-prefix="${SDKROOT}"/usr/include \
      --with-libxml-libs-prefix="${SDKROOT}"/usr/lib \
      --without-python )

    # Build it
    echo "*** Building libxslt-${LIBXSLT_VERSION}"
    ( cd "${SRCDIR}" && show_cmd make )

    # Install it
    echo "*** Installing libxslt-${LIBXSLT_VERSION}"
    ( cd "${SRCDIR}" && show_cmd make install )

    # Change library name to avoid dynamic linking to the iPhone's shared libxslt library
    ln libxslt/dist/lib/lib{x,z}slt.a
fi

A: Hey Hilton, any chance you could let us know how you managed to statically link the LIBXSLT library into your app please?
I'm having exactly the same issue as quite a few others but at the moment at least, I have no idea how to go about turning the dynamic library into a static one.
Thanks.
EDIT: Check out this Version of XSLT in iPhone
My app was rejected for using LibXSLT so instead I manually added the source code and did it that way. My app was approved a few days ago.

A: You can only dynamically link to libraries that are already present on the device.
If you want to link to an external library that is not present on the device, you will have to compile it yourself to a static library and link that instead.

A: Based on Archie's answer, this script (with XCode 5 command line tools) generates a multi-architecture libzslt suitable for inclusion in a project, compatible with iOS 6 and iOS 7 projects (though I haven't included iOS 7 64 bit).
This solution assumes libxslt-1.1.28 is unpacked and in the same directory as the script.
The script creates a directory dependencies which contains the header and lib files. You can include them in an Xcode project by adjusting the header and linker search paths.

    #!/bin/sh
    # build.sh

    GLOBAL_OUTDIR="`pwd`/dependencies"
    LOCAL_OUTDIR="outdir"
    XSLT_LIB="`pwd`/libxslt-1.1.28"

    IOS_BASE_SDK="7.0"
    IOS_DEPLOY_TGT="6.0"

    sed_patch_file()
    {
        FILE="${1}"
        shift
        sed ${1+"$@"}  "${FILE}".new
        if ! diff -q "${FILE}" "${FILE}".new >/dev/null; then
            cat "${FILE}".new > "${FILE}"
        fi
        rm "${FILE}".new
    }

    patch_libxslt() {
        export LIBXSLT_VERSION=1.1.28
        echo "*** Changing symbol names"
        find libxslt-"${LIBXSLT_VERSION}" -name '*.[ch]' -print | while read FILE; do
                sed_patch_file "${FILE}" -E 's%([^[:alnum:]_/"]|^)xslt([A-Z])%\1zslt\2%g'
        done

            # Disable build of xsltproc which fails to link
        sed_patch_file libxslt-"${LIBXSLT_VERSION}"/Makefile.in -E '/^[[:space:]]xsltproc \\$/d'
    }

    setenv_all()
    {
        unset LIBRARIES
        export LIBRARIES=${SDKROOT}/usr/lib
        echo "*** LIBRARIES: ${LIBRARIES}"

        # Add internal libs
        export LDFLAGS="--sysroot=${SDKROOT} $LDFLAGS -L${LIBRARIES}"
        export CFLAGS="--sysroot=${SDKROOT} $CFLAGS -I${SDKROOT}/usr/lib/gcc/${ARCH}/${GCC_VERSION}/include -I${SDKROOT}/usr/include -arch ${ARCH} -Os -pipe ${CPPFLAGS}"

        export CXX="$PLATFORM_BIN_DIR/g++"
        export CC="$PLATFORM_BIN_DIR/gcc"

        export LD=$TOOLROOT/ld
        export AR=$TOOLROOT/ar
        export AS=$TOOLROOT/as
        export NM=$TOOLROOT/nm
        export RANLIB=$TOOLROOT/ranlib
        export CPPFLAGS=$CFLAGS
        export CXXFLAGS=$CFLAGS

        export CXXFLAGS="${CFLAGS}"
    }

    setenv_arm7()
    {
        unset LN DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAGS DYLD_LIBRARY_PATH ARCH PLATFORM_BIN_DIR TOOLROOT DISTDIR

        export ARCH=armv7
        export DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
        export SDKROOT=$DEVROOT/SDKs/iPhoneOS$IOS_BASE_SDK.sdk
        export PLATFORM_BIN_DIR=/Applications/Xcode.app/Contents/Developer/usr/bin
        export TOOLROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin

        export DYLD_LIBRARY_PATH="$SDKROOT/usr/lib"

        export CFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT -I$SDKROOT/usr/include/"

        setenv_all
    }

    setenv_arm7s()
    {
        unset LN DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAGS DYLD_LIBRARY_PATH ARCH PLATFORM_BIN_DIR TOOLROOT DISTDIR

        export ARCH=armv7s
        export DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
        export SDKROOT=$DEVROOT/SDKs/iPhoneOS$IOS_BASE_SDK.sdk
        export PLATFORM_BIN_DIR=/Applications/Xcode.app/Contents/Developer/usr/bin
        export TOOLROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin

        export DYLD_LIBRARY_PATH="$SDKROOT/usr/lib"

        export CFLAGS="-arch armv7s -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT -I$SDKROOT/usr/include/"

        setenv_all
    }

    setenv_i386()
    {
        unset LN DEVROOT SDKROOT CFLAGS CC LD CPP CXX AR AS NM CXXCPP RANLIB LDFLAGS CPPFLAGS CXXFLAGS DYLD_LIBRARY_PATH ARCH PLATFORM_BIN_DIR TOOLROOT DISTDIR

        export ARCH=i386
        export DEVROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
        export SDKROOT=$DEVROOT/SDKs/iPhoneSimulator$IOS_BASE_SDK.sdk
        export PLATFORM_BIN_DIR=$DEVROOT/usr/bin
        export TOOLROOT=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

        export CFLAGS="-arch i386 -pipe -no-cpp-precomp -isysroot $SDKROOT -miphoneos-version-min=$IOS_DEPLOY_TGT"

        setenv_all
    }

    create_outdir_lipo()
    {
        for lib_i386 in `find $LOCAL_OUTDIR/i386 -name "lib*\.a"`; do
            lib_arm7=`echo $lib_i386 | sed "s/i386/arm7/g"`
            lib_arm7s=`echo $lib_i386 | sed "s/i386/arm7s/g"`
            lib=`echo $lib_i386 | sed "s/i386\///g"`
            mkdir -p $(dirname $lib)
            cmd="xcrun -sdk iphoneos lipo -arch armv7 $lib_arm7 -arch i386 $lib_i386 -arch armv7s $lib_arm7s -create -output $lib"
            echo $cmd
            $cmd
        done
    }

    merge_libfiles()
    {
        DIR=$1
        LIBNAME=$2

        cd $DIR
        for i in `find . -name "lib*.a"`; do
            $AR -x $i
        done
        $AR -r $LIBNAME *.o
        rm -rf *.o __*
        cd -
    }

    #######################
    # libxslt
    #######################

    patch_libxslt

    cd $XSLT_LIB
    rm -rf $LOCAL_OUTDIR
    mkdir -p $LOCAL_OUTDIR/arm7 $LOCAL_OUTDIR/i386

    make clean 2> /dev/null
    setenv_i386

    export DISTDIR=`pwd`/$LOCAL_OUTDIR/i386

    ./configure --prefix="${DISTDIR}" \
    --enable-static \
    --disable-shared \
    --with-libxml-include-prefix="${SDKROOT}"/usr/include \
    --with-libxml-libs-prefix="${SDKROOT}"/usr/lib \
    --without-crypto \
    --without-python || exit
    make "CC=$CC" "CFLAGS=$CFLAGS" "AR=$AR"
    make install

    ln $LOCAL_OUTDIR/i386/lib/lib{x,z}slt.a

    # find ./ -iname *.a | grep -v $LOCAL_OUTDIR | xargs -L 1 -I '{}' cp '{}' $LOCAL_OUTDIR/i386
    # cp -vf lib*.a $LOCAL_OUTDIR/i386

    make clean 2> /dev/null
    setenv_arm7

    export DISTDIR=`pwd`/$LOCAL_OUTDIR/arm7

    ./configure --prefix="${DISTDIR}" \
    --host=armv7-apple-darwin12.5.0 \
    --enable-static \
    --disable-shared \
    --with-libxml-include-prefix="${SDKROOT}"/usr/include \
    --with-libxml-libs-prefix="${SDKROOT}"/usr/lib \
    --without-crypto \
    --without-python || exit
    make -j4
    make install

    ln $LOCAL_OUTDIR/arm7/lib/lib{x,z}slt.a

    # find ./ -iname *.a | grep -v $LOCAL_OUTDIR | xargs -L 1 -I '{}' cp '{}' $LOCAL_OUTDIR/arm7
    # cp -rvf lib*.a $LOCAL_OUTDIR/arm7

    make clean 2> /dev/null
    setenv_arm7s

    export DISTDIR=`pwd`/$LOCAL_OUTDIR/arm7s

    ./configure --prefix="${DISTDIR}" \
    --host=armv7s-apple-darwin12.5.0 \
    --enable-static \
    --disable-shared \
    --with-libxml-include-prefix="${SDKROOT}"/usr/include \
    --with-libxml-libs-prefix="${SDKROOT}"/usr/lib \
    --without-crypto \
    --without-python || exit
    make -j4
    make install

    ln $LOCAL_OUTDIR/arm7s/lib/lib{x,z}slt.a

    # find ./ -iname *.a | grep -v $LOCAL_OUTDIR | xargs -L 1 -I '{}' cp '{}' $LOCAL_OUTDIR/arm7s
    # cp -rvf lib*.a $LOCAL_OUTDIR/arm7s

    create_outdir_lipo
    mkdir -p $GLOBAL_OUTDIR/lib && cp -rvf $LOCAL_OUTDIR/lib/lib*.a $GLOBAL_OUTDIR/lib
    mkdir -p $GLOBAL_OUTDIR/include && cp -rvf $LOCAL_OUTDIR/arm7/include/* $GLOBAL_OUTDIR/include

    cd ..

    echo "Finished!"


text:
Q: How to reflect Generic Type Parameters in C# .NET Consider the following generic classes
Dictionary<TKey, TValue>

List<T>

CustomHashMap<K, V>

Is it possible to reflect back the names given to the generic type parameters?
For Example
"TKey", "TValue"

"T"

"K", "V"

A: This seems to do the trick:
class Program
{
    static IEnumerable<string> GetGenericArgumentNames(Type type)
    {
        if (!type.IsGenericTypeDefinition)
        {
            type = type.GetGenericTypeDefinition();
        }

        foreach (var typeArg in type.GetGenericArguments())
        {
            yield return typeArg.Name;
        }
    }

    static void Main(string[] args)
    {
        // For a raw type
        Trace.WriteLine(string.Join(" ", GetGenericArgumentNames(typeof(Foo<>))));
        Trace.WriteLine(string.Join(" ", GetGenericArgumentNames(typeof(Foo<Quux>))));
    }

}

class Foo<TBar> {}

class Quux {}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Operator overloading < I'm trying to verify if the first object is smaller then the second object.
I'm getting error message the first is areaCircle is not a type.
bool Circle::operator < (const Circle & pc) const
{
    return *this.areaCircle(getradius) < pc.areaCircle(getradius) ? true : false;
}

Here is my areaCircle function
float areaCircle(float radius){return( radius*radius*3.1416);}

A: . has precedence over *. You want ->.
return this->areaCircle(getradius) < pc.areaCircle(getradius) ? true : false;

Or just leave out this-> altogether (it's implicit).

Also, since your areaCircle function doesn't depend on the object's state, you should consider making it a static member function or a free function.


text:
Q: Power Method in MATLAB I would like to implement the Power Method for determining the dominant eigenvalue and eigenvector of a matrix in MATLAB.
Here's what I wrote so far:
%function to implement power method to compute dominant
%eigenvalue/eigenevctor
function [m,y_final]=power_method(A,x);
m=0;
n=length(x);
y_final=zeros(n,1);
y_final=x;
tol=1e-3;
while(1)
    mold=m;
 y_final=A*y_final;
 m=max(y_final);
 y_final=y_final/m;
 if (m-mold)<tol
     break;
 end
end
end

With the above code, here is a numerical example:
 A=[1 1 -2;-1 2 1; 0 1 -1]

A =

     1     1    -2
    -1     2     1
     0     1    -1

>> x=[1 1 1];
>> x=x';
>> [m,y_final]=power_method(A,x);
>> A*x

ans =

     0
     2
     0

When comparing with the eigenvalues and eigenvectors of the above matrix in MATLAB, I did:
[V,D]=eig(A)

V =

    0.3015   -0.8018    0.7071
    0.9045   -0.5345    0.0000
    0.3015   -0.2673    0.7071

D =

    2.0000         0         0
         0    1.0000         0
         0         0   -1.0000

The eigenvalue coincides, but the eigenvector should be approaching [1/3 1 1/3].  Here, I get:
 y_final

y_final =

    0.5000
    1.0000
    0.5000

Is this acceptable to see this inaccuracy, or am I making some mistake?

A: You have the correct implementation, but you're not checking both the eigenvector and eigenvalue for convergence.  You're only checking the eigenvalue for convergence.  The power method estimates both the prominent eigenvector and eigenvalue, so it's probably a good idea to check to see if both converged.  When I did that, I managed to get [1/3 1 1/3].  Here is how I modified your code to facilitate this:
function [m,y_final]=power_method(A,x)
m=0;
n=length(x);
y_final=x;
tol=1e-10; %// Change - make tolerance more small to ensure convergence
while(1)
     mold = m;
     y_old=y_final; %// Change - Save old eigenvector
     y_final=A*y_final;
     m=max(y_final);
     y_final=y_final/m;
     if abs(m-mold) < tol && norm(y_final-y_old,2) < tol %// Change - Check for both
         break;
     end
end
end

When I run the above code with your example input, I get:
>> [m,y_final]=power_method(A,x)

m =

     2

y_final =

    0.3333
    1.0000
    0.3333

On a side note with regards to eig, MATLAB most likely scaled that eigenvector using another norm.  Remember that eigenvectors are not unique  and are accurate up to scale.  If you want to be sure, simply take the first column of V, which coincides with the dominant eigenvector, and divide by the largest value so that we can get one component to be normalized with the value of 1, just like the Power Method:
>> [V,D] = eig(A);
>> V(:,1) / max(abs(V(:,1)))

ans =

    0.3333
    1.0000
    0.3333

This agrees with what you have observed.


text:
Q: problem with sql lines, conflicts and more I am new on this website, I have to enter this SQL instructions  in my DB but I can't solve the error shown below:
*create table category ( id int(10) primary key not null auto_increment, name varchar(50));

create table product ( product_id int(10) primary key not null auto_increment, name varchar(50) , price double(10,2), category_id int(10), description varchar(1000));

alter table product add constraint product_ctgy_id_fk foreign key(category_id) references category( id);

create table userorder(order_id  int(10) primary key not null auto_increment, user_id int(10) , price double(10,2));

create table user(user_id int(10) primary key not null auto_increment, fname varchar(10), lname varchar(10), email_id varchar(50), phone int(10));

alter table userorder add constraint order_user_id_fk foreign key(user_id) references user(user_id);
//alter table product add column description varchar(1000);

create table orderItems ( item_id int(10) primary key not null auto_increment, name varchar(50), quantity int(2), order_id int(10));

alter table orderItems add constraint order_id_fk foreign key(order_id) references userorder(order_id);
 alter table userorder add column order_date date;

 alter table user modify phone varchar(10);

alter table userorder modify order_date timestamp;

 alter table orderItems add column hotness varchar(10);

 alter table user add column address varchar(100);

insert into category values (1,"APPETIZERS");
insert into category values (2,"Soups and Salads");
insert into category values (3,"Tandoori Breads");
insert into category values (4,"Rice and Biryani");
insert into category values (5,"Tandoori Specialities");
insert into category values (6,"Chicken Entrees");
insert into category values (7,"Lamb Entrees");
insert into category values (8,"Sea Food");
insert into category values (9,"Vegetable Delights");
insert into category values (10,"Specials");
insert into category values (11,"Beverages");
insert into category values (12,"Beers");
insert into category values (13,"Deserts");
insert into category values (14,"Side Orders");
insert into product values (1, "VEGETABLE SAMOSA",2.95, 1,"Crisp patties filled with mildly spiced potatoes and peas");
insert into product values (2, "VEGETABLE PAKORA",2.95, 1,"Mixed Vegetable Fritters dipped in batter and fried");
insert into product values (3, "CHICKEN PAKORA",6.95, 1,"Boneless chicken dipped in spiced batter and fried");
insert into product values (4, "CHEESE PAKORA",5.95, 1,"Delicately spiced fried cheese fritters");
insert into product values (5, "FISH PAKORA",8.95, 1,"Fish filets dipped in Spiced batter and fried");
insert into product values (6, "CHICKEN SOUP",4.95, 2,"Indian style, lightly spiced");
insert into product values (7, "MULLIGATAWNY SOUP",3.95, 2,"Delicately Spiced Lentil Soup Garnished with Rice & Chicken");
insert into product values (8, "LENTIL SOUP",2.95, 2,"Mildly spiced");
insert into product values (9, "Vegeterian Salad",3.95, 2,"Lettuce, cheese, cilantro, cucumber, tomatoes");
insert into product values (10, "KACHUMBER/CHICK PEA SALAD",2.95, 2,"Cucumbers, Onions, Tomatoes, Cilantro, Chickpeas & Lemon");
insert into product values(117,"ASSORTED APPETIZERS ",8.95,1,"KABAB, SAMOSA, PAKORA, CHICKEN PAKORA, ONION BHAJI");
insert into product values(118,"PANEER TIKKA (CHEEESE)",12.95,1,"Marinated in spices, cooked in clay over, sautéed in bell pepper & onion");
insert into product values(119,"CHILI CHICKEN",13.95,1,"Boneless chicken sautéed with onion and Bell Pepper");
insert into product values(120,"ONION BHAJI",3.95,1,"Chopped onions dipped in batter and fried");
insert into product values(121,"GULAB JAMUN",3.95,13,"Indian Milk Cheese Balls, Fried & soaked in honey syrup");
insert into product values(122,"KHEER",3.95,13,"Indian Rice Pudding");
insert into product values(123,"PISTACHIO KULFI",4.95,13,"Indian Ice Cream With Pistachios");
insert into product values(124,"MANGO KULFI",4.95,13,"Indian Ice Cream With Mango");
insert into product values(125,"RAITA",2.5,14,"Cultured Yogurt with Cucumbers, Carrots & Spices");
insert into product values(126,"Plain Yogurt",2.5,14,"");
insert into product values(127,"MANGO CHUTNEY",2.5,14,"");
insert into product values(128,"HOT PICKEL",1.95,14,"");
insert into product values(129,"PAPADDAM",1.25,14,"");*

But an error appears "CONFLICT WITH "TABLE" and Entity name expected.
How can i solve this? I need to create that column cause my .war needs it. Otherwise it will return and 500 error.

A: Take a look at the mySql reserved keywords:
https://dev.mysql.com/doc/refman/8.0/en/keywords.html#keywords-8-0-detailed-U
Seems like you trying to create table user with is also mySql keyword.
Try to encapsulate  table name:
create table `user`(

Or, if it possible, rename it to smth like users


text:
Q: new javascript Date from a string and formatting template? I have an application that works in several "cultures".  I will be using many date formats.
I have a string with my format (i.e. 'd/m/y', but keep in mind this is variable) and 2 text inputs with dates in that given format.
I need to compare the dates in input box 1 to input box 2.  I had a method that did this fine, until we added the international formatting.
new Date(endDate) >= new Date(startDate)

This used to work with U.S. only dates.  It does not now.  Is there a method I can use that works like this?:
new Date(endDate, 'd/m/y')

A: You may want to consider moment.js library, which may relieve you from many date manipulation problems, since Javascript can't parse locale formats.  For your case, you'd write
moment("12-25-1995", "MM-DD-YYYY");

which would create a "moment" object, parsing date string to the provided template.


text:
Q: ng build error with property not found I define an object of type any in Typescript but when i build with ng build --prod --aot it shows the property not exist auth_user and auth_password
export const environment = {
  production: false,
  api_url: 'http://localhost:8033',
  token_name: 'X-Auth-Token',
  auth_user: 'X-Auth-Username',
  auth_password: 'X-Auth-Password'
};

authenticate(user: User) {
    var payload:{[x: string]: any} = {}
    payload[environment.auth_user] = user.username;
    payload[environment.auth_password] = user.password;
    return this.apiService.post("/authenticate", {}, new Headers(payload))
}

i also tried
var payload:any = {
      [environment.auth_password]:user.password,
      [environment.auth_user] : user.username
    }

but with no luck.
Any solution will be appreciated.
Error detail
ERROR in /home/vikram/code/angular/start/src/app/user/services/user.service.ts (26,20): Property 'auth_password' does not exist on type '{ production: boolean; api_url: string; }'.
ERROR in /home/vikram/code/angular/start/src/app/user/services/user.service.ts (27,20): Property 'auth_user' does not exist on type '{ production: boolean; api_url: string; }'.

here is my complete service
@Injectable()
export class UserService implements OnInit {

  constructor(private apiService: ApiService, private jwtService: JwtService) {
  }

  ngOnInit() {

  }
  saveUser(user: User): Observable<any> {
    return this.apiService.post("/user", user);
  }
  authenticate(user: User) {
    var payload:any = {
      [environment.auth_password]:user.password,
      [environment.auth_user] : user.username
    }
    return this.apiService.post("/authenticate", {}, new Headers(payload))
  }
}

A: I had two file in the environment folder
environment.ts and environment.prod.ts
And i was executing command ng build --prod --aot
so it was taking environment.prod.ts while building
but in environment.prod.ts these properties were not defined since i never build for production after adding these property to environment.prod.ts
It is working find

A: Try the object's definition this way. Exchange '=' by ':'
export const environment: {
  production: false,
  api_url: 'http://localhost:8033',
  token_name: 'X-Auth-Token',
  auth_user: 'X-Auth-Username',
  auth_password: 'X-Auth-Password'
};


text:
Q: How do I convert date formats using a regex in R? I need to convert dates in my dataframe, from "mddyy" to "m_dd_yyyy" (or "m_d_yyyy") format.
Current data looks like this:
df <- data.frame(x = c("81617", "80117", "62817"))
df
      x
1 81617
2 80117
3 62817

Desired output:
df
          x
1 8_16_2017
2  8_1_2017
3 6_28_2017

Perhaps removing zero values for days between 1-9 using str_remove(), then apply a regex to insert underscores and the "20" prefix to year would work?
Thanks for your help!

A: Using sub
sub("(\\d+)(\\d{2})(\\d{2})$", "\\1_\\2_20\\3", df$x)

Removing leading 0
gsub("_0", "_", sub("(\\d+)(\\d{2})(\\d{2})$", "\\1_\\2_20\\3", df$x))

[1] "8_16_2017" "8_1_2017"  "6_28_2017"

A: No regex required.
This (updated) answer goes to @Henrik:
as.Date(sprintf("%06d", as.integer(vec)), format = "%m%d%y")
# [1] "2017-08-16" "2017-08-01" "2017-06-28"

A: Like @r2evans mentioned, you might be better off converting to a true date object, then utilizing Date's format method. This is safer than regex or string pasting to deal with situations such as having dates from different centuries.
To get a date, you'll want to pad the month portion with a 0. I'm doing that with stringr::str_pad because it's easy, and added a date that doesn't need padding in order to have another test case.
x <- c("81617", "80117", "62817", "120816")
dates <- as.Date(stringr::str_pad(x, width = 6, side = "left", pad = "0"),
                 format = "%m%d%y")
strftime(dates, format = "%m_%d_%Y")
#> [1] "08_16_2017" "08_01_2017" "06_28_2017" "12_08_2016"

In your example, you show them without the 0 padding in the months or dates. Using regex, you can remove any 0s that follow either the beginning of the string or a _.
gsub("(?<=^|_)0", "", strftime(dates, format = "%m_%d_%Y"), perl = TRUE)
#> [1] "8_16_2017" "8_1_2017"  "6_28_2017" "12_8_2016"


text:
Q: Making a query between three access tables does not return value enter image description hereI have three Access tables. I tried to make a query depend on date, but the query does not return any value.
SELECT Sum(income2.mony) AS SumOfmony, Sum(outcome.mony) AS SumOfmony1, Sum(PT.PT_Paid) AS SumOfPT_Paid, Sum(PT.PT_Remain) AS SumOfPT_Remain, PT.PT_Date
FROM (PT INNER JOIN income2 ON PT.PT_Date = income2.dat) INNER JOIN outcome ON PT.PT_Date = outcome.[dat&time]
GROUP BY PT.PT_Date;

A: Seems like you want subqueries, not joins. INNER JOIN returns no records on unmatched results.
Then, there's an additional problem: dates can store fractions of seconds. Comparing dates for equality leads to trouble in Access (see this for an example)
Try querying your external tables using these subqueries:
SELECT Sum(income2.mony) FROM income2 WHERE DateDiff("s",PT.PT_Date, income2.dat) = 0
SELECT Sum(outcome.mony) FROM outcome WHERE DateDiff("s",PT.PT_Date, outcome.[dat&time]) = 0

Implemented:
SELECT
    (SELECT Sum(income2.mony) FROM income2 WHERE DateDiff("s",PT.PT_Date, income2.dat) = 0) As SumOfmony,
    (SELECT Sum(outcome.mony) FROM outcome WHERE DateDiff("s",PT.PT_Date, outcome.[dat&time]) = 0) AS SumOfmony1,
    Sum(PT.PT_Paid) AS SumOfPT_Paid, Sum(PT.PT_Remain) AS SumOfPT_Remain, PT.PT_Dat
FROM PT
GROUP BY PT.PT_Date;


text:
Q: PayPal Mobile Payments Library (iOS) log in button disable I downloaded the PayPalMPL_1-6-5-iPhone_DevelopersPackage from paypal official website,then opened the demoApp project, run in iPad device, when I pressed the button [Pay with PayPal],  a view displayed, I can input my email and password, then pressed the button [Log In], every thing worked good. But someday the [Log In] button is disabled, I can't Log in and can't do anything from then on.
It worked OK in iOS simulator all the time.
I didn't change any code of the demoApp. The same problem occurred in my another application. WHY??? Who can help me? Thanks very much.


text:
Q: simple loop two pixelsearch won't work is there something wrong? Hi I'm newbie using autoit so please guys be gentle :)
so i make a flash internet browser script it perfectly works on single pixelsearch loop, however it won't work if a put another two different pixelsearch is there something wrong? :(
HotKeySet("{HOME}", "Start")
HotKeySet("{END}", "_Exit")

While 1
    Sleep(200)
WEnd

Func Start()
    While 1

        $colorgreen = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x00FF00)
        If Not @error Then
            MouseClick("Left", $colorgreen[0], $colorgreen[1], 1, 1) ;spam left click on the green-color areas
            Sleep(100)

        Else
            PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0xFF0063)
            If Not @error Then
                SoundPlay(@WindowsDir & "\media\tada.wav", 1) ;Alert me using very loud noise when it founds pink color lol
                Sleep(100)
            Else
                Send("{F5}") ;Refresh button
            EndIf
        EndIf
    WEnd
EndFunc   ;==>Start

Func _Exit()
    Exit
EndFunc   ;==>_Exit


text:
Q: How can I run my HP Pavillion dv4000 laptop with VGA output only (using Win XP)? I'd like to use my old HP Pavillion dv4000 laptop as a media server by connecting it to a large monitor but I don't really want to have the laptop screen showing output.
The screen properties dialog doesn't let me disable the laptop screen and Fn-F5 doesn't seem to do anything at all.
Anybody know how to get this to work with this particular laptop?

A: Just me being ignorant.  Turns out I needed to press the fn-f4 key once more as it cycles through three options - laptop only - laptop + VGA - VGA only.  I was only pressing it once and expecting it to switch screens.


text:
Q: Inheritance from template class or multiple constructors? Considering the following template class to work with different boost::asio sockets (i.e., TCP/UDP/Serial):
template<class T>
class Connection:: private boost::noncopyable, public  std::enable_shared_from_this<Connection<T>> {

            Connection(const std::shared_ptr<IoServiceWrapper> &ioService,
                       const std::shared_ptr<boost::asio::io_context::strand> &ioStrand);

  ..
}

where each boost socket object requires specific parameters while opening the connection, e.g., dstAddr and dstPort to create the endpoint for TCP/UDP sockets, and portName, baudRate, serial_port_base parameters (e.g., character size, stop bits etc.) for the serial port.
What is the best approach to provide these parameters which are related to the specific type T of the boost socket?
I was thinking to two possible solutions:
1) Inheritance from the template class, such as:
class TcpPortConnection : public Connection<boost::asio::ip::tcp::socket> {

public:

TcpPortConnection(
    const std::shared_ptr<IoServiceWrapper> &ioService,
    const std::shared_ptr<boost::asio::io_context::strand> &ioStrand,
    const std::string &dstAddress, uint16_t dstPort)
    : Connection(ioService, ioStrand), _dstAddress(dstAddress), _dstPort(dstPort) {}

...

}

2) Multiple constructors for the template class, such as:
template<class T>
class Connection:: private boost::noncopyable, public  std::enable_shared_from_this<Connection<T>> {

            Connection(const std::shared_ptr<IoServiceWrapper> &ioService,
                       const std::shared_ptr<boost::asio::io_context::strand> &ioStrand,
                       const std::string &dstAddress,
                       uint16_t dstPort);

            Connection(const std::shared_ptr<IoServiceWrapper> &ioService,
                       const std::shared_ptr<boost::asio::io_context::strand> &ioStrand,
                       const std::string &portName,
                       uint32_t baudRate,
                       boost::tuples::tuple<boost::asio::serial_port_base::character_size,
                                            boost::asio::serial_port_base::parity,
                                            boost::asio::serial_port_base::stop_bits> SerialParams);

  ..
}

Is there a more elegant solution to the previous approaches?


text:
Q: How to set ImageView by file name from object data to existing image in Drawable folder? I need to call the filename and set to ImageView but it does not working at all. I knew the code below is totally wrong:
holder.iconFilename.setImageDrawable(subjects.getIconFilename());

How to call it correctly? All the images that need to be call were in Drawable folder.

My full code:
@Override
public void onBindViewHolder(SubjectAdapter.MyViewHolder holder, int position) {
    context = holder.itemView.getContext();
    Subjects subjects = subjectsList.get(position);
    holder.iconFilename.setImageDrawable(subjects.getIconFilename()); // Definitely wrong.
    holder.subjectNameStd.setText(subjects.getSubjectNameStd());
    holder.itemView.setOnClickListener(new View.OnClickListener(){

        @Override
        public void onClick(View v) {
            Intent gotoChapter = new Intent (context,ChapterActivity.class);
            context.startActivity(gotoChapter);
        }
    });
}

A: If you mean that you have images as resources like this: res/drawable/whatever, then you load it into the ImageView like this:
imageView.setImageResource(R.drawable.whatever);

That's a pretty standard text book thing. You are probably missing something else.
For example, your holder.iconFilename look suspicious. Your holder should have a property that's an ImageView, not a file name, e.g. holder.fooImageView.
The other potential problem that you are not explaining is what Subjects is. It should return the resource id, e.g. subjects.getPhotoResourceId(). If you are trying to load your refernences to the drawable resource from a database or other external source, you need to create a mapping from an external constant to the R.drawable.whatever constant.
For example:
if (subjects.getStatusId() == OK_STATUS) {
  holder.statusImageView.setImageResource(R.drawable.ok_icon);
}


text:
Q: New SSD and different OS Last summer, my Lenovo AIO suddenly stopped working; more specifically, I was performing maintenance on it and the next restart gave an error 1962: No Operating System found. Fortunately, this is a well known error among Lenovo brand machines. Unfortunately, there is really no clear answer or consensus on what the solution is. For some people, changing a setting in bios fixed it, for others it was the SATA cable, etc.  I took my hard drive out and attempted to see if it would boot up externally with another company, or at least be recognized. No such luck. I decided to just go ahead and replace the hard drive a 1 TB SSD and ended up with a clean install of Windows 10 (my now-dead HDD was running Windows 8.1). Ironically, the maintenance I had been performing right before it died was a full back up of my system to my Acronis Cloud account. I also have a couple of external hard drive's that have the back up and/or a system image of my now defunct HDD. Although they're not recent the most recent files, really all I'm wanting is pretty much just save the many photos that I have (like most people). My question is, can I attempt to somehow restore that back up to a computer that is now running Win 10?
Or is there someway that I can just get the photo files and possibly some other files I may want to keep? I know for a fact I have a system image copied to an external hard drive, it might be a year old but it would be helpful. How would I go about doing this, if it's possible?  Thanks!


text:
Q: Ignoring some tuples in a loop I am producing some animation frames in tuples, which may contain (0,0) value, which I would like omit while producing frames with moviepy. The xy contains the following in a loop. The first and second iteration contains (0,0) and the rest contains floats. I would like ignore those iteration that possesses (0,0). Can it be done with moviepy's make_frame(t) def? I need some suggestions.
(0, 0)
(0, 0)
(82.5, 82.5)
(82.5, 82.5)
(108.28125, 108.28125)
(108.28125, 108.28125)

I am getting the following errors:
Traceback (most recent call last):
  File "C:\vhosts\VIDEO_TWO_CLONE\vapory-examples-master\scene9.py", line 151, in <module>
    clip = VideoClip(make_frame, duration=5)
  File "C:\Anaconda64\lib\site-packages\moviepy\video\VideoClip.py", line 103, in __init__
    self.size = self.get_frame(0).shape[:2][::-1]
AttributeError: 'NoneType' object has no attribute 'shape'
Process terminated with an exit code of 1

Here is the def of the make_frame(t):
def make_frame(t):

    # PREPARE A DRAWING SURFACE
    surface = gizeh.Surface(width=W, height=H, bg_color=(0,0,0)) # in pixels

    p = PointAnimation((0,0), (110,110), tween=['easeOutElastic', 1, 0.2])

    xy = p.make_frame(t, 0.2, 1, 4, 5)

    if str(xy) == '(0,0)':
        circle = gizeh.circle(r=30, xy=xy, fill=(1,1,0))
        circle.draw(surface) # draw the circle on the surface
        return surface.get_npimage()

clip = VideoClip(make_frame, duration=5)
clip.write_gif("circle.gif", fps=25, fuzz=10)

A: In your code, you have if str(xy) == '(0,0)', when in fact this should be if str(xy) == '(0, 0)' (note the space inside the tuple; this is how tuples are converted to strings in Python). However, an even better way to do this is if xy == (0,0) (the space doesn't matter here because there's no conversion to string).


text:
Q: Delete and Replace within Case statements I am having to do a lot of data validations on several worksheets. One of the common problems I face is shown below. I have 4 columns with a row number over the group.
Example 1
I would like to remove row 2 and 4 as the Visit '1st' takes precedence.
Example 2
I would like to keep row one as is but change rows 2 3 4 to '2nd'. Can anyone suggest a quick and clean way to do this. I have tried using case and replace (using some of the examples on the site) but I am not too happy with the results.
Thanks in Advance
Example 1
Row     ID     Date           Visit
 1       A     2014-04-10     1st
 2       A     2014-04-10     2nd
 3       A     2014-04-17     1st
 4       A     2014-04-17     2nd

Example 2
Row     ID     Date           Visit
 1       A     2014-04-10     1st
 2       A     2014-04-10     1st
 3       A     2014-04-17     1st
 4       A     2014-04-17     1st

A: You are best using the "If" function for this problem.
For example:
   If (select COUNT(*) from table where criteria) > 1
    drop delete from
    where criteria

A: For the first example:
DELETE t FROM [table] t WHERE t.[Visit] = '2nd'

and the second
UPDATE t
   SET [Visit] = CASE [Row] WHEN 1 THEN '1st'
                            ELSE '2nd'
                 END
  FROM [table] t

Or, when you say "row number" are you actually using the ROW_NUMBER function in SQL?


text:
Q: How do you serve "normal" static files alongside SPA static files in ASP.NET? I have an ASP.NET application which serves an Angular frontend using ASP.NET's built-in Microsoft.AspNetCore.SpaServices.
In addition to the SPA frontend, which is served from the appropriate directory, I also want to make available a directory (and the static files contained within) through the browser.
I have tried simply configuring the call to UseStaticFiles (which is called by default in a dotnet new <SPA> invocation) with a FileProvider and a RequestPath. The application has no trouble locating the directory, but when browsing to the path assigned to that directory directly, I get redirected to the SPA at its root.
EDIT: Once I addressed this issue, I was presented with another issue that prevents this question from being completely answered.
Using UseFileServer does not appear to recurse through the directory provided by the PhysicalFileProvider (Yes, the directory structure is correct):

A: The "canonical" way to do this appears to be to call Microsoft.AspNetCore.Builder.UseDefaultFiles1 paired with Microsoft.AspNetCore.Builder.UseStaticFiles2.
As long as these sit before the UseSpaStaticFiles middleware, ASP.NET will check your static files first before serving the SPA application. Example:
var docsFileProvider = new PhysicalFileProvider("doc/site");
app.UseDefaultFiles(new DefaultFilesOptions
{
    FileProvider = docsFileProvider,
    RequestPath = "/docs",

    DefaultFileNames = new[] { "index.html" },
});

app.UseStaticFiles(new StaticFileOptions
{
    FileProvider = docsFileProvider,
    RequestPath = "/docs"
});

var clientAppFileProvider = new PhysicalFileProvider("ClientApp/dist");

if (!env.IsDevelopment())
{
    app.UseSpaStaticFiles(new StaticFileOptions{
        FileProvider = clientAppFileProvider,
    });
}

The problem demonstrated in the edit is caused by the behavior of sending the index of the SPA to the client in the case of a 404. As a result, all the responses for the resources were the SPA's index.html file, leading to the displayed issue.
This can be fixed by properly declaring the RequestPath in both UseDefaultFiles and UseStaticFiles.


text:
Q: How to check array visit may out of bounds using sonarqube? How to check array may out of bounds using sonarqube ? There is nothing about this in existing rules. Custom rule ?
I want to find array visit without index check.
Noncompliant Code Example
String[] spiltResults = chatString.split(ch);
result = spiltResults[0];

Compliant Solution
String[] spiltResults = chatString.split(ch);
if(spiltResults.length > 0){
    result = spiltResults[0];
}

A: You could implement a custom rule in SonarCube that requires there to be an explicit bounds check prior to any array subscripting operation.
However, there are a few problems:

*

*It is relatively easy to test that there is always an explicit check.

*It is harder to test that the check is correct.

*It is very hard to test that the correct action is taken when the index expression would be out of bounds.

*It is very hard to deal with code where the programmer has left out a check that is unnecessary, has hoisted the check out of a loop, or similar.
Here's the rub.  If you can implement a custom rule that does 1) and 2) but not 3) and 4) then the net result will be that you are encouraging programmers to write ugly code with redundant checks to make SonarCube "just shut up".   That is a bad thing, and probably worse for real code quality than not implementing the rule at all.
A better approach is to test thoroughly.  You should be doing this anyway.  (Relying on a code analyser to find your bugs is a bad idea.)
Indeed, you could argue that it is better for the code throw index check exceptions when there are bugs, than to encourage the programmer to add sloppy range checking code that may actually make the real bugs harder to find.

FWIW, SonarCube most likely doesn't have a standard rule for this.  Such a rule would produce too many false positives to be useful for real-world code bases.


text:
Q: Hierachial Tree buiding from flat collection I need to build a tree from hierarchical flat collection separated by dots (.) like namespaces in C# for example. Here are some entry values as a collection (ordered):
A0.A0.A0
A1
A1.A2
A2.A3.A3.A2
A3.A2
A3.A4.A5.A3
A3.A4.A5.A4
B0.B1.B0
B1.B2
B1.B2.B3
B1.B2.B4

This collection looks like namespaces in C#. So let's assume they are namespaces (as you can understand A.A.A.A namespace is really legal).
What I need?
I need a parent-child tree from this collection like this (note, we save some space concatenating some names in one):
A0.A0.A0
A1
   A2
A2.A3.A3.A2
A3
   A2
   A4.A5
      A3
      A4
B0.B1.B0
B1.B2
     B3
     B4

In this case we will have only 6 root objects.
Here is our interface for our algorithm:
    public interface IParentChild
    {
        IEnumerable<IParentChild> Children { get; set; }
        string FullName { get; set; }
        string Name { get; set; }
    }

Any suggestions ?

A: *

*Use a Trie data structure as given in this answer Parsing one terabyte of text and efficiently counting the number of occurrences of each word

*Modify the Trie generation code in #1 to store namespaces

*Walk the Trie and output the contents to the console.
If you need more detail, comment on this and I can quickly code it.


text:
Q: objects as class data members using default constructor with and without initializer list for the following program
#include <iostream>
using namespace std;

class university{
private:
    string uni;
public:
    university(){
        cout<<"default constructor of university is invoked"<<endl;
    }
    university(string u){
        uni =u;
        cout<<"parametrized constructor of university is invoked: "<<uni;
    }
};

class student{
private:
    university u;
public:
    student() {
        u = university("ABC");
    }
};

int main()
{
    student s;

    return 0;
}

the output is:
default constructor of university is invoked
parametrized constructor of university is invoked: ABC

but when changing the the constructor of student class to use initializer list like following:
    student(): u(university("ABC")){

    }

the output is:
parametrized constructor of university is invoked: ABC

My question is:
for the second case, when the compiler runs the line university u in the private section of student class, does it create an object 'u' of class 'university' and allocate a memory address to it, or does the object get created in the initializer list?  if the former, then why didn't it call the default constructor?
for the first case, I have the same question where does the object get created and assigned a memory location.

A: "Allocating memory" and "assigning memory location" has nothing to do with anything here. You are asking about how objects that are members of another class get constructed. Trying to pull in the subject of memory allocation here only confuses things. Advanced C++ techniques allow objects to be repeatedly constructed and destroyed "in the same place" (via placement new and explicit destructor invocations). Actual memory locations, and object constructions/destructions, are completely immaterial. They have nothing to do with each other, and it will be helpful if you simply forget everything about memory locations, and focus only on the topic of object construction and destruction. Having said all of that:
An object constructor is responsible for constructing all members of the object. That's the rule. No exceptions. Full stop.
student(): u(university("ABC")){

This will work, but this also does this in a confusing member. This spells out the following sequence of events: a temporary university object gets constructed, then copy-constructs the actual member of the student class, finally the temporary object gets destroyed. This is unnecessary and only serves to muddy the waters. Using a simpler, modern C++ syntax, this should be:
student(): u{"ABC"}{

This shorter, direct syntax, describes exactly what's going on in a simple, concise manner: the object's constructor constructs all members of this object, namely just one, here. It's called u. u's constructor gets invoked passing to it a character string as a parameter. The university's "parametrized" constructor gets called. A constructor's member initialization section is nothing more than a simple list: here are my class members, and here are the parameters to their respective constructors. Abracadabra: they're constructed.
student() {

If a constructor does not have a member initialization section, or does not list the object's member in the initialization section, the corresponding class members' default constructors get called.
That's it, that's all there is to it: your class *here the class is called student) has members, and the class's constructor explicitly initializes them, the corresponding constructor gets called, for the class members. If any class member is not listed in the initialization section its default constructor gets called, if the class member does not have a default constructor the resulting code is ill-formed and won't compile.

A: Members are not initialized in the body of the constructor. They are initialized before the body of the constructor is executed. When you write:
class student{
private:
    university u;
public:
    student() {
        u = university("ABC");
    }
};

Then u = unisversizy("ABC"); is not initialization. As you are not providing an initializer for the u member it will be initialized by calling its default constructor. Then in the constructor university("ABC") creates another object by calling the other constructor and assigns that to u.
PS: In my opinion the term "parametrized constructor" is a very misleading term. The distinction between "parametrized constructor" and a default constructor that is often made in tutorials is just wrong. A default constructor is a constructor that can be called without parameters, hence the following is a default constructor (and it can be called with parameters):
 struct foo {
      foo(int x = 0) {} // a default constructor
                        // is this a parametrized constructor ?!?
 };

A: Case 1
Here we consider the case where we have:
student() {
        u = university("ABC"); //this is assignment not initialization
    }

When you wrote:
student s;

These are the effects of the above statement:

*

*Default constructor student::student() of class student is called.

*Before entering/executing the body of the default ctor student::student(), the default ctor university::university() of class university is implicitly called. As a result, you get the output:

default constructor of university is invoked

*Now once the body of university::university() is completely executed, execution of the body of default ctor student::student() is resumed.

*While executing the body of student::student() the following statement is encountered:
u = university("ABC");

which is an assignment and not an initialization. Due to the expression univerisity("ABC"), a temporary university object is created using the parameterized constructor of class university and hence you get the output :
parametrized constructor of university is invoked: ABC

*The temporary created in the last step is assigned to the data member u.

Case 2
Here we consider the case where we have:
student(): u(university("ABC")){

    }

When you wrote:
student s;

this is what happens:

*

*Default constructor of class student is called.

*Before entering the body of the default ctor student::student(), the parameterized constructor university::university(std::string)of class university is called because you have the expression university("ABC") and the data member u is initialized. Note that since the parameterized ctor was called you get the output:

default constructor of university is invoked

*Now when the body of the parameterized ctor is completed, execution of the body of default ctor student::student() of class student resumes.

Note
In case 2 of your example, you should change student():u(university("ABC")){} to just:
student(): u("ABC"){

    }


text:
Q: Can't run a command in a batch file while in command prompt it executes Been stuck on this for a while now, I've tried finding the answer on this and similar forums but nothing worked.
I got this command:
 FOR /F "tokens=3 skip=1" %i IN (C:\logoff\query.txt) DO logoff %i /server:192.168.0.231

Where basically it takes number from query.txt file and it loggs off the user from server by his session id number.
It works if I execute command in a command prompt, but I can't seems to get it working on a batch. I've tried doubling the percentage signs, like someone suggested in forums - nothing.
I assume to confirm the command should work on batch it should execute using "Run...", it doesn't though..
Is the problem that the command starts with FOR or what is the case? I give up..

A: The for replaceable parameters (the "variable" containing the current value of the iteration) uses the %x syntax. But inside a batch file, the percent sign needs to be escaped and the syntax is %%x (see for /?).
FOR /F "tokens=3 skip=1" %%i IN (C:\logoff\query.txt) DO logoff %%i /server:192.168.0.231
                         ^^                                     ^^

A: Try this:
for /F "usebackq tokens=3 skip=1 delims=|" %%i in ("C:\logoff\query.txt") do logoff %%i /server:192.168.0.231

I thing you problem is like @MC ND said and you forget to use delims.
in you query.txt must something like this:
1|1|111
2|2|222
3|3|333

output:
logoff 222 /server:192.168.0.231
logoff 333 /server:192.168.0.231


text:
Q: split the set of Eigenvalues I have a question on how to split a set of eigenvalues.
I have a set of $n$ eigenvalues denoted by $\lambda_{m}$ for $=0...n-1$ given as
$$
\lambda_{m}=1 -\dfrac{1}{K}   \left(  \dfrac{\sin(\frac{m \pi}{n}(K+1))}{\sin(\frac{m \pi}{n})} - 1 \right),
$$
where $K$ and $n$ are finite numbers and I assume here that $K <n$ .
I am interested only on examining the eigenvalues $0<\lambda_{m} \ll 1$, how can I represent them? Should I just select $m$ for which the eigenvalues will be small? But I don't know at which $m$ I should stop.
Is it possible to find a general expression for the small eigenvalues without the $m$ inside?

A: There is no general definition of $\lambda_m \ll 1,$ therefore, the $m$ at which to stop is very application specific. However, one way to get a good intuition for the behaviour of small values of $\lambda_m$ is by

*

*Relaxing $\frac{m\pi}{n} \to x.$

*Noting that the small values lie around zero and $\pi.$

*Obtaining the Taylor expansion of the relaxed $\lambda_x$ around these points and approximating the Taylor series to the first few terms.


text:
Q: R foreach with .combine=rbindlist I am using foreach with a .combine = rbindlist. This does not appear to work, although it works fine if I use .combine = rbind.
Just to illustrate using a simple example --
> t2 <- data.table(col1=c(1,2,3))
> foreach (i=1:3, .combine=rbind) %dopar% unique(t2)
   col1
1:    1
2:    2
3:    3
4:    1
5:    2
6:    3
7:    1
8:    2
9:    3

# But using rbindlist gives an error

> foreach (i=1:3, .combine=rbindlist) %dopar% unique(t2)
error calling combine function:
<simpleError in fun(result.1, result.2): unused argument(s) (result.2)>
NULL

Has anyone been able to make this work ?
Thanks in advance.

A: It's basically what you said - rbindlist assumes a list argument, and the error you're getting is the same as this one:
result.1 = data.table(blah = 23)
result.2 = data.table(blah = 34)

rbindlist(result.1, result.2)
#Error in rbindlist(result.1, result.2) : unused argument (result.2)

If you want to utilize rbindlist, the way to do it would be this:
rbindlist(foreach (i = 1:3) %dopar% unique(t2))

or this:
foreach (i=1:3, .combine=function(x,y)rbindlist(list(x,y))) %dopar% unique(t2)

A: Here's a way to both use rbindlist as your .combine function and have .multicombine=TRUE:
foreach (i=1:3,
         .combine=function(...) rbindlist(list(...)),
         .multicombine=TRUE) %dopar% unique(t2)

If you have a decent amount of seperate results to aggregate, this could be quite a bit faster than only combining two-at-a-time.
For a single foreach statement, this produces the same result as letting foreach default .combine to list and wrapping with rbindlist, as in eddi's first solution. I'm not sure which is faster, though I would expect them to be close.
For small, single-foreach jobs I like wrapping with rbindlist, but when chaining several foreach's together with %:% I think the above approach (likely in the first foreach) looks cleaner.


text:
Q: Repeated words dont convert to positions then to its original array when punctuation is involved This code allows the user to input a sentence. It then converts the words into positions. e.g bob is great bob becomes 0,1,2,0 it then converts those positions back into the original array so 0,1,2,0 becomes bob is great bob. However whenever I use punctuation on a sentence with a repeated word like bob is great bob! it prints the positions 0,1,2,0,4 and a syntax error shows saying "list index out of range". I have no idea why this code works fine with punctuation when there are no repeated words and so require help to fix this problem.
import re
sentence=('bob is great bob!')
punctuation=(re.findall(r"[\w'\"]+|[.,!?;:_-]", sentence))
print(punctuation)
positions = [punctuation.index(x) for x in punctuation]
print(positions)
test1=(",".join(str(i) for i in positions))
words=" ".join(sorted(set(punctuation), key=punctuation.index))
print(words)
with open('1.txt', 'w') as f:#this creates the name of the file called task 2 which will contain my data ad allows the computer to locate the fle and add in the data. The 'w' makes the file writable so i can add in my data, without it displaying an error, using f as a variable.
     f.write(str(words))
with open('2.txt', 'w') as f:
     f.write(str(test1))
f.close()
openfile=('1.txt')
openfile = open(openfile, "r")
print ( openfile.read())
openfile=('2.txt')
openfile = open(openfile, "r")
print ( openfile.read())

openfile = open('1.txt', "r")

test=openfile.read()
 #print(test)

blankarray=[]

for i in test.split(" "):
     blankarray.append(i)

#print(blankarray)

openfile.close

openfile = open('2.txt', "r")

test=openfile.read()
 #print(test)

blankarray2=[]

for i in test.split(","):
     blankarray2.append(int(i))

#print(blankarray2)
openfile.close

blankstring=""

for i in range(len(blankarray2)):
     #print(i)
     blankstring=blankstring+blankarray[blankarray2[i]] + " "
print(blankstring)


text:
Q: Facebook login issue in iOS with latest SDK I'm implementing app with face book login. i need to access user "public profile" and as well as "email id" also. Here email id is must. i am able to login but after enter login details it shows review page, in that review page it shows "Edit info you provide" button, here i am facing issue. i have 2 doubts here 1) is it possible to disable "edit info you provide" option (or) 2) is it possible to disable user interaction for email field like public profile. my code is below.
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    [self toggleHiddenState:YES];
    self.lblLoginStatus.text = @"";

    self.loginButton.delegate = self;
    self.loginButton.readPermissions = @[@"public_profile",@"email"];
}
#pragma mark - Private method implementation

-(void)toggleHiddenState:(BOOL)shouldHide{
    self.lblUsername.hidden = shouldHide;
    self.lblEmail.hidden = shouldHide;
    self.profilePicture.hidden = shouldHide;
}

#pragma mark - FBLoginView Delegate method implementation

-(void)loginViewShowingLoggedInUser:(FBLoginView *)loginView{
    self.lblLoginStatus.text = @"You are logged in.";

    [self toggleHiddenState:NO];
}

-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user{
    NSLog(@"%@", user);
    self.profilePicture.profileID = user.id;
    self.lblUsername.text = user.name;
    self.lblEmail.text = [user objectForKey:@"email"];
}

-(void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView{
    self.lblLoginStatus.text = @"You are logged out";

    [self toggleHiddenState:YES];
}

-(void)loginView:(FBLoginView *)loginView handleError:(NSError *)error{
    NSLog(@"%@", [error localizedDescription]);
}

A: As far as I read from the documentation in developers.facebook.com for the first and second doubt the answer is No. The user can revoke permission even after he gave permission initially, it is a security feature added from facebook. What you can do is check what permission is granted to you with:
[FBRequestConnection startWithGraphPath:@"/me/permissions" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
__block NSString *alertText;
__block NSString *alertTitle;
if (!error){
    // Walk the list of permissions looking to see if email has been granted
    NSArray *permissions = (NSArray *)[result data];
    BOOL emailPermission = FALSE;
    for (NSDictionary *perm in permissions) {
        if ([[perm objectForKey:@"permission"] isEqualToString:@"email"] &&
            [[perm objectForKey:@"status"] isEqualToString:@"granted"]) {
            emailPermission = TRUE;
            NSLog(@"email granted.");
            break;
        }
}


text:
Q: Neo4j doesn't work after migrating from Spring 1.4.5 to Spring 1.5.3 (SDN) My application runs well with Spring 1.4.5 and this configuration :
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-neo4j</artifactId>
    </dependency>
    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-ogm-embedded-driver</artifactId>
        <version>2.0.6</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-ogm-bolt-driver</artifactId>
        <version>2.0.6</version>
    </dependency>

I moved to Spring 1.5.3 and I just can't upgrade the driver.
If I leave 2.0.6 release, I get an error:
org.springframework.transaction.CannotCreateTransactionException: Could not open Neo4j Session for transaction; nested exception is
  java.lang.AbstractMethodError: org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver.newTransaction(Lorg/neo4j/ogm/transaction/Transaction$Type;Ljava/lang/String;)Lorg/neo4j/ogm/transaction/Transaction;

If i set the driver release to 2.1.2, I get an error:
java.util.ServiceConfigurationError: org.neo4j.ogm.driver.Driver: Provider org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver could not be instantiated

If I set the driver neo4j-embedded-driver to 2.1.2 and the neo4j-bolt-driver to 2.0.6, it works with mvn test & mvn spring-boot:run but once in Tomcat I get:
org.neo4j.ogm.drivers.bolt.driver.BoltDriver.newTransaction(Lorg/neo4j/ogm/transaction/Transaction$Type;Ljava/lang/String;)Lorg/neo4j/ogm/transaction/Transaction

This is the complete stack of ̀mvn test after setting spring boot to 1.5.3 and ogm to 1.2.1
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.Session]: Factory method 'getSession' threw exception; nested exception is org.neo4j.ogm.exception.ServiceNotFoundException: org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
    at com.sun.proxy.$Proxy84.resolveGraphIdFor(Unknown Source)
    at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.resolveParams(GraphRepositoryQuery.java:90)
    at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:48)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy93.countBlockByState(Unknown Source)
    at com.oakinvest.b2g.Application.initApplication(Application.java:78)
    at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:372)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:111)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
    at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
    at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: org.neo4j.ogm.exception.ServiceNotFoundException: org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver
    at org.neo4j.ogm.service.DriverService.load(DriverService.java:51)
    at org.neo4j.ogm.service.DriverService.load(DriverService.java:63)
    at org.neo4j.ogm.service.Components.loadDriver(Components.java:157)
    at org.neo4j.ogm.service.Components.driver(Components.java:103)
    at org.neo4j.ogm.session.SessionFactory.openSession(SessionFactory.java:81)
    at org.springframework.data.neo4j.config.Neo4jConfiguration.getSession(Neo4jConfiguration.java:56)
    at org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration.getSession(Neo4jDataAutoConfiguration.java:98)
    at org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration$$EnhancerBySpringCGLIB$$4bf6d5e2.CGLIB$getSession$0(<generated>)
    at org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration$$EnhancerBySpringCGLIB$$4bf6d5e2$$FastClassBySpringCGLIB$$5c9c15d1.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
    at org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration$$EnhancerBySpringCGLIB$$4bf6d5e2.getSession(<generated>)
    at sun.reflect.GeneratedMethodAccessor175.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
    at com.sun.proxy.$Proxy84.resolveGraphIdFor(Unknown Source)
    at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.resolveParams(GraphRepositoryQuery.java:90)
    at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:48)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy93.countBlockByState(Unknown Source)
    at com.oakinvest.b2g.Application.initApplication(Application.java:78)
    at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:372)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:111)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
    at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189)
    at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

A: There are several problems I can see in your config:

*

*neo4j-ogm-embedded-driver has scope provided, it should be either compile or runtime depending on your config. This causes the ServiceNotFoundException

*you need to add a dependency to neo4j itself for the embedded driver, e.g.:
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j</artifactId>
    <version>3.1.4</version>
</dependency>

*you use both neo4j-ogm-embedded-driver and neo4j-ogm-bolt-driver - if you really want to use both they must be the same version. It only makes sense to use both if you use embedded for tests and bolt for production.

*follow the upgrade procedure for spring-data-neo4j http://docs.spring.io/spring-data/data-neo4j/docs/current/reference/html/#migration.4-2 for any additional changes