text:
Q: Error throw new Error('Invalid scope ' + scopeName + ' called.') My Error is :-
server\node_modules\sequelize\lib\model.js:1224
      throw new Error('Invalid scope ' + scopeName + ' called.');
      ^

Error: Invalid scope nested called.
    at D:\Coworkee-master_org(V8)\server\node_modules\sequelize\lib\model.js:1224:13
    at Array.forEach (<anonymous>)
    at Model.scope (D:\Coworkee-master_org(V8)\server\node_modules\sequelize\lib\model.js:1182:11)
    at Model.associate (D:\Coworkee-master_org(V8)\server\models\employee.js:191:47)
    at D:\Coworkee-master_org(V8)\server\models\index.js:26:19
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (D:\Coworkee-master_org(V8)\server\models\index.js:24:17)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
    at Object.<anonymous> (D:\Coworkee-master_org(V8)\server\utils\data.js:3:14)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
[nodemon] app crashed - waiting for file changes before starting...

My models are :-
index:-
/**
 * This file collects all the models from the models directory and associates them if needed.
 */
    "use strict";

    var fs = require("fs");
    var path = require("path");
    var Sequelize = require("sequelize");
    var env = process.env.NODE_ENV || "development";
    var config = require(path.join(__dirname, '..', 'utils', 'config')).database;
    var sequelize = new Sequelize(config.database, config.username, config.password, config);
    var db = {};

    fs.readdirSync(__dirname)
      .filter(function(file) {
        return (file.indexOf(".") !== 0) && (file !== "index.js");
      })
      .forEach(function(file) {
        var model = sequelize.import(path.join(__dirname, file));
        db[model.name] = model;
      });

    Object.keys(db).forEach(function(modelName) {
      if ("associate" in db[modelName]) {
        db[modelName].associate(db);
      }
    });

    db.sequelize = sequelize;
    db.Sequelize = Sequelize;

    module.exports = db;

    Employee :
    "use strict";

    var errors = require('../utils/errors');
    var helpers = require('../utils/helpers.js');

    module.exports = function(sequelize, DataTypes) {
        var Model = sequelize.define("Employee", {
            id: {
                type: DataTypes.UUID,
                defaultValue: DataTypes.UUIDV4,
                allowNull: false,
                primaryKey: true,
                validate: {
                    isUUID: 4
                }
            },
            employeeid:{
                type: DataTypes.STRING,
                allowNull: true,
                searchable : true,
                unique : {
                    msg : 'Id already Taken'
                }
            },
            email: {
                type: DataTypes.STRING,
                allowNull: false,
                searchable: true,
                unique: {
                    msg: 'This email is already taken.'
                },
                validate: {
                    isEmail: true
                }
            },
            username: {
                type: DataTypes.STRING,
                allowNull: false,
                unique: {
                    msg: 'This username is already taken.'
                },
                validate: {
                    len: 6
                }
            },
            contactnumber: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            password: {
                type: DataTypes.STRING,
                allowNull: false,
                validate: {
                    notEmpty: true
                }
            },
            firstname: {
                type: DataTypes.STRING,
                allowNull: false,
                searchable: true,
                validate: {
                    notEmpty: true
                }
            },
            lastname: {
                type: DataTypes.STRING,
                allowNull: false,
                searchable: true,
                validate: {
                    notEmpty: true
                }
            },
            title: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            phone: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            extension: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            skype: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            linkedin: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            picture: {
                type: DataTypes.STRING,
                allowNull: true,
                get: function() {
                    return helpers.apiUrl + this.getDataValue('picture');
                }
            },
            birthday: {
                type: DataTypes.DATEONLY,
                allowNull: false,
                validate: {
                    isDate: true
                }
            },
            started: {
                type: DataTypes.DATEONLY,
                allowNull: true,
                validate: {
                    isDate: true
                }
            },
            ended: {
                type: DataTypes.DATEONLY,
                allowNull: true,
                validate: {
                    isDate: true
                }
            },
            dateofjoining: {
                type: DataTypes.DATEONLY,
                allowNull: true,
                validate: {
                    isDate: true
                }
            },
            employeetype: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            addressline1: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            addressline2: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            city: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            state: {
                type: DataTypes.STRING,
                allowNull: true,
                searchable: true
            },
            pincode: {
                type: DataTypes.BIGINT,
                allowNull: true,
                searchable: true
            },
            createdby: {
                type: DataTypes.BIGINT,
                allowNull: true,
                searchable: true
            },
            updatedby: {
                type: DataTypes.BIGINT,
                allowNull: true,
                searchable: true
            }
        }, {
            defaultScope: {
                attributes: {
                    exclude: ['password']
                }
            },

            classMethods: {
                associate: function(models) {
                    Model.belongsTo(models.Department, { as : 'department'});
                    Model.belongsTo(models.Office, { as: 'office' });
                    Model.hasMany(models.Action, { as: 'actions' });
                    Model.addScope('nested', {
                        attributes: {
                            exclude: ['password']
                        },
                        include: [
                           { model: models.Office.scope('nested'), as: 'office' },
                           { model: models.Department.scope('nested'),  as : 'department'}
                        ]
                    }) ;
                },

                lookup: function(identifier) {
                    return this.findOne({
                        where: {
                            $or: [
                                { id: identifier },
                                { username: identifier },
                                { email: identifier }
                            ]
                        }
                    }).then(function(row) {
                        if (!row) {
                            throw errors.generate('Unknown Employee with id/username/email: ' + identifier);
                        }
                        return row;
                    });
                },

                sayHello: function(){
                    console.log('Hello! I am ' , Model.name);
                }
            }
        });

        return Model;
    };

    Department:-

    "use strict";

    module.exports = function(sequelize, DataTypes) {
        var Model = sequelize.define("Department", {
            id: {
                type: DataTypes.UUID,
                defaultValue: DataTypes.UUIDV4,
                allowNull: false,
                primaryKey: true,
                validate: {
                    isUUID: 4
                }
            },
            name: {
                type: DataTypes.STRING,
                allowNull: false,

  searchable: true,
            unique: {
                msg: 'An organization with this name already exists.'
            },
            validate: {
                notEmpty: true
            }
        }
    },{
        //tableName: 'organization',
        classMethods: {
            associate: function(models) {
                Model.hasMany(models.Employee, { as: 'employees' });
                Model.belongsTo(models.Employee, { as: 'manager', constraints: false });

                // http://stackoverflow.com/a/37817966
                Model.addScope('nested', {
                    attributes: {
                        include: [[sequelize.literal('(SELECT COUNT(*) FROM Employees WHERE Employees.department_id = Department.id)'), 'headcount']]
                    },
                    include: [{
                        model: models.Employee,
                        as: 'manager',
                        include: [{
                            model: models.Office,
                            as: 'office'
                        }]
                    }]
                });
            }
        }
    });

    return Model;
};

Office:-

"use strict";

module.exports = function(sequelize, DataTypes) {
    var Model = sequelize.define("Office", {
        id: {
            type: DataTypes.UUID,
            defaultValue: DataTypes.UUIDV4,
            allowNull: false,
            primaryKey: true,
            validate: {
                isUUID: 4
            }
        },
        name: {
            type: DataTypes.STRING,
            allowNull: false,
            searchable: true,
            unique: {
                msg: 'An office with this name already exists.'
            },
            validate: {
                notEmpty: true
            }
        },
        address: {
            type: DataTypes.STRING,
            allowNull: false,
            searchable: true,
            validate: {
                notEmpty: true
            }
        },
        postcode: {
            type: DataTypes.STRING,
            allowNull: true,
            searchable: true
        },
        region: {
            type: DataTypes.STRING,
            allowNull: true,
            searchable: true
        },
        city: {
            type: DataTypes.STRING,
            allowNull: false,
            searchable: true,
            validate: {
                notEmpty: true
            }
        },
        country: {
            type: DataTypes.STRING,
            allowNull: false,
            searchable: true,
            validate: {
                notEmpty: true
            }
        },
        location: {
            type: DataTypes.TEXT,
            allowNull: false,
            get: function () {
                return JSON.parse(this.getDataValue('location'));
            },
            set: function (value) {
                return this.setDataValue('location', JSON.stringify(value));
            }
        }
    }, {
        classMethods: {
            associate: function(models) {
                 Model.hasMany(models.Employee, { as: 'employees' });

                 // http://stackoverflow.com/a/37817966
                 Model.addScope('nested', {
                    attributes: {
                        include: [[sequelize.literal('(SELECT COUNT(*) FROM Employees WHERE Employees.office_id = Office.id)'), 'headcount']]
                    }
                 });
            }
        }
    });

    return Model;
};

Action:_
"use strict";

module.exports = function(sequelize, DataTypes) {
    var Model = sequelize.define("Action", {
        id: {
            type: DataTypes.UUID,
            defaultValue: DataTypes.UUIDV4,
            allowNull: false,
            primaryKey: true,
            validate: {
                isUUID: 4
            }
        },
        type: {
            type: DataTypes.STRING,
            allowNull: false,
            searchable: true,
            validate: {
                notEmpty: true
            }
        },
        subject: {
            type: DataTypes.STRING,
            searchable: true,
            validate: {
                notEmpty: true
            }
        }
    }, {
        classMethods: {
            associate: function(models) {
                Model.belongsTo(models.Employee, { as: 'recipient', constraints: false });
                Model.belongsTo(models.Employee);
                Model.addScope('nested', {
                    include: [{
                        model: models.Employee,
                        as: 'recipient',
                        include: [{
                            model: models.Office,
                            as: 'office'
                        }, {
                            model: models.Department,
                            as: 'department'
                        }]
                    }]
                });
            },

            subject: function(action, recipient) {
                switch (action) {
                case 'phone':
                    var extension = recipient.get('extension');
                    return recipient.get('phone') + (extension? ':' + extension : '');
                case 'profile':
                    return recipient.get('username');
                case 'email':
                case 'linkedin':
                case 'skype':
                    return recipient.get(action);
                default:
                    return null;
                }
            }
        }
    });

    return Model;
};

Can someone please tell me how to resolve this?


text:
Q: How is floating action button created? While using the floating action button provided by android developer, I can't help but to wonder how exactly did they even achieve the floating action button from scratch.
1) I would like to know how exactly was the floating action button was built
2) how is the android able to animate only the plus to become something else?
This might be a repeat of other post but I have checked already and can't seem to find any post asking this same question. If you find one that ask similar question then please let me know.
My post is different from this post: How can I add the new "Floating Action Button" between two widgets/layouts because the post above only explain how to use the android FAB library and does not explain how FAB are created from scratch.

A: FloatingActionButton class mainly extends the VisibilityAwareImageButton which extends the imagebutton . So, from scratch when you start you should start from extending imagebutton. Then when you get VisibilityAwareImageButton you can create your FloatingButton class. Code for VisibilityAwareImageButton is given below
package android.support.design.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageButton;

class VisibilityAwareImageButton extends ImageButton {

private int mUserSetVisibility;

public VisibilityAwareImageButton(Context context) {
    this(context, null);
}

public VisibilityAwareImageButton(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}

public VisibilityAwareImageButton(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mUserSetVisibility = getVisibility();
}

@Override
public void setVisibility(int visibility) {
    internalSetVisibility(visibility, true);
}

final void internalSetVisibility(int visibility, boolean fromUser) {
    super.setVisibility(visibility);
    if (fromUser) {
        mUserSetVisibility = visibility;
    }
}

final int getUserSetVisibility() {
    return mUserSetVisibility;
}
}

How they created the Floating button:
well the source code is available in below link from google
https://android.googlesource.com/platform/frameworks/support/+/master/design/src/android/support/design/widget/FloatingActionButton.java?autodive=0%2F%2F
And the VisibilityAwareImageButton  code is taken from below link
https://github.com/android/platform_frameworks_support/blob/master/design/base/android/support/design/widget/VisibilityAwareImageButton.java

redpajama_set_name: RedPajamaStackExchange


text:
Q: Android - Save Game - Text File My question is, how do I make a save file using a text file. I want to be able to save the game and to load even after the phone has been restarted.
So what I'm asking is how to make a save file using text file.
public class MainActivity extends AppCompatActivity {

ImageButton Button,Button2,Button3,Button4,Button5,Button6,Button7,Button8,Button9,Button10;
long count = 0;
MediaPlayer mp, mp_pilla,mp_slua;
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final TextView textview = (TextView) findViewById(R.id.textView);
    mp = MediaPlayer.create(MainActivity.this, R.raw.nyaaw);
    mp_pilla = MediaPlayer.create(MainActivity.this, R.raw.pillabli);
    mp_slua = MediaPlayer.create(MainActivity.this, R.raw.slua);
    Button = (ImageButton) findViewById(R.id.myButton);
    Button2 = (ImageButton) findViewById(R.id.myButton2);
    Button3 = (ImageButton) findViewById(R.id.myButton3);
    Button4 = (ImageButton) findViewById(R.id.myButton4);
    Button5 = (ImageButton) findViewById(R.id.myButton5);
    Button6 = (ImageButton) findViewById(R.id.myButton6);
    Button7 = (ImageButton) findViewById(R.id.myButton7);
    Button8 = (ImageButton) findViewById(R.id.myButton8);
    Button9 = (ImageButton) findViewById(R.id.myButton9);
    Button10 = (ImageButton) findViewById(R.id.myButton10);

    textview.setText("0");

    ImageButton buttonsak = (ImageButton) findViewById(R.id.myButton);
    ImageButton buttonsak2 = (ImageButton) findViewById(R.id.myButton2);
    ImageButton buttonsak3 = (ImageButton) findViewById(R.id.myButton3);
    ImageButton buttonsak4 = (ImageButton) findViewById(R.id.myButton4);
    ImageButton buttonsak5 = (ImageButton) findViewById(R.id.myButton5);
    ImageButton buttonsak6 = (ImageButton) findViewById(R.id.myButton6);
    ImageButton buttonsak7 = (ImageButton) findViewById(R.id.myButton7);
    ImageButton buttonsak8 = (ImageButton) findViewById(R.id.myButton8);
    ImageButton buttonsak9 = (ImageButton) findViewById(R.id.myButton9);
    ImageButton buttonsak10 = (ImageButton) findViewById(R.id.myButton10);

    View.OnClickListener clicker = new View.OnClickListener() {
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.myButton:
                    count++;
                    mp.start();
                    textview.setText("" + count);
                    break;
                case R.id.myButton2:
                    if (count >= 50) {
                        count += 5;
                        mp_slua.start();
                        textview.setText("" + count);
                    }
                    break;
                case R.id.myButton3:
                    if (count >= 100) {
                        count += 10;
                        mp_pilla.start();
                        textview.setText("" + count);
                    }
                    break;
                case R.id.myButton4:
                    if (count >= 500) {
                        count += 20;
                        mp_slua.start();
                        textview.setText("" + count);
                    }
                    break;
                case R.id.myButton5:
                    if (count >= 2000) {
                        count += 50;
                        mp_slua.start();
                        textview.setText("" + count);
                    }
                    break;
                case R.id.myButton6:
                    if (count >= 5000) {
                        count += 100;
                        mp.start();
                        textview.setText("" + count);
                    }
                    break;
                case R.id.myButton7:
                    if (count >= 10000) {
                        count += 200;
                        mp_slua.start();
                        textview.setText("" + count);
                    }
                    break;
                case R.id.myButton8:
                    if (count >= 30000) {
                        count += 500;
                        mp_pilla.start();
                        textview.setText("" + count);
                    }
                    break;
                case R.id.myButton9:
                    if (count >= 100000) {
                        count += 1000;
                        mp.start();
                        textview.setText("" + count);
                    }
                    break;
                case R.id.myButton10:
                    if (count >= 250000) {
                        count += 2500;
                        mp_pilla.start();
                        textview.setText("" + count);
                    }
                    break;
                default:
                    break;
            }
        }
    };

    buttonsak.setOnClickListener(clicker);
    buttonsak2.setOnClickListener(clicker);
    buttonsak3.setOnClickListener(clicker);
    buttonsak4.setOnClickListener(clicker);
    buttonsak5.setOnClickListener(clicker);
    buttonsak6.setOnClickListener(clicker);
    buttonsak7.setOnClickListener(clicker);
    buttonsak8.setOnClickListener(clicker);
    buttonsak9.setOnClickListener(clicker);
    buttonsak10.setOnClickListener(clicker);
}

A: Use SharePreference to save data like this:
SharedPreferences.Editor editor = getSharedPreferences(SAVE_GAME, MODE_PRIVATE).edit();
editor.putString("game", "saved");
editor.commit();

and get the info like this:
SharedPreferences prefs = getSharedPreferences(SAVE_GAME, MODE_PRIVATE);
String restoredText = prefs.getString("game", null);
if (restoredText != null) {
String name = prefs.getString("game", "state");// "state" is the default value.
}

A: As @Mariano said: SharedPreferences is a good place to save things. The advantage of SharedPreferences is that it doesn't require any additional permissions.
There are other choices though, depending on your needs. You can write to external storage (which requires the WRITE_EXTERNAL) permission and perhaps much more interesting for you is using the service that Google provides for saving game state. There are some nice examples on there for you to follow.


text:
Q: make GCC's ASM label available for tokenization so, let me warn you guys, i don't really know much about how GCC's build process uses the preprocessor. specifically the naming of assembly symbols for the assembler and consequently the linker.
but, from what i gather after the abstract syntax tree has been created by the compiler, the preprocessor is called for the second time by the assembler to create the symbol labels to figure out all the static dependencies and whatnot...
now, this may sound weird, but i need to access the ASM labels and use them in code and stringify them using the same preprocessor (#str), to be specific. i could manually do the labeling using asm. but i need to access the ones internally defined by the build
of course, from the point of view of a programmer compiling in GCC, the preprocessor is only called once at the very start to create a very, very long source file. the asm labeling happens afterwards. so is it even possible to do it by the book within GCC, at least?

A: gcc -c foo.c will give you the obj file. Use objdum -S foo.o to see the asm code.
For Example:
$gcc -c foo.c
$objdump -S foo.o

foo.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <test>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   48 83 ec 10             sub    $0x10,%rsp
   8:   48 89 7d f8             mov    %rdi,-0x8(%rbp)
   c:   48 8b 45 f8             mov    -0x8(%rbp),%rax
  10:   8b 10                   mov    (%rax),%edx
  12:   b8 00 00 00 00          mov    $0x0,%eax
  17:   89 d6                   mov    %edx,%esi
  19:   48 89 c7                mov    %rax,%rdi
  1c:   b8 00 00 00 00          mov    $0x0,%eax
  21:   e8 00 00 00 00          callq  26 <test+0x26>
  26:   c9                      leaveq
  27:   c3                      retq


text:
Q: How to create customized side control bar in OpenLayers? I could create a simple map using OpenLayers. But I want to have a customised side control bar.
The one I created:

The one I want to create:

A: GeoExplorer is written using Ext JS 3.4 and Geo Ext Js Libraries. Try this tutorial from Open Geo. With this tutorial you will create similar app


text:
Q: efficient and accurate approximation of error function I am looking for the numerical approximation of error function, which must be efficient and accurate. Thanks in advance
$$\mathrm{erf}(z)=\frac2{\sqrt\pi}\int_0^z  e^{-t^2} \,\mathrm dt$$

A: The oldest approximations to the error function $\mathrm{erf}$ encountered in existing software come from:
Cecil Hastings, Jr., Approximations for Digital Computers, Princeton, NJ: Princeton University Press 1955, pp. 167-169, pp. 185-187
Hastings gives six minimax approximations designed for absolute error bounds, the most accurate of which bounds the error by $1.5 \times {10}^{-7}$. Four of the approximations were later incorporated into:
Milton Abramowitz & Irene A. Stegun (eds.), Handbook of Mathematical Functions, Washington, D.C.: National Bureau of Standards 1964, sections 7.1.25 - 7.1.28 (online)
The first approximations designed with a relative error bound were published by William J. Cody:
William J. Cody, "Rational Chebyshev approximations for the error function." Mathematics of Computation, Vol. 23, No. 107, July 1969, pp. 631-637
(online)
Cody used these rational minimax approximations as the basis for a Fortran implementation of the error function $\mathrm{erf}$, complementary error function $\mathrm{erfc}$ and the scaled complementary error function $\mathrm{erfcx}$ which he contributed to SPECFUN (online) during the 1980s, and improved until 1990. This work is described in:
William J. Cody, "Performance Evaluation of Programs for the Error and Complementary Error Functions." ACM Transactions on Mathematical Software, Vol. 16, No. 1, March 1990, pp. 29-37
In testing with 500 million random test vectors I found no errors larger than 6.03 ulps in Cody's SPECFUN implementation of $\mathrm{erf}$.
Around the same time Stephen Moshier released the Cephes library (online), which he maintained well into the 2000s. This library is written in C and contains an implementation of $\mathrm{erf}$ that is based on rational approximations as well. The library was documented in:
Stephen Lloyd Baluk Moshier, Methods and Programs for Mathematical Functions, Ellis Horwood Limited, Chichester, 1989
Testing with 500 million random test vectors I found no errors in excess of 2.95 ulps in Moshier's Cephes implementation of $\mathrm{erf}$.
In 1993 Sun Microsystems, Inc released the Freely Distributable Math Library, or FDLIBM, which is based on the work of K. C. Ng. This library, written in C, aimed to provide a faithfully-rounded implementation of $\mathrm{erf}$ (online), based on rational minimax approximations. A faithfully-rounded function has an error bound of 1 ulp or less. The result returned is either the floating-point number closest to the mathematical result, or its immediate neighbor.
Based on my tests with 500 million random test vectors, the FDLIBM implementation falls slightly short of its accuracy goal, in that errors in excess of 1 ulp do occur but no errors larger than 1.01 ulp were observed.
Using modern tools and processor architectures, it is not too hard to create one's own competitive implementation of $\mathrm{erf}$. Rational approximations have largely fallen out of favor because of the high computational cost of division compared with additions and multiplications. Polynomial minimax approximations are desired, and can readily be generated with tools such as Maplesoft's Maple and Wolfram's Mathematica, both of which have dedicated functions for this: the numapprox command in Maple and the MiniMaxApproximation command in Mathematica.
It should be noted that these generate minimax approximations without taking into account that the coefficients will be rounded to target precision, e.g. IEEE-754 double precision. The Sollya tool with its fpminimax command is unique in offering that functionality, it typically generates superior approximations.
To my knowledge, all these tools use variants of the Remez algorithm which may be augmented by additional heuristics. It is quite possible to write one's own implementation of this algorithm, this basically requires a solver for systems of linear equations and an arbitrary-precision library. I use Richard Brent's MP library for the latter, but would not recommended it for new software since the design is outdated.
Looking at the graph of $\mathrm{erf}$ we find that it is symmetric about the origin, so approximations can be restricted to the positive half-plane.
The graph further suggest two basic approximation intervals. For smaller arguments, the function closely follows its tangent through the origin, while for larger arguments it approaches $y = 1$ in the shape of exponential decay. The crossover between the two regions is roughly around $x = 1$. For simplicity, we might choose that as the actual crossover point.
The  series expansion for $\mathrm{erf}$ suggests a polynomial approximation of the form $x p({x}^{2})$ for $x \in [0, 1]$, while a quick numerical check shows that for IEEE-754 double precision, erf(x) == 1.0 holds for $x > 5.921875$, so we can use an approximation $1 - \exp (x q(x))$ for $x \in (1, 5.921875]$; $p$ and $q$ are polynomials. Many software environments offer a function expm1 for computing $\exp(x)-1$ which can be used to achieve a modest improvement in accuracy over a verbatim implementation.
The fused-multiply add operation (FMA) enables the evaluation of the polynomials with improved accuracy, by reducing rounding error and providing protection against subtractive cancellation, as the intermediate product is not rounded. An FMA operation is provided by most modern processor architectures, and is exposed in ISO C/C++ via the standard math function fma(). Use of the Horner scheme is beneficial for the accuracy of polynomial evaluation; for increased performance by means of increased instruction level parallelism on modern processor architectures the use of some form of second-order Horner scheme can be helpful.
Below is exemplary C code for a IEEE-754 double-precision implementation that follows the design guidelines sketched above. The accuracy of this implementation depends somewhat on the accuracy of the exponential functions. With faithfully-rounded implementations of exp() and expm1() I observed no errors in excess of 1.054 ulp using 1 billion random test vectors when USE_EXPM1=0, and no errors in excess of 1.020 ulp when USE_EXPM1=1. With some tweaking, a faithfully-rounded approximation should be possible, as I demonstrated for equivalent single-precision code.
double my_erf (double a)
{
    double r, s, t, u;

    t = fabs (a);
    s = a * a;
    if (t >= 1.0) {
        // max ulp error = 0.97749 (USE_EXPM1 = 1); 1.05364 (USE_EXPM1 = 0)
        r = fma (-5.6271698391213282e-18, t, 4.8565951797366214e-16); // -0x1.9f363ba3b515dp-58, 0x1.17f6b1d68f44bp-51
        u = fma (-1.9912968283386570e-14, t, 5.1614612434698227e-13); // -0x1.66b85b7fbd01ap-46, 0x1.22907eebc22e0p-41
        r = fma (r, s, u);
        u = fma (-9.4934693745934645e-12, t, 1.3183034417605052e-10); // -0x1.4e0591fd97592p-37, 0x1.21e5e2d8544d1p-33
        r = fma (r, s, u);
        u = fma (-1.4354030030292210e-09, t, 1.2558925114413972e-08); // -0x1.8a8f81b7e0e84p-30, 0x1.af85793b93d2fp-27
        r = fma (r, s, u);
        u = fma (-8.9719702096303798e-08, t, 5.2832013824348913e-07); // -0x1.8157db0edbfa8p-24, 0x1.1ba3c453738fdp-21
        r = fma (r, s, u);
        u = fma (-2.5730580226082933e-06, t, 1.0322052949676148e-05); // -0x1.595999b7e922dp-19, 0x1.5a59c27b3b856p-17
        r = fma (r, s, u);
        u = fma (-3.3555264836700767e-05, t, 8.4667486930266041e-05); // -0x1.197b61ee37123p-15, 0x1.631f0597f62b8p-14
        r = fma (r, s, u);
        u = fma (-1.4570926486271945e-04, t, 7.1877160107954648e-05); // -0x1.319310dfb8583p-13, 0x1.2d798353da894p-14
        r = fma (r, s, u);
        u = fma ( 4.9486959714661590e-04, t,-1.6221099717135270e-03); //  0x1.037445e25d3e5p-11,-0x1.a939f51db8c06p-10
        r = fma (r, s, u);
        u = fma ( 1.6425707149019379e-04, t, 1.9148914196620660e-02); //  0x1.5878d80188695p-13, 0x1.39bc5e0e9e09ap-6
        r = fma (r, s, u);
        r = fma (r, t, -1.0277918343487560e-1); // -0x1.a4fbc8f8ff7dap-4
        r = fma (r, t, -6.3661844223699315e-1); // -0x1.45f2da3ae06f8p-1
        r = fma (r, t, -1.2837929411398119e-1); // -0x1.06ebb92d9ffa8p-3
        r = fma (r, t, -t);
#if USE_EXPM1
        r = expm1 (r);
#else // USE_EXPM1
        r = 1.0 - exp (r);
#endif // USE_EXPM1
        r = copysign (r, a);
    } else {
        // max ulp error = 1.01912
        r =            -7.7794684889591997e-10; // -0x1.abae491c44131p-31
        r = fma (r, s,  1.3710980398024347e-8); //  0x1.d71b0f1b10071p-27
        r = fma (r, s, -1.6206313758492398e-7); // -0x1.5c0726f04dbc7p-23
        r = fma (r, s,  1.6447131571278227e-6); //  0x1.b97fd3d9927cap-20
        r = fma (r, s, -1.4924712302009488e-5); // -0x1.f4ca4d6f3e232p-17
        r = fma (r, s,  1.2055293576900605e-4); //  0x1.f9a2baa8fedc2p-14
        r = fma (r, s, -8.5483259293144627e-4); // -0x1.c02db03dd71bbp-11
        r = fma (r, s,  5.2239776061185055e-3); //  0x1.565bccf92b31ep-8
        r = fma (r, s, -2.6866170643111514e-2); // -0x1.b82ce311fa94bp-6
        r = fma (r, s,  1.1283791670944182e-1); //  0x1.ce2f21a040d14p-4
        r = fma (r, s, -3.7612638903183515e-1); // -0x1.812746b0379bcp-2
        r = fma (r, s,  1.2837916709551256e-1); //  0x1.06eba8214db68p-3
        r = fma (r, a, a);
    }
    return r;
}
```

A: "Efficient and accurate" is probably contradictory... Have you tried the one listed in http://en.wikipedia.org/wiki/Error_function#Approximation_with_elementary_functions ?

A: How about this: Computation of the error function erf in arbitrary precision with correct rounding

A: I know its an old post, but others stumbling upon this post might find it helpful. You can try the accurate approximate analytical expression for faster numerical evaluation such as this or answers in this post especially by Ron Gordon.

A: It can be computed by using the complex error function (aka the Faddeeva function):
$$1-{\rm{erf}}(z)=e^{-z^2}w(iz)$$
Matlab and C packages for the Faddeeva function are available in the Matlab Central.

A: In terms of approximation, I think that using
$$\text{erf}(x) \sim \sqrt{1-\exp\Big[
-\frac {4x^2} {\pi} P_{n}(x) \Big]}$$ where $P_n$ is the $[2n,2n]$ Padé approximant built around $x=0$ can be very good. For example
$$P_1(x)=\frac {1+\frac{\left(10-\pi ^2\right) }{5 (\pi -3) \pi }x^2 } {1+\frac{\left(120-60 \pi +7 \pi ^2\right) }{15 (\pi -3) \pi }x^2 }$$ Computing
$$\Phi_n=\int_0^\infty \left(\text{erf}(x)-\sqrt{1-\exp\Big[
-\frac {4x^2} {\pi} P_{n}(x) \Big]}\right) ^2\,dx$$ gives $\Phi_0=3.23\times 10^{-5}$,  $\Phi_1=3.04\times 10^{-8}$, $\Phi_2=1.20\times 10^{-10}$, $\Phi_3=3.97\times 10^{-12}$.


text:
Q: Sum of row Depending on data in sql server I have a table which store Customerid, amount and vouchartype this is a transaction table which store multiple entry for a single customer. vouchartype is 'D' for debit and 'C' for Credit and all amount have positive value. Now I want to sum of Individual customer debit value should be subtract from Credit value.
Please help me

A: Here is one solution. Everything other than 'C' is considered positive. You might need to reverse the sign depending on what you need.
SELECT
Customerid,
sum(case when vouchartype = 'C' THEN -amount ELSE amount END) As AMount
FROM YOurTable
GROUP BY Customerid


text:
Q: Check the number of digits after the decimal part I need to validate a number accordingly to its number of digits after the decimal part.
I am using with success the following code but, I would like to know:

*

*Is there another better way to achieve the same result? Maybe using some native Math functional.

Notes: I am aware of regular expression, but I am looking for a math approach.

    var max = 2; // max number of digits after decimal places
        var value = 10.154;
        var s = value.toString().split('.')
        if (s[1].length > max) {
            alert('invalid');
        } else {
            alert('ok');
        }

A: I believe this is the best way of doing it as there is no built in Javascript function that will achieve what you want.  This solution will work everywhere except in continental Europe where they use a comma(,) delimiter for decimals instead of a period(.)
You could also do this, but it wont work for negative numbers
var value = 10.154;
value = Math.abs(value);
var decimal = value - Math.floor(value)
var length = decimal.toString().length;

A: You may use Python's round() function:
>>> num = 10.542
>>> round(num, 2) == num
False
>>> num = 12.32
>>> round(num, 2) == num
True

Or
>>> num = 12.32
>>> round(num, 2) >= num
True
>>> num = 12.3
>>> round(num, 2) >= num
True
>>> num = 12.324
>>> round(num, 2) >= num
False

A: You can do this:
var value = 10.154;
var length = value.toString().length - (value.toString().indexOf('.') + 1)

A: In the computer, the number has a whole floating point decimal.  So 10.154 is in fact 10.15400000000 (to whatever level of accuracy the language goes).
So if you want to check if it has > max decimal values then you go:
you'll multiply the whole value with 10^x and then modulus 1 it.  If it's not 0 then you have more deceimal values than the max that you set.
So per your example 10.154 (3 decimal points) * 10^2 (your max) = 1015.4
1015.4 % 1 = 0.4 so "invalid"


text:
Q: How can I test that a select has a given value in Cypress? I am very new to Cypress and I want to write a simple test that a select box (drop down) is set to a certain state when the page first loads. I don't want to set it to anything, which the instructions on the website clearly show. I just want to make sure when the page first loads the select box is set to what it should be. I am sure this is easy to do and I am looking over the documentation now. So far I have:
cy.get('#sinkerTypeList')

I can't figure out how to make sure the selected item has the text "All Sinkers Types".
How can I test that a specific value is selected?

A: So not sure if this is the best way to do it, but I got this to work:
it('the selected option should be All Sinker Types', function () {
        cy.get('#sinkerTypeList')
            .find(':selected').contains('All Sinker Types')
})


text:
Q: How does series parallel combination of LEDs affect the temperature rise? I was designing the LED light of 200 W with LED combination of 9 series / 8 parallel, each LED is 6V thus total output voltage is 56V. I am using Meanwell xlg 200 W driver. But this resulted in high temp rise and blinking of LED after some time. Does making an LED combination of 8 series / 9 parallel solve the problem without affecting light output?

A: LEDs are sensitive to temperature rise and will fail quickly if allowed to operate outside their design limits. A high power system like you're building requires cooling to keep that temperature in range. You will need a heatsink and likely forced-air cooling to make that setup work.


text:
Q: how to simulate click on button with javafx I have two Buttons ; toRed and toGreen . When toRed is clicked it switches the Scene to the Scene "Green" and a Timer(using thread) is started. It counts down from 5 to 0  and then switches back to Scene Red . In my Timer class I implemented this so:
public void run() {

    try{
        while(running){
            if (seconds==1 && goBack){

                this.seconds = 6;
                running=false;
                toRed.fire();

            }   ......

but toRed.fire() seems not to work (nothing changes) . How can I simulate a click on the Button in my Timer class, which is in my Main class?


text:
Q: How to initialize a class inheriting from an inner class? How to initialize a class inheriting from an inner class? Why foo1.this() won't compile?
class Foo1 {
    class Inner {
    }
}

class Foo2 extends Foo1.Inner {
    //Foo2(Foo1 foo1) {foo1.this();} //won't compile
    Foo2(Foo1 foo1) {foo1.super();}
}

A: If you declare the Inner class static you can do it else you need an instance of the outer class Foo1.
class Foo1 {
    static class Inner {
    }
}

But your direct questions seems strange:
foo1.this(); //won't compile

What are you trying to do here?
Call a method called "this" it looks like, but hoping to use the no-argument constructor perhaps? Just use this() if so.

A: I'm not sure I understand what foo1.this(); is supposed to do. Perhaps you are trying to call the default constructor of Inner. Since Inner is a not a static class, it does not have a no argument constructor. It only looks that way. In reality, it has a constructor which takes a Foo1 argument containing the reference to its parent object.
The call to foo1.super(), however, will work just fine. It will call the constructor of the new Inner instance with foo1 as implicit parent reference. That is, the new Inner instance will be tied to the given Foo1 instance.
As others have pointed out, you can of cause make your Inner class static, in which case it does not contain an implicit reference to a Foo1 instance. Then you can simply call super(); in your Foo2 constructor.

A: Make your inner class static. There is no instance from which to get a non static class definition


text:
Q: Oracle Invalid Identifier ORA-00904 I keep getting this error trying to run this simple Join.....
SELECT docregitem.reviewdate, docregitem.nclient, client.name
FROM docregitem, client
     INNER JOIN client
      ON docregitem.nclient = client.nclient

ORA-00904: "DOCREGITEM"."NCLIENT": invalid identifier

I can do a select and all the columns are present and correct...

A: I think the query you want is:
SELECT dr.reviewdate, dr.nclient, c.name
FROM docregitem dr INNER JOIN
     client c
     ON dr.nclient = c.nclient;

Your from clause has a comma in it.  This is a lot like a cross join, but it affects the columns.  These are not known in the on clause, which is what is causing the problem.

A: SELECT docregitem.reviewdate, docregitem.nclient, client.name
FROM docregitem
INNER JOIN client
ON docregitem.nclient = client.nclient

you try this one as you used client table twice one with simple join and other with inner join without giving the alias name to the table so the compiler is confused in selecting and comparing column from client table.


text:
Q: Determine accuracy of a given date string Given a date string, parsed with new Date, how can I determine the accuracy?
Examples
Year
let date = new Date('2017')
// Sun Jan 01 2017 00:00:00

Month
let date = new Date('2017-10')
// Sun Oct 01 2017 00:00:00

let date = new Date('oct 2017')
// Sun Oct 01 2017 00:00:00

Day
let date = new Date('2017.3.15')
// Wed Mar 15 2017 00:00:00

let date = new Date('3 15 17')
// Wed Mar 15 2017 00:00:00

I can't just check if the month is january to see if the accuracy is year, as the month may be january, obviously.
new Date('2017').getMonth() // 0
new Date('2017 1').getMonth() // 0

Also, using RegExp is difficult as there is a great variation of formats supported by the Date parser.
Is it possible to determine the accuracy of a date string with the built-in Date (or other built-ins), and if so, how?

Edit: the end goal is to create an array of date parts (i.e. [year, month, day]), and, for example, if the day is omitted in the input, it should be omitted in the output as well.
'2017 2 3' -> [2017, 2, 3]
'2017 4' -> [2017, 4]
'2017' -> [2017]

If the solution to that problem is different from the solution to the problem mentioned above, that would work too, but I don't think there's any solution that wouldn't solve the problem above as well.


text:
Q: Validating XML on XSD with the error line numbers Is there any way to validate an XML file on an XSD schema with the output of the error line numbers?
The XmlReader reader doesn't allow line numbers, it shows only the element name.

A: Since @chris-watts suggested to post my comment again as answer. Here it is.
The document only has line number information if it was loaded with the appropriate flags:
var opts = LoadOptions.PreserveWhitespace
         | LoadOptions.SetLineInfo;
XDocument doc = XDocument.Load(fileStream, opts);

A: See the original MSDN example:
http://msdn.microsoft.com/en-us/library/ms172454.aspx
ValidationEventHandler's ValidationEventArgs argument has Exception.LineNumber:
private void SchemaValidationEventHandler(object sender, ValidationEventArgs e) {
    Console.WriteLine("XML {0}: {1} (Line {2})",
                         e.Severity,
                         e.Message,
                         e.Exception.LineNumber);
}

A: Woah, rather tricky this XSD stuff, I'm also new :)
As it was said before the position information gets lost in the XmlDocument.
I got it finally running using the XmlReader in combination with XmlDocument:
// xmlStream and xsdStream are open streams that
// point to the respective xml and xsd files
public void ReadAndVerify(Stream xmlStream, Stream xsdStream)
{
    // Read the scheme validation and compile it
    XmlSchemaSet schemaSet = new XmlSchemaSet();

    using (XmlReader r = XmlReader.Create(xsdStream))
    {
        schemaSet.Add(XmlSchema.Read(r, null));
    }

    schemaSet.CompilationSettings = new XmlSchemaCompilationSettings();
    schemaSet.Compile();

    // Setup the settings for the reader.
    // This includes the previously compiled schema
    XmlReaderSettings settings = new XmlReaderSettings();
    settings.CloseInput = true;

    // This is the callback method see below
    settings.ValidationEventHandler += ValidationEventHandler;

    settings.ValidationType = ValidationType.Schema;
    settings.Schemas = schemaSet;  // <-- here the schema is set

    // To be honest, this is cut'n'paste. Not sure which flags are really required.
    settings.ValidationFlags =
            XmlSchemaValidationFlags.ReportValidationWarnings |
    XmlSchemaValidationFlags.ProcessIdentityConstraints |
    XmlSchemaValidationFlags.ProcessInlineSchema |
    XmlSchemaValidationFlags.ProcessSchemaLocation;

    // Now the validating reader is created
    using (XmlReader validatingReader = XmlReader.Create(xmlStream, settings))
    {

        // This has to be done BEFORE the validating while loop
        XmlDocument x = new XmlDocument();
        x.Load(validatingReader);

        // This is the validation loop
        while (validatingReader.Read()) ;

        // This is the client code that actually uses the XmlDocument nodes.
        XmlNode node = x[RootNode];
        ReadAllParameters(node);
    }
}

And the ValidationEventHandler:
private void ValidationEventHandler(object sender, ValidationEventArgs e)
{
    // This actually works with this approach
    string text = $"[Line: {e.Exception?.LineNumber}, Column: {e.Exception?.LinePosition}]: {e.Message}";
    switch (e.Severity) {
        case XmlSeverityType.Error:
            Logger.Error(text);
            break;
        case XmlSeverityType.Warning:
            Logger.Warn(e.Message);
            break;
    }
}

Life can be so simple ;-)

A: You can use XMLStarlet. That supports validating, and provides error line numbers:
$ xml val -e --xsd file.xsd file.xml
file.xml:8: Element 'atitle': This element is not expected. Expected is ( title ).
file.xml - invalid

A: Try this working example. IXmlLineInfo gets you the line info.
I am getting all the list of errors here, concatenating the Line number, unique id of that specific record, the element name where the error occurred and adding it to a list.
       //get the input file here - You can replace this to your local file
        var httpRequest = HttpContext.Current.Request;

        if (httpRequest.Files.Count > 0)
        {
            var postedFile = httpRequest.Files[0];

            //sete the xsd schema path
            string xsdPath = HttpContext.Current.Server.MapPath("~/XSD/MyFile.xsd");

            //set the XSD schema here
            var schema = new XmlSchemaSet();
            schema.Add("", xsdPath);
            var Message = "";

            //validate the xml schema here
            XDocument document = XDocument.Load(postedFile.InputStream, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo | LoadOptions.SetBaseUri);
            //create a lists to add the error records
            List<string> lstErrors = new List<string>();
            document.Validate(schema, ValidationEventHandler);

            //validate all the errors
            document.Validate(schema, (sender, args) =>
             {
                 IXmlLineInfo item = sender as IXmlLineInfo;
                 if (item != null && item.HasLineInfo())
                 {
                     //capture all the details needed here seperated by colons
                     Message = item.LineNumber + ";" +
                     (((System.Xml.Linq.XObject)item).Parent.Element("id")).Value + ";" +
                     ((System.Xml.Linq.XElement)item).Name.LocalName + ";" +
                     args.Message + Environment.NewLine;
                     //add the error to a list
                     lstErrors.Add(Message);
                 }
             });
        }

A: This example is the most complete I've found. It's slower than other validation methods, but it's the best for debugging: It writes validated element for each line and errors found.
To have numbers of lines with errors just add this line in ValidationHandler method:
Console.WriteLine(args.Exception.LineNumber);

Pay attention that xsd file is specified in the root tag of the Xml doc.


text:
Q: How do I know that the image shown is cached? I am using timThumb that has a cache engine. As the script/tutorials say, you have to have a cache file with permission 0777. This is what I have already.
When an image is viewed in the page, using the below
timthumb.php?src=http://farm3.static.flickr.com/2340/2089504883_863fb11b0a_z.jpg

it creates a 9c9313eced007f38eb59791dad91edb1.jpg file in the cache folder.
I checked the image and it is the same I saw. On my next refresh, I view the page source and I get again
timthumb.php?src=http://farm3.static.flickr.com/2340/2089504883_863fb11b0a_z.jpg instead of the cached image.
My question is, shouldn't show a domain.com/9c9313eced007f38eb59791dad91edb1.jpg ?
This is the code I use http://codepad.org/pVzET9Dv ( It is a modified version to accept all domains )
Note: I tried it also with the official release, but again the same. Maybe it's how cache works, I don't know.. But if is so, how can I check that what I saw is the cached?

A: You have the wrong idea about the concept of caching here.
Notice that when a file is in the cache_dir, php checks whether the user has sent him the header HTTP_IF_MODIFIED_SINCE.
If the browser sends this header, then this means that the browser has a local copy of this file which has had a Last-Modified value of HTTP_IF_MODIFIED_SINCE when it was downloaded.
Now, if this date is the really the last modification date of the image, the server sends the header HTTP/1.1 304 Not Modified.
Notice the check in function show_cache_file.

One more thing, it seems php is re-sizing the image and saving the re-sized image in its own cache folder. So in this way, the re-sizing process is not repeated again.

I am not aware whether there is a browser that allows you to know if a displayed image is fetched from cache or downloaded. Anyway this is irrelevant since the user must be sure that it is the most recent image.

A: The URL timthumb.php?src=http://farm3.static.flickr.com/2340/2089504883_863fb11b0a_z.jpg
 will not change.  The logic of the script is like this:

I have been given a URL to an image "http://farm3.static.flickr.com/2340/2089504883_863fb11b0a_z.jpg"
Do I have a cached copy on disk that is not expired?
NO: go retrive the image from "http://farm3.static.flickr.com/2340/2089504883_863fb11b0a_z.jpg", write it to cache, then display it.
YES: read the file from the disk and display it.

So even though you are saying the image is here (through the query string parameter src=) "http://farm3.static.flickr.com/2340/2089504883_863fb11b0a_z.jpg" it doesn't mean the script actually retrieves it from there every time.
I would say the fact that your permissions are correct and cache files are being written to the folder, that is verification enough it is working.
Any kind of verification beyond this would be kind of a waste of time.


text:
Q: Example : sequence of functions $u_n$ Looking for a sequence of functions $u_n$ in $U=B(0,1)\subset\mathbb{R}^2$ ($x=(x_1, x_2))$ satisfying $$||u_n||_{L^1(U)}\rightarrow0\quad \mbox{as $n\rightarrow \infty$ and}\quad||D_{x_1}u_n||_{L^1(U)}\geq||u_n||_{L^1(\partial U)}$$for any $n$.
Moreover, $||u_n||_{L^1(\partial U)} \mbox{: constant}>0$
Any suggestions?

A: How about $u_n=x^{n-1}+\frac{2\pi n^2}{\mbox{volume}(B(0,1))}x_1\cdot I_{B(0,1/n)}$ ?


text:
Q: Reshaping a data based one two columns I have a data like this :
df<-structure(list(id = c(13186082L, 13186082L, 15186082L, 15186082L,
32186082L, 32186082L, 24186085L, 24186085L), freq1 = c("socialinteraction2",
"who", "socialinteraction2", "who", "socialinteraction2", "who",
"socialinteraction2", "who"), Response = c("2", "a", "1", "b",
"3", "a", "4", "c")), class = "data.frame", row.names = c(NA,
-8L))

         id              freq1 Response
1 13186082 socialinteraction2        2
2 13186082                who        a
3 15186082 socialinteraction2        1
4 15186082                who        b
5 32186082 socialinteraction2        3
6 32186082                who        a
7 24186085 socialinteraction2        4
8 24186085                who        c

I want to reshape it in a way that selects the "Response" when
freq1="who" and repeat the number of "Response"  when freq1="socialinteraction2" in the way like this:
                 From To
1  socialinteraction2  a
2  socialinteraction2  a
3  socialinteraction2  b
4  socialinteraction2  a
5  socialinteraction2  a
6  socialinteraction2  a
7  socialinteraction2  c
8  socialinteraction2  c
9  socialinteraction2  c
10 socialinteraction2  c

So, for instance, for the first Id, I want to make two columns. For "to" when "freq1" is who selects "a" 2 times and all the "from" values will be "socialinteraction2.

A: Is this what you were looking for:
df<-structure(list(id = c(13186082L, 13186082L, 15186082L, 15186082L, 32186082L, 32186082L, 24186085L, 24186085L),
                   freq1 = c("socialinteraction2", "who", "socialinteraction2", "who", "socialinteraction2", "who",
                                                                                "socialinteraction2", "who"),
                   Response = c("2", "a", "1", "b", "3", "a", "4", "c")), class = "data.frame", row.names = c(NA, -8L))

#separat socialinteraction2 and who into 2 columns
output <-df %>% pivot_wider(names_from= freq1, values_from = Response)

#create the repeating values
repeats <- rep(output$who, times=as.integer(output$socialinteraction2))

data.frame(From=c("socialinteraction2"), To=repeats)


text:
Q: Trying to access C++ functions in dll using python ctypes on windows I have a C++ function that accepts two parameters - void * and unsigned long * and it returns an unsigned long integer.
I tried to access this function after loading the dll and it throws an error saying:

ValueError: Procedure called with not enough arguments (8 bytes
  missing) or wrong calling convention

Below is the python code for the same:
import ctypes

from ctypes import cdll

lib1 = cdll.LoadLibrary("Sample1.dll")

i = ctypes.c_void_p

j = ctypes.c_ulong()

lib1.Funct1.argtypes = [ctypes.c_void_p,ctypes.POINTER(ctypes.c_ulong)]

lib1.Funct1.restype = ctypes.c_ulong

res1 = lib1.Funct1(None,ctypes.byref(j))

print res1

Tried out various examples but did not help much...
Could anyone provide a solution to this above issue?
Thanks
Pavana


text:
Q: Cart update - removes jquery events I am new to woocommerce. I added in quantity-input.php file short html code with "+" and "-" divs near quantity input to increment/decrement quantity of product. Then I added short code in functions.php to handle that in jQuery. That works fine. But the problem is when I click "update cart" button - after successfull refresh those jQuery events for added divs are gone. Not sure why. Not sure how should I add this jQuery code and where to be able to use it each time, even after cart refresh.
Any help appreciate.
BR


text:
Q: Resharper Unit Test Session hides before running tests I am trying to get the R# Unit Test Session window to show when I run unit tests in the solution and stay visible until I change focus or press escape, similar to other VS windows that auto-hide.
What I'm actually seeing is that the window shows until the solution builds then hides before the tests start running.
Is there a setting in VS or R# that I can change to get my desired result?
Options > Environment > Tabs and Windows doesn't have anything relevant. I browsed through all of the options in the ReSharper > Options menus and I couldn't find anything relevant either.

A: This sounds like it might be a bug in ReSharper. I've raised an issue that you can track, vote or comment on: RSRP-451566


text:
Q: Integration test of Neo4j in spring boot fails to rollback the inserted object=nodes I use Spring Boot 1.5.1 and the SDN release of 4.2.0. I am new to spring boot and Neo4j. I wanted to test my repository as a first step.
I used the same Neo4j related context for test as I used for development based on HttpDriver:
@EnableNeo4jRepositories("hu.bookandwalk.repository")
@EnableTransactionManagement
public class MyNeo4jConfig {
    @Bean
    org.neo4j.ogm.config.Configuration configuration(){
        org.neo4j.ogm.config.Configuration config=new org.neo4j.ogm.config.Configuration();
        config.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver").setURI("http://xxx:yyyy@localhost:7474");

        /*autoindex feature based on annotation is false in default*/
        config.autoIndexConfiguration().setAutoIndex("assert");
        return config;
    }

    @Bean
    /*In Spring Data Neo4j 4.2 the name of the bean is important to be sessionFactory*/
    SessionFactory sessionFactory(){
        return new SessionFactory(configuration(), "hu.bookandwalk.domain");
    }

    /*In Spring Data Neo4j 4.2 the name of the bean is important to be transactionManager @link http://graphaware.com/neo4j/2016/09/30/upgrading-to-sdn-42.html*/
    @Bean
    PlatformTransactionManager transactionManager(){
        return new Neo4jTransactionManager(sessionFactory());
    }
}

My test always failed so I started to debug the integration test itself. My test class is the following:
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
@ContextConfiguration(classes={MyNeo4jConfig.class})
public class RepositoryTests {

    @Autowired
    Session session;

    @Autowired
    BnWUserRepository bnwUserRepository;

    @Autowired
    AddressRepository addressRepository;

    @Autowired
    InvoiceDataRepository invoiceDataRepository;

    @Test
    public void ShouldInsertUser(){
        BnwAddress a1=new BnwAddress("Hungary", "Budapest", "1092","Erkel utca 9.");
        BnwAddress a2=new BnwAddress("Hungary", "Budapest", "1092","Ráday utca 9.");
        InvoiceData i1=new InvoiceData("Book and Walk Kft","23345",true,a1);

        BnWUser u=new BnWUser(1l,"Roland","roland.szucs@gmail.com","password",true,true,true);
        u.addAddress(a1);
        u.addAddress(a2);
        u.addInvoiceData(i1);
        bnwUserRepository.save(u);
        assertEquals(bnwUserRepository.findOne("Roland").getUserEmail(),"roland.szucs@gmail.com");

    /*@After
    public void cleaning(){
        session.purgeDatabase();
    }*/

}

When I started to debug the test, it turned out that my @Test annotated method runs as expected but as soon as spring/Neo4j start to rollback the transaction i get the following exception:
org.neo4j.ogm.exception.TransactionManagerException: Transaction is not current for this thread
    at org.neo4j.ogm.session.transaction.DefaultTransactionManager.rollback(DefaultTransactionManager.java:89) ~[neo4j-ogm-core-2.1.1.jar:na]
    at org.neo4j.ogm.transaction.AbstractTransaction.rollback(AbstractTransaction.java:67) ~[neo4j-ogm-api-2.1.1.jar:na]
    at org.neo4j.ogm.drivers.http.transaction.HttpTransaction.rollback(HttpTransaction.java:59) ~[neo4j-ogm-http-driver-2.1.1.jar:na]
    at org.neo4j.ogm.transaction.AbstractTransaction.close(AbstractTransaction.java:141) ~[neo4j-ogm-api-2.1.1.jar:na]
    at org.springframework.data.neo4j.transaction.Neo4jTransactionManager.doCleanupAfterCompletion(Neo4jTransactionManager.java:311) ~[spring-data-neo4j-4.2.0.RELEASE.jar:na]
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:1016) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:883) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:830) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.test.context.transaction.TransactionContext.endTransaction(TransactionContext.java:125) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.test.context.transaction.TransactionalTestExecutionListener.afterTestMethod(TransactionalTestExecutionListener.java:227) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.test.context.TestContextManager.afterTestMethod(TestContextManager.java:319) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:94) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) [.cp/:na]

First, I thought that my @After annotated method throws the exception so I commented it out. I still got the same error.
I set the log level of Neo4j to debug and you can see the relevant debug log items until the exception:
**2017-02-21 12:11:18.941 DEBUG 5604 --- [           main] o.s.d.n.t.Neo4jTransactionManager        : Opened new Session [org.neo4j.ogm.session.Neo4jSession@74cf8b28] for Neo4j OGM transaction**
2017-02-21 12:11:18.941 DEBUG 5604 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: beginTransaction()
2017-02-21 12:11:18.941 DEBUG 5604 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: Neo4jSession identity: org.neo4j.ogm.session.delegates.TransactionsDelegate@1f9d6c7b
2017-02-21 12:11:18.957 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, POST http://neo4j:RollerBlade1@localhost:7474/db/data/transaction
2017-02-21 12:11:18.957 DEBUG 5604 --- [           main] o.n.o.drivers.http.request.HttpRequest   : Thread: 1, request: POST http://neo4j:RollerBlade1@localhost:7474/db/data/transaction HTTP/1.1
2017-02-21 12:11:18.957 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, text: {"commit":"http://localhost:7474/db/data/transaction/7/commit","results":[],"transaction":{"expires":"Tue, 21 Feb 2017 11:12:18 +0000"},"errors":[]}
2017-02-21 12:11:18.957 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, Connection released
2017-02-21 12:11:18.957 DEBUG 5604 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: Transaction, tx id: org.neo4j.ogm.drivers.http.transaction.HttpTransaction@79c5636f
2017-02-21 12:11:18.957 DEBUG 5604 --- [           main] o.s.d.n.t.Neo4jTransactionManager        : Beginning Transaction [org.neo4j.ogm.drivers.http.transaction.HttpTransaction@79c5636f] on Session [org.neo4j.ogm.session.Neo4jSession@74cf8b28]
2017-02-21 12:11:18.957  INFO 5604 --- [           main] o.s.t.c.transaction.TransactionContext   : Began transaction (1) for test context [DefaultTestContext@e720b71 testClass = RepositoryTests, testInstance = hu.bookandwalk.RepositoryTests@718607eb, testMethod = ShouldInsertUser@RepositoryTests, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@1b26f7b2 testClass = RepositoryTests, locations = '{}', classes = '{class hu.bookandwalk.config.MyNeo4jConfig}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.SpringBootTestContextCustomizer@42dafa95, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@59ec2012, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@55d56113], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]]]; transaction manager [org.springframework.data.neo4j.transaction.Neo4jTransactionManager@27f3b6d6]; rollback [true]
2017-02-21 12:11:19.004 DEBUG 5604 --- [           main] o.s.d.n.t.Neo4jTransactionManager        : Found thread-bound Session [org.neo4j.ogm.session.Neo4jSession@74cf8b28] for Neo4j OGM transaction
2017-02-21 12:11:19.004 DEBUG 5604 --- [           main] o.s.d.n.t.Neo4jTransactionManager        : Participating in existing transaction
2017-02-21 12:11:19.004 DEBUG 5604 --- [           main] o.s.d.n.transaction.SessionFactoryUtils  : Registering transaction synchronization for Neo4j Session
2017-02-21 12:11:19.035 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : context initialised with 0 relationships
2017-02-21 12:11:19.051 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : visiting: hu.bookandwalk.domain.BnWUser@3088660d
2017-02-21 12:11:19.051 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : hu.bookandwalk.domain.BnWUser@3088660d has changed
2017-02-21 12:11:19.051 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : mapping references declared by: hu.bookandwalk.domain.BnWUser@3088660d
2017-02-21 12:11:19.051 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : mapping reference type: HAS_INVOICEDATA
2017-02-21 12:11:19.051 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : linking to entity hu.bookandwalk.domain.InvoiceData@238ad8c in one direction
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : visiting: hu.bookandwalk.domain.InvoiceData@238ad8c
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : hu.bookandwalk.domain.InvoiceData@238ad8c has changed
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : mapping references declared by: hu.bookandwalk.domain.InvoiceData@238ad8c
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : mapping reference type: HAS_ADDRESS
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : linking to entity hu.bookandwalk.domain.BnwAddress@377c68c6 in one direction
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : visiting: hu.bookandwalk.domain.BnwAddress@377c68c6
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : hu.bookandwalk.domain.BnwAddress@377c68c6 has changed
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : mapping references declared by: hu.bookandwalk.domain.BnwAddress@377c68c6
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : trying to map relationship between hu.bookandwalk.domain.InvoiceData@238ad8c and hu.bookandwalk.domain.BnwAddress@377c68c6
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : context-new: (-37268876)-[-1062181581:HAS_ADDRESS]->(-930900166)
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : trying to map relationship between hu.bookandwalk.domain.BnWUser@3088660d and hu.bookandwalk.domain.InvoiceData@238ad8c
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : context-new: (-814245389)-[-1219553025:HAS_INVOICEDATA]->(-37268876)
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : mapping reference type: HAS_DELIVERYINFO
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : linking to entity hu.bookandwalk.domain.BnwAddress@377c68c6 in one direction
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : already visited: hu.bookandwalk.domain.BnwAddress@377c68c6
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : trying to map relationship between hu.bookandwalk.domain.BnWUser@3088660d and hu.bookandwalk.domain.BnwAddress@377c68c6
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : context-new: (-814245389)-[-1011104118:HAS_DELIVERYINFO]->(-930900166)
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : linking to entity hu.bookandwalk.domain.BnwAddress@538cd0f2 in one direction
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : visiting: hu.bookandwalk.domain.BnwAddress@538cd0f2
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : hu.bookandwalk.domain.BnwAddress@538cd0f2 has changed
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : mapping references declared by: hu.bookandwalk.domain.BnwAddress@538cd0f2
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : trying to map relationship between hu.bookandwalk.domain.BnWUser@3088660d and hu.bookandwalk.domain.BnwAddress@538cd0f2
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.context.EntityGraphMapper  : context-new: (-814245389)-[-62739928:HAS_DELIVERYINFO]->(-1401737458)
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: beginTransaction()
2017-02-21 12:11:19.066 DEBUG 5604 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: Neo4jSession identity: org.neo4j.ogm.session.delegates.TransactionsDelegate@6f63c44f
2017-02-21 12:11:19.082 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, POST http://neo4j:RollerBlade1@localhost:7474/db/data/transaction
2017-02-21 12:11:19.082 DEBUG 5604 --- [           main] o.n.o.drivers.http.request.HttpRequest   : Thread: 1, request: POST http://neo4j:RollerBlade1@localhost:7474/db/data/transaction HTTP/1.1
2017-02-21 12:11:19.082 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, text: {"commit":"http://localhost:7474/db/data/transaction/8/commit","results":[],"transaction":{"expires":"Tue, 21 Feb 2017 11:12:19 +0000"},"errors":[]}
2017-02-21 12:11:19.082 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, Connection released
2017-02-21 12:11:19.082 DEBUG 5604 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: Transaction, tx id: org.neo4j.ogm.drivers.http.transaction.HttpTransaction@408a247c
2017-02-21 12:11:19.098 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, request url http://localhost:7474/db/data/transaction/8
2017-02-21 12:11:19.098  INFO 5604 --- [           main] o.n.o.drivers.http.request.HttpRequest   : Thread: 1, url: http://localhost:7474/db/data/transaction/8, request: {"statements":[{"statement":"UNWIND {rows} as row MERGE (n:`BnWUser`{userName: row.props.userName}) SET n=row.props RETURN row.nodeRef as ref, ID(n) as id, row.type as type","parameters":{"rows":[{"nodeRef":-814245389,"type":"node","props":{"password":"password","newsletterSubscribed":true,"active":true,"notficationSubscribed":true,"userEmail":"roland.szucs@gmail.com","userName":"Roland","dateAdded":"17-02-21 11:11:19"}}]},"resultDataContents":["row"],"includeStats":false},{"statement":"UNWIND {rows} as row CREATE (n:`InvoiceData`) SET n=row.props RETURN row.nodeRef as ref, ID(n) as id, row.type as type","parameters":{"rows":[{"nodeRef":-37268876,"type":"node","props":{"invoiceName":"Book and Walk Kft","taxNumber":"23345","dateAdded":"17-02-21","euTaxNumber":true}}]},"resultDataContents":["row"],"includeStats":false},{"statement":"UNWIND {rows} as row CREATE (n:`BnwAddress`) SET n=row.props RETURN row.nodeRef as ref, ID(n) as id, row.type as type","parameters":{"rows":[{"nodeRef":-930900166,"type":"node","props":{"country":"Hungary","zipCode":"1092","address":"Erkel utca 9.","city":"Budapest","dateAdded":"17-02-21"}},{"nodeRef":-1401737458,"type":"node","props":{"country":"Hungary","zipCode":"1092","address":"Ráday utca 9.","city":"Budapest","dateAdded":"17-02-21"}}]},"resultDataContents":["row"],"includeStats":false}]}
2017-02-21 12:11:19.098 DEBUG 5604 --- [           main] o.n.o.drivers.http.request.HttpRequest   : Thread: 1, request: POST http://localhost:7474/db/data/transaction/8 HTTP/1.1
2017-02-21 12:11:19.296 DEBUG 5604 --- [           main] o.n.o.d.h.response.AbstractHttpResponse  : Thread 1: Releasing HttpResponse
2017-02-21 12:11:19.298 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : to create: nodeEntity -814245389:0
2017-02-21 12:11:19.298 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : to create: nodeEntity -37268876:1
2017-02-21 12:11:19.298 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : to create: nodeEntity -930900166:2
2017-02-21 12:11:19.298 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : to create: nodeEntity -1401737458:3
2017-02-21 12:11:19.299 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, request url http://localhost:7474/db/data/transaction/8
2017-02-21 12:11:19.300  INFO 5604 --- [           main] o.n.o.drivers.http.request.HttpRequest   : Thread: 1, url: http://localhost:7474/db/data/transaction/8, request: {"statements":[{"statement":"UNWIND {rows} as row MATCH (startNode) WHERE ID(startNode) = row.startNodeId MATCH (endNode) WHERE ID(endNode) = row.endNodeId MERGE (startNode)-[rel:`HAS_INVOICEDATA`]->(endNode) RETURN row.relRef as ref, ID(rel) as id, row.type as type","parameters":{"rows":[{"startNodeId":0,"relRef":-1219553025,"type":"rel","endNodeId":1}]},"resultDataContents":["row"],"includeStats":false},{"statement":"UNWIND {rows} as row MATCH (startNode) WHERE ID(startNode) = row.startNodeId MATCH (endNode) WHERE ID(endNode) = row.endNodeId MERGE (startNode)-[rel:`HAS_ADDRESS`]->(endNode) RETURN row.relRef as ref, ID(rel) as id, row.type as type","parameters":{"rows":[{"startNodeId":1,"relRef":-1062181581,"type":"rel","endNodeId":2}]},"resultDataContents":["row"],"includeStats":false},{"statement":"UNWIND {rows} as row MATCH (startNode) WHERE ID(startNode) = row.startNodeId MATCH (endNode) WHERE ID(endNode) = row.endNodeId MERGE (startNode)-[rel:`HAS_DELIVERYINFO`]->(endNode) RETURN row.relRef as ref, ID(rel) as id, row.type as type","parameters":{"rows":[{"startNodeId":0,"relRef":-1011104118,"type":"rel","endNodeId":2},{"startNodeId":0,"relRef":-62739928,"type":"rel","endNodeId":3}]},"resultDataContents":["row"],"includeStats":false}]}
2017-02-21 12:11:19.300 DEBUG 5604 --- [           main] o.n.o.drivers.http.request.HttpRequest   : Thread: 1, request: POST http://localhost:7474/db/data/transaction/8 HTTP/1.1
2017-02-21 12:11:19.445 DEBUG 5604 --- [           main] o.n.o.d.h.response.AbstractHttpResponse  : Thread 1: Releasing HttpResponse
2017-02-21 12:11:19.445 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : to (maybe) create: relEntity -1219553025:0
2017-02-21 12:11:19.446 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : to (maybe) create: relEntity -1062181581:1
2017-02-21 12:11:19.446 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : to (maybe) create: relEntity -1011104118:2
2017-02-21 12:11:19.446 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : to (maybe) create: relEntity -62739928:3
2017-02-21 12:11:19.446 DEBUG 5604 --- [           main] o.n.o.drivers.http.request.HttpRequest   : Thread: 1, request: POST http://localhost:7474/db/data/transaction/8/commit HTTP/1.1
2017-02-21 12:11:19.469 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, text: {"results":[],"errors":[]}
2017-02-21 12:11:19.469 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, Connection released
2017-02-21 12:11:19.469 DEBUG 5604 --- [           main] org.neo4j.ogm.transaction.Transaction    : Thread 1: Commit transaction extent: 0
2017-02-21 12:11:19.470 DEBUG 5604 --- [           main] org.neo4j.ogm.transaction.Transaction    : Thread 1: Committed
2017-02-21 12:11:19.470 DEBUG 5604 --- [           main] org.neo4j.ogm.transaction.Transaction    : Thread 1: Close transaction extent: 0
2017-02-21 12:11:19.470 DEBUG 5604 --- [           main] org.neo4j.ogm.transaction.Transaction    : Thread 1: Closing transaction
2017-02-21 12:11:19.470 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : creating new node id: -814245389, 0, hu.bookandwalk.domain.BnWUser@3088660d
2017-02-21 12:11:19.472 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Removed object with id 0
2017-02-21 12:11:19.472 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Removed object with id Roland
2017-02-21 12:11:19.472 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Added object to node registry: 0, hu.bookandwalk.domain.BnWUser@3088660d
2017-02-21 12:11:19.473 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Added object to node registry: Roland, hu.bookandwalk.domain.BnWUser@3088660d
2017-02-21 12:11:19.473 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : creating new node id: -37268876, 1, hu.bookandwalk.domain.InvoiceData@238ad8c
2017-02-21 12:11:19.473 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Removed object with id 1
2017-02-21 12:11:19.473 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Added object to node registry: 1, hu.bookandwalk.domain.InvoiceData@238ad8c
2017-02-21 12:11:19.474 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : creating new node id: -930900166, 2, hu.bookandwalk.domain.BnwAddress@377c68c6
2017-02-21 12:11:19.474 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Removed object with id 2
2017-02-21 12:11:19.474 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Added object to node registry: 2, hu.bookandwalk.domain.BnwAddress@377c68c6
2017-02-21 12:11:19.474 DEBUG 5604 --- [           main] o.n.ogm.session.request.RequestExecutor  : creating new node id: -1401737458, 3, hu.bookandwalk.domain.BnwAddress@538cd0f2
2017-02-21 12:11:19.474 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Removed object with id 3
2017-02-21 12:11:19.474 DEBUG 5604 --- [           main] o.n.ogm.context.register.EntityRegister  : Added object to node registry: 3, hu.bookandwalk.domain.BnwAddress@538cd0f2
2017-02-21 12:11:19.479 DEBUG 5604 --- [           main] o.s.d.n.t.Neo4jTransactionManager        : Found thread-bound Session [org.neo4j.ogm.session.Neo4jSession@74cf8b28] for Neo4j OGM transaction
2017-02-21 12:11:19.479 DEBUG 5604 --- [           main] o.s.d.n.t.Neo4jTransactionManager        : Participating in existing transaction
2017-02-21 12:11:19.484 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, No current transaction, using auto-commit
2017-02-21 12:11:19.485 DEBUG 5604 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Thread: 1, request url http://neo4j:RollerBlade1@localhost:7474/db/data/transaction/commit
2017-02-21 12:11:19.488  INFO 5604 --- [           main] o.n.o.drivers.http.request.HttpRequest   : Thread: 1, url: http://neo4j:RollerBlade1@localhost:7474/db/data/transaction/commit, request: {"statements":[{"statement":"MATCH (n) WHERE n.userName = { id } WITH n MATCH p=(n)-[*0..1]-(m) RETURN p","parameters":{"id":"Roland"},"resultDataContents":["graph"],"includeStats":false}]}
2017-02-21 12:11:19.489 DEBUG 5604 --- [           main] o.n.o.drivers.http.request.HttpRequest   : Thread: 1, request: POST http://neo4j:RollerBlade1@localhost:7474/db/data/transaction/commit HTTP/1.1
2017-02-21 12:11:19.525 DEBUG 5604 --- [           main] o.n.o.d.h.response.AbstractHttpResponse  : Thread 1: Releasing HttpResponse
2017-02-21 12:11:19.558 DEBUG 5604 --- [           main] o.s.d.n.t.Neo4jTransactionManager        : Initiating transaction rollback
2017-02-21 12:11:19.559 DEBUG 5604 --- [           main] **o.s.d.n.t.Neo4jTransactionManager        : Rolling back Neo4j transaction [null] on Session [org.neo4j.ogm.session.Neo4jSession@74cf8b28]**
2017-02-21 12:11:19.560 DEBUG 5604 --- [           main] org.neo4j.ogm.transaction.Transaction    : Thread 1: Close transaction extent: 0
2017-02-21 12:11:19.560 DEBUG 5604 --- [           main] org.neo4j.ogm.transaction.Transaction    : Thread 1: Closing transaction
2017-02-21 12:11:19.560 DEBUG 5604 --- [           main] org.neo4j.ogm.transaction.Transaction    : Thread 1: Rollback transaction extent: 0
2017-02-21 12:11:19.566  WARN 5604 --- [           main] o.s.test.context.TestContextManager      : Caught exception while allowing TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener@3e57cd70] to process 'after' execution for test: method [public void hu.bookandwalk.RepositoryTests.ShouldInsertUser()], instance [hu.bookandwalk.RepositoryTests@718607eb], exception [null]

The first log items show that a new session was created for the test transaction. What is strange the when the transaction started to be rolled back pring/neo4j saw the session but the transaction was null. Any idea what I am doing wrong. I have spent two days finding out the issue without success.


text:
Q: CF network error 303 when uploading multiple files with AFNetworking I'm developing an app that allows users to upload their photos to my web server. I've recently added support for uploading multiple files at once: users can select photos from their iPhone album and upload then to the server.
Uploading one file is no problem, however, when I try to upload multiple files, I get the following error:
The operation couldn't be completed (kCFErrorDomainCFNetwork error 303.)

The code I'm using for uploading the files is the following:
// start the uploading for each photo
for(int i = 0; i < photosArray.count; i++)
{
    Photo *currentPhoto = [photosArray objectAtIndex:i];

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"upload", @"command", UIImageJPEGRepresentation(currentPhoto.image,70),@"file", [NSNumber numberWithInt:album.albumId], @"albumId", currentPhoto.title, @"title", currentPhoto.description, @"description", nil];

    [[AFAPI sharedInstance] commandWithParams:params onCompletion:^(NSDictionary *json)
     {
         //completion
         if (![json objectForKey:@"error"])
         {
             // hide the UIProgressView and show the detail label
             UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
             UIProgressView *pv = (UIProgressView *) [cell viewWithTag:4];
             pv.hidden = YES;

             UILabel *detailLabel = (UILabel *) [cell viewWithTag:3];
             detailLabel.text = @"Upload completed";
             detailLabel.hidden = NO;

         }
         else
         {
             //error :(
             NSString* errorMsg = [json objectForKey:@"error"];
             [UIAlertView error:errorMsg];
         }
     }
     onUploadProgress:^(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite)
    {
         // ...
    }];
}

I'm enumerating the photosArray with a for loop and for every photo it finds, it uploads the image (currentPhoto.image). The implementation of the commandWithParams function is:
-(void)commandWithParams:(NSMutableDictionary*)params onCompletion:(JSONResponseBlock)completionBlock onUploadProgress:(void (^)(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))uploadProgressBlock
{
    NSData* uploadFile = nil;
    if ([params objectForKey:@"file"])
    {
        uploadFile = (NSData*)[params objectForKey:@"file"];
        [params removeObjectForKey:@"file"];
    }

NSMutableURLRequest *apiRequest =
[self multipartFormRequestWithMethod:@"POST"
                                path:kAPIPath
                          parameters:params
           constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
               if (uploadFile) {
                   [formData appendPartWithFileData:uploadFile
                                               name:@"file"
                                           fileName:@"photo.jpg"
                                           mimeType:@"image/jpeg"];
               }
           }];

AFJSONRequestOperation* operation = [[AFJSONRequestOperation alloc] initWithRequest: apiRequest];
[operation setUploadProgressBlock:uploadProgressBlock];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    //success!
    completionBlock(responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    //failure :(
    completionBlock([NSDictionary dictionaryWithObject:[error localizedDescription] forKey:@"error"]);
}];

[operation start];
}

Sorry for the long code part but I really can't figure out how to solve this error. I've tried to use a NSOperationQueue but that also gave the same error.
I've searched on internet, and I figured out that error 303 in the CFNetwork means that the HTTP response couldn't be parsed. Could it be that the problem is in the web service? If so, I can also give the php part where I handle the uploaded file :)
Thanks in advance!

A: I think that this was a bug in AFNetworking. I had the exact same issue, but upgrading to the latest version downloaded on August 24, 2012 resolved the problem for me.