text:
Q: CollapsingToolbarLayout flickers with overlapped content Background
I'm trying to do a collapsing toolbar with overlapped content using Android Design Support Library.
Its similar to Google Play Store Movie page where the movie poster slightly overlaps the parallax image in the collapsing toolbar above.
Problem
I've encountered an issue when scrolling up, the movie poster goes behind the parallax image, then redraws itself ontop. Causing an image flicker.
Animated gif of the issue
Code
Below is the layout used and its referenced from Google's SupportDesignDemo.
https://android.googlesource.com/platform/development/+/master/samples/SupportDesignDemos/res/layout/design_appbar_toolbar_parallax_overlap.xml
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/col"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_height="192dp"
        android:layout_width="match_parent"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_app_bar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:layout_scrollInterpolator="@android:anim/decelerate_interpolator"
            app:contentScrim="?attr/colorPrimary">

            <ImageView
                android:id="@+id/app_bar_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/backdrop"
                android:scaleType="centerCrop"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_height="?attr/actionBarSize"
                android:layout_width="match_parent"
                app:layout_collapseMode="pin"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
                                                xmlns:app="http://schemas.android.com/apk/res-auto"
                                                android:layout_width="match_parent"
                                                android:layout_height="match_parent"
                                                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                                                app:behavior_overlapTop="50dp">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="1000dp"
            android:orientation="vertical">

            <ImageView android:layout_width="150dp"
                       android:layout_height="220dp"
                       android:padding="15dp"
                       android:src="@drawable/poster"
                       android:layout_marginLeft="16dp"/>

            <TextView
                android:id="@+id/textview_dialogue"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="16dp"/>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

Notes
Downloaded "API Demos for Android", tried "AppBar/Parallax Overlapping content" demo and it seems to work fine without the flicker issue.

A: Found the answer! It's simple. Adding elevation to the AppBarLayout will fix the flicker.
<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_height="192dp"
    android:layout_width="match_parent"
    app:elevation="1dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">


text:
Q: matching two different dataframes by common elements I have two pandas data frame of the following kind. The first is df1
A B C D <- columns name
1 2 0 0
1 2 0 1
1 2 3 0
4 5 6 2
4 5 1 2
4 5 0 1
2 3 1 0
5 7 8 0

the second is df2
A B C D <- columns name
1 2 0 1
4 5 0 1

I want to create a new dataframe by selecting from df1 all the rows whose entries in columns A,B are in df2. For example, the result should be a df3 in the following way
A B C D <- columns name
1 2 0 0
1 2 0 1
1 2 3 0
4 5 6 2
4 5 1 2
4 5 0 1

How can I do it efficiently in pandas?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Get python progress bars to behave properly in cygwin I'm running anaconda python in cygwin. When I use keras and chainer from a normal command prompt, they both print out progress bars to show the status of a training run and update them in place.
However, in cygwin, I get a new line for each step making the output unreadable. Is there any fix for this?
This might be related to this question that says: "all Cygwin pty-based terminals (mintty, rxvt and xterm) are recognized as pipes by Windows, not as the console".


text:
Q: Jenkins : Sending Build Trend Graph as email Can jenkins send as email , the build trend graphs ?

A: Email-ext Plugin can send HTML e-mails. As the URL of the graph is known (for example, for the test trend graph the URL is: http://[server]/job/[job-name]/test/trend) it can be embedded into your e-mail with <img> tag like this:
<img src="${PROJECT_URL}test/trend" />

A: I beleive ,there is no such plugin for Jenkins to send an email with trend graph of build.
For advance mailing or report , you can try plugin Email-ext


text:
Q: Implementing SetupAPI in C# (WinForms) to read physical screen size I'm trying to read the physical size of my two monitor, for learning purpouses...
I'm doing this because I need to know exactly the distance that the mouse travels along the screen (in centimeters).
I have tried the option of the DPI, but scren always returns 96 DPI (if the scale is 100%, I had read the following)
But this is not real, because of this:
My first monitor has:

By dividing, 600 px / 6,417323 inches we get = 93,4 ... dpi
Aprox, 93,4 DPI.
And my second monitor:

84,6 DPI, 12 less units than the average monitor, I suppose.
So, we can't take this, because this is very unnacurate. And I want to be precise.

I tried by getting the real centimeters (reading this) and using PInvoke for Interop calls.
But as @Andreas Rejbrand has said, this returns a big value (1600 x 900 mm, a screen of 1,6 meters by 90 centimeters, that's not logic, my biggest screen has 52 centimeters by 29 centimeters, dividing 1600/900 returns almost the same as 52 by 30, that is 1,7777 but is this useful for me???)
PD: Asking to the user is not an option because they can lie to me, I don't was such things.

Another option was searching in the WinAPI for solutions, and I had found the following: (I think I will be downvoted for this xD, but I want to explain eveything I done)
Under the last answer I shared I found the following:
https://stackoverflow.com/a/3858175/3286975
This is edited by someone, I click the revisions and the user shared the following:
How to obtain the correct physical size of the monitor?
In a comment we can see the following link:
https://ofekshilon.com/2014/06/19/reading-specific-monitor-dimensions/
Well, we can find the following code:
#include <atlstr.h>
#include <SetupApi.h>
#pragma comment(lib, "setupapi.lib")

#define NAME_SIZE 128

const GUID GUID_CLASS_MONITOR = {0x4d36e96e, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18};

// Assumes hDevRegKey is valid
bool GetMonitorSizeFromEDID(const HKEY hDevRegKey, short& WidthMm, short& HeightMm)
{
    DWORD dwType, AcutalValueNameLength = NAME_SIZE;
    TCHAR valueName[NAME_SIZE];

    BYTE EDIDdata[1024];
    DWORD edidsize=sizeof(EDIDdata);

    for (LONG i = 0, retValue = ERROR_SUCCESS; retValue != ERROR_NO_MORE_ITEMS; ++i)
    {
        retValue = RegEnumValue ( hDevRegKey, i, &valueName[0],
            &AcutalValueNameLength, NULL, &dwType,
            EDIDdata, // buffer
            &edidsize); // buffer size

        if (retValue != ERROR_SUCCESS || 0 != _tcscmp(valueName,_T("EDID")))
            continue;

        WidthMm  = ((EDIDdata[68] & 0xF0) << 4) + EDIDdata[66];
        HeightMm = ((EDIDdata[68] & 0x0F) << 8) + EDIDdata[67];       return true; // valid EDID found    }   return false; // EDID not found } bool GetSizeForDevID(const CString& TargetDevID, short& WidthMm, short& HeightMm) {   HDEVINFO devInfo = SetupDiGetClassDevsEx(       &GUID_CLASS_MONITOR, //class GUID       NULL, //enumerator      NULL, //HWND        DIGCF_PRESENT, // Flags //DIGCF_ALLCLASSES|         NULL, // device info, create a new one.         NULL, // machine name, local machine        NULL);// reserved   if (NULL == devInfo)        return false;   bool bRes = false;  for (ULONG i=0; ERROR_NO_MORE_ITEMS != GetLastError(); ++i)     {       SP_DEVINFO_DATA devInfoData;        memset(&devInfoData,0,sizeof(devInfoData));         devInfoData.cbSize = sizeof(devInfoData);       if (SetupDiEnumDeviceInfo(devInfo,i,&devInfoData))      {           HKEY hDevRegKey = SetupDiOpenDevRegKey(devInfo,&devInfoData,                DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ);          if(!hDevRegKey || (hDevRegKey == INVALID_HANDLE_VALUE))                 continue;           bRes = GetMonitorSizeFromEDID(hDevRegKey, WidthMm, HeightMm);           RegCloseKey(hDevRegKey);        }   }   SetupDiDestroyDeviceInfoList(devInfo);  return bRes; } int _tmain(int argc, _TCHAR* argv[]) {   short WidthMm, HeightMm;    DISPLAY_DEVICE dd;  dd.cb = sizeof(dd);     DWORD dev = 0; // device index  int id = 1; // monitor number, as used by Display Properties > Settings

    CString DeviceID;
    bool bFoundDevice = false;
    while (EnumDisplayDevices(0, dev, &dd, 0) && !bFoundDevice)
    {
        DISPLAY_DEVICE ddMon;
        ZeroMemory(&ddMon, sizeof(ddMon));
        ddMon.cb = sizeof(ddMon);
        DWORD devMon = 0;

        while (EnumDisplayDevices(dd.DeviceName, devMon, &ddMon, 0) && !bFoundDevice)
        {
            if (ddMon.StateFlags & DISPLAY_DEVICE_ACTIVE &&
                !(ddMon.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
            {
                DeviceID.Format (L"%s", ddMon.DeviceID);
                DeviceID = DeviceID.Mid (8, DeviceID.Find (L"\\", 9) - 8);

                bFoundDevice = GetSizeForDevID(DeviceID, WidthMm, HeightMm);
            }
            devMon++;

            ZeroMemory(&ddMon, sizeof(ddMon));
            ddMon.cb = sizeof(ddMon);
        }

        ZeroMemory(&dd, sizeof(dd));
        dd.cb = sizeof(dd);
        dev++;
    }

    return 0;
}

I have been searching in PInvoke this, and examples, but I'm very lost, because I don't know if we can translate it all to C#, or is only a C++ example that can't be translated. I suppose that it can be translated, but I don't know how, I'm very newbie at interoperability calls.
PD: I have found this: http://www.programering.com/a/MDO2YjMwATc.html but I don't know yet which methods I have to use for translating the code into C# and the parameters I have to pass.
So, if any one can teach me how to figure this out, If you want to give some codes for me, that's good, but I think that good explanation is enough. i don't know.
And if there are better options to do this, please, tell me.
Because, my final solution will be applying this (centimeters of screen) to this: https://stackoverflow.com/a/422333/3286975
Also, I'm seeing that DPI are different from PPI, I'm maybe I'm searching for PPI.
Thanks in advance!


text:
Q: Lumen - I'm getting CORS error when trying POST request with some header, but without header everything is ok So my problem is: I Have Lumen server on subdomain api.domain.com
After sending ajax request from domain.com to api.domain.com:
$.ajax({
            url: 'https://api.domain.com/login',
            type: 'post',
            headers: {
                'Authorization': 'someJWTTOKEN'
                'Content-Type': 'application/json'
            },
            data: {},
            dataType: 'json',
            success: function(result) {
                console.log('result');
                console.log(result);
            },
            error: function(error) {
                console.log(error);
            }
        });

Now I get CORS error:

But when I remove Header from ajax request, everything works fine.
This works great:
   $.ajax({
                url: 'https://api.domain.com/login',
                type: 'post',
                headers: {
                },
                data: {},
                dataType: 'json',
                success: function(result) {
                    console.log('result');
                    console.log(result);
                },
                error: function(error) {
                    console.log(error);
                }
            });

A: I had this problem connecting my React app to my Lumen API but solved it by using this PHP Package. In the README they explain how to configure the package with Lumen. Legit took me like 2 minutes.


text:
Q: how to use iap windows phone 8 remove ads? I'm trying to add an IAP to remove ads in my apps, but I can't find a good clear tutorial on how to do it.
I tried the next ones:
http://code.msdn.microsoft.com/wpapps/Free-App-With-Paid-Products-f138d4a8
But that one is just the code without any explanation.
I also tried and followed every step of this one:
http://www.visuallylocated.com/post/2013/07/19/Remove-ads-with-an-in-app-purchase-across-your-entire-app.aspx
My ad is inside a UserControl, since I use multiple pages and just call the UserControl the next way:
<Grid Height="auto" VerticalAlignment="Bottom">
            <local:Advertisement x:Name="advertisement" Width="480" Height="80" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
        </Grid>
And the UserControl code:
`
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
    <Ads:AdControl HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" Height="70" PublisherID="XXXXX"/>
</Grid>

`
Basically what I would like to do is to hide the UserControl if the user buys the app through IAP, but I can't figure out how to do it with those tutorials.

A: If you created your own user control to wrap the ads, you can subscribe to the Loaded event and check the global "AdsRemoved" property. In the loaded event handler, check if ads have been removed. If they have, collapse the control.
public Advertisement()
{
    Loaded += OnLoaded;
}

private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
    if (App.AdsRemoved)
    {
        Visibility = Visibility.Collapsed;
    }
}

If your AdsRemoved property caches the value, you need a way to reset the value when a purchase is made. A quick way is to just add a setter
private static bool? _adsRemoved;
private bool AdsRemoved
{
    get
    {
        if (_adsRemoved == null)
        {
            _adsRemoved =  CurrentApp.LicenseInformation.ProductLicenses["RemoveAdsProductID"].IsActive;
        }
        return _adsRemoved.Value;
    }
    set
    {
        _adsRemoved =  CurrentApp.LicenseInformation.ProductLicenses["RemoveAdsProductID"].IsActive;
    }
}

Then when the purchase is made, call the setter with any value.
App.AdsRemoved = true; // or false. Doesn't matter what the value is

Following my post, this will not remove the ad from the current page (as it is only removed when the control is loaded). But the ads will be removed from all other pages.


text:
Q: Tables whose sole purpose is specify a subset of another table The database I'm designing has an employees table; there can be multiple types of employees, one of which are medical employees. The database needs to also describe a many-to-many relation between medical employees and what competences they have.
Is it okay to create a table medical_employees with only an id column, whose only purpose is to specify which employees are medics? The id column has a foreign key constraint that references the employees table. The code below should make my question clearer:
/* Defines a generic employee */
CREATE TABLE employees (
    id      INT PRIMARY KEY AUTO_INCREMENT,
    name    VARCHAR(100) NOT NULL
);

/* Specifies which employees are medics */
CREATE TABLE medical_employees (
    id INT NOT NULL,
    FOREIGN KEY (id) references employees(id);
);

/* Specifies what competences a medic can have */
CREATE TABLE medical_competences (
    id     INT PRIMARY KEY AUTO_INCREMENT,
    name   VARCHAR(100) NOT NULL
);

/* A many-to-many relation between medical employees and
   their competences. */
CREATE TABLE medical_employees_competences (
    id             INT PRIMARY KEY AUTO_INCREMENT,
    medic_id       INT NOT NULL,
    competence_id  INT NOT NULL,
    FOREIGN KEY (medic_id) REFERENCES medical_employees(id),
    FOREIGN KEY (competence_id) REFERENCES medical_competences(id)
);

A: Why a separate table for that. Why not just create a BIT/Boolean field say IsMedical and set that to TRUE for medical employees in employee table like
/* Defines a generic employee */
CREATE TABLE employees (
    id      INT PRIMARY KEY AUTO_INCREMENT,
    name    VARCHAR(100) NOT NULL,
    IsMedical BIT(1)
);

That way, say if you want to get all medical employees from Employee table; you will just have to do a single filter in WHERE condition saying WHERE IsMedical = true. Whereas, if you go by a separate table then you will have perform a INNER JOIN with medical_employees and employees table which I believe would be more costly and unnecessary.

A: +1 to answer from @Rahul, another alternative is to create an attribute in the employees table. Although I would not use BIT because there are bugs in that data type. Just use BOOLEAN or TINYINT.
But the way you have it, creating a second table, has the following advantage: the medical_employees_competences is implicitly restricted to reference only medical employees. It cannot reference someone unless they're in that table.
Another way to provide that constraint is to make the foreign key in the following way:
CREATE TABLE employees (
    id      INT PRIMARY KEY AUTO_INCREMENT,
    name    VARCHAR(100) NOT NULL
    IsMedical BOOLEAN DEFAULT 0,
    KEY (id, IsMedical)
);

/* A many-to-many relation between medical employees and
   their competences. */
CREATE TABLE medical_employees_competences (
    id             INT PRIMARY KEY AUTO_INCREMENT,
    IsMedical      BOOLEAN DEFAULT 1, /* only put 1 in this column */
    medic_id       INT NOT NULL,
    competence_id  INT NOT NULL,
    FOREIGN KEY (medic_id, IsMedical) REFERENCES medical_employees(id, IsMedical),
    FOREIGN KEY (competence_id) REFERENCES medical_competences(id)
);

Now you can achieve the same constraint, that you can only reference medical employees using the second table.

A: Yes it is ok, it is the straightforward relational idiom and it is what you should do. (You can search on SQL subtypes & supertypes.)
When one has disjoint subtyping, eg other kinds of employees where an employee can only be of one kind, there are SQL idioms for constraining that to be the case as declaratively as possible. This can involve a constant type discriminator column in the supertype describing which sole subtype its id should appear in. (The IDEF1X idiom.) There is also an idiom involving that type discriminator also in subtypes sometime avoidig further non-declarative constraints. For the former see (answer) How to Implement Referential Integrity in Subtypes. (Explaining the former although disparaging the latter.) For the latter see (conference paper) Foreign Superkeys and Constant References.


text:
Q: Где хранится файл Яндекс текущей сессии? И так, в чём проблема, я открыл очень много вкладок и мне понадобилось срочно переустановить Винду, мне нужно найти файл со информацией об открытых вкладках, (т.е текущих открытых вкладок этой сессии) чтобы после переустановки винды загрузить его и они все открылись,
Где искать этот файл ❓
У меня Виндоус 7, сразу говорю что вариант сохранить все вкладки в избранное не подходит, их слишком много, нужен этот файл


text:
Q: Prepared Statement query syntax error Please can anyone tell me why this stored procedure is not working , what am I doing wrong.It keeps giving syntax error.
puserid and plimit are the parameters passed in the procedure.
DECLARE uid BIGINT;
DECLARE rangee TINYINT;
SET @uid    = puserid;
SET @rangee = plimit * 15;

PREPARE STMT FROM
'IF((SELECT count(type) from notificationrecievers nr where
nr.status=0 and nr.recieverid=?) = 0) THEN
select nr.type,n.senderid,n.postid,u.name,nr.status
 from
 user u,notifications n,notificationrecievers nr where
 nr.recieverid=? and u.userid=n.senderid   and
 nr.notificationid=n.notid order by n.notid desc
limit 15 OFFSET ?;
ELSE
select nr.type,n.senderid,n.postid,u.name,nr.status
 from
 user u,notifications n,notificationrecievers nr where
 nr.recieverid=? and u.userid=n.senderid   and nr.status=0 and
 nr.notificationid=n.notid order by n.notid desc;
END IF;';

EXECUTE STMT USING @uid,@uid,@rangee,@uid;

Here's the error that i get.
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF((SELECT count(type) from notificationrecievers nr where nr.status=0 and nr.r' at line 1

A: You can use only DML in prepared statements.
You can do something like this
IF condition THEN
  set @q = 'your query text'
ELSE
  set @q = 'another query'
END IF;

PREPARE stmt FROM @q
EXECUTE stmt using ...
DEALLOCATE PREPARE stmt

You can execute some queries before to evaluate your conditions.
Hope it helps


text:
Q: Android App. Create checkbox from a text field i'm new on java and android programming. What i'm trying to do is to create an app that creates a checkbox after introducing a name in an EditText field. Like creating a todo list or a shopping list.
public class MainActivity extends AppCompatActivity {

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

public void storeProduct(View view) {
    //Input name
    EditText productField = (EditText) findViewById(R.id.product_field);
    String product = productField.getText().toString();
}

public void createCheckBox(String product){
    //Create Checkbox
    CheckBox savedPRoduct = new CheckBox(getApplicationContext());
    savedProduct.setText(producto);
}

This is what I got so far. And I'm not sure if it's correct. I've been loocking documentation and some forums including this one and I managed to create the method storeProduct to save the string from the EditText view. Then I create the method createCheckbox that generates the checbox with the string from the EditText view. What I'm not sure is hoy to create the method that displays the checkbox created.
Any clues and info you could share with me is really appreciated.
Thank you very much.

A: You usually need to add view content in the file located under res/layout/R.layout.activity_main.xml
From there you can add all the view you need in your layout. Here is an example layout from the android documentation.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/to" />
<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/subject" />
<EditText
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:gravity="top"
    android:hint="@string/message" />
<Button
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:text="@string/send" />
</LinearLayout>

You can do it programatically as well but I wont advice you to do so because it is against android good practice.

A: So, with the help of KevDev I managed to come up with this xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context=".MainActivity">

<EditText
    android:id="@+id/product_field"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textCapSentences"
    android:hint="Product"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="storeProduct"
    android:text="Guardar"/>

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="product"
    android:id="@+id/productCheckBox"
    android:visibility="gone"/>
</LinearLayout>

And this java code:
public class MainActivity extends AppCompatActivity {

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

    public void storeProduct(View view) {
        //Input name
        EditText productField = (EditText) findViewById(R.id.product_field);
        String product = productField.getText().toString();

        CheckBox savedProduct = (CheckBox) findViewById(R.id.productCheckBox);
        savedProduct.setText(product);
        savedProduct.setVisibility(View.VISIBLE);
    }

}

It only shows a checkbox once, but i'm working to make a loop to put a series of checkboxes. I'm also looking the recyclerview documentation to introduce it in this code.


text:
Q: Adding repetitive headers using the podofo library Trying to add a text heading to a multi page PDF report created using the pofodo PDF library. Cant seem to find a function for doing this in the API documentation for pofodo. I'm trying to see if there is a function that can add a document wide header (repetitive text heading on each page ).
I can just add text and set to to a different font to make it come off as a heading / header. What I'm trying to see is if there is way of adding a document wide header just with one api call.


text:
Q: Div Previous Siblings is not reducing it's size I have a code where div should increase its size to twice. It's working, but the previous siblings after hover are not increasing their size.
When I hover the first box, the rest of them change their size. When I hover the second box, the bottom boxes size changes but the first box doesn't change its size. I want to target the previous siblings too while hovering the box.

* {
  box-sizing: border-box;
  transition: 0.5s ease all;
}

body {
  margin: 20px;
  font-family: calibri;
}

.box1 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #FF7F50;
  margin: 0 auto 20px auto;
}

.box2 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #6495ED;
  margin: 0 auto 20px auto;
}

.box3 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #FFF8DC;
  margin: 0 auto 20px auto;
}

.box4 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #DC143C;
  margin: 0 auto 20px auto;
}

.box5 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #00FFFF;
  margin: 0 auto 20px auto;
}

.box5 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #00008B;
  margin: 0 auto 20px auto;
}

.box6 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #008B8B;
  margin: 0 auto 20px auto;
}

.box7 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #B8860B;
  margin: 0 auto 20px auto;
}

.box8 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #006400;
  margin: 0 auto 20px auto;
}

.box9 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #B22222;
  margin: 0 auto 20px auto;
}

.box10 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #E9967A;
  margin: 0 auto 20px auto;
}

.box11 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #FF1493;
  margin: 0 auto 20px auto;
}

.box12 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #9400D3;
  margin: 0 auto 20px auto;
}

.box div:hover~* {
  width: 100px;
  height: 100px;
}

A: There is a way to achieve this. The trick is to target the parent div and expand all descendant but force the hovered element to not expand.
But you'll run into a different problem. When the boxes on top expand it pushes the box you are hovering over down and you lose the hover for that particular box. If it was something like a flip effect we would have no problem.
Check out the solution below and you'll know what am talking about. Hopefully you'll be able to figure out something for this. All the best.

* {
  box-sizing: border-box;
  transition: 0.5s ease all;
}

body {
  margin: 20px;
  font-family: calibri;
}

.box {
  width: 100px;
  margin: auto;
  text-align: center;
}

.box1 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #FF7F50;
  margin: 0 auto 20px auto;
}

.box2 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #6495ED;
  margin: 0 auto 20px auto;
}

.box3 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #FFF8DC;
  margin: 0 auto 20px auto;
}

.box4 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #DC143C;
  margin: 0 auto 20px auto;
}

.box5 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #00FFFF;
  margin: 0 auto 20px auto;
}

.box5 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #00008B;
  margin: 0 auto 20px auto;
}

.box6 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #008B8B;
  margin: 0 auto 20px auto;
}

.box7 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #B8860B;
  margin: 0 auto 20px auto;
}

.box8 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #006400;
  margin: 0 auto 20px auto;
}

.box9 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #B22222;
  margin: 0 auto 20px auto;
}

.box10 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #E9967A;
  margin: 0 auto 20px auto;
}

.box11 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #FF1493;
  margin: 0 auto 20px auto;
}

.box12 {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  background: #9400D3;
  margin: 0 auto 20px auto;
}

.box:hover>* {
  width: 100px;
  height: 100px;
}

.box>*:hover {
  width: 50px;
  height: 50px;
  margin-bottom: 20px;
  margin: 0 auto 20px auto;
}


text:
Q: Prove that norm must be complete Let $X$ be a Banach space and $Y$ be a normed space and $A:X\rightarrow Y$ be a linear map. Show that $A$ is bounded $\iff$ norm $\| \cdot \|_A:=\|x\|_A=\|x\|+\|A(x)\|, \:\: x\in X $ is complete.

A: The direction "$\Rightarrow$" should present no problem. (Cauchy in $\Vert\cdot\Vert_A$ implies Cauchy in $\Vert \cdot \Vert$, so there is a $\Vert \cdot \Vert$-limit. Show that this limit is also the $\Vert \cdot \Vert_A$-limit (using boundedness of $A$)).
For the other direction, consider the inclusion
$$
\iota : (X, \Vert \cdot \Vert_A) \rightarrow (X, \Vert\cdot\Vert).
$$
Note that this is a well-defined, linear, continuous, bijective map. By the open mapping theorem, $\iota^{-1}$ is thus bounded (here, we used completeness of $X$ with the usual and with the new norm).
Note that $A' := A : (X, \Vert\cdot\Vert_A) \rightarrow Y$ is bounded (why?), so that $A  = A' \circ \iota^{-1}$ is also bounded.


text:
Q: error: octave_base_value::save_ascii(): wrong type argument 'object' How can I fix to save, write command in octave?
Import_Data
error: octave_base_value::save_ascii(): wrong type argument 'object'
DATASET.TSERIES = csvread('MR_AER_DATASET1.csv');
DATASET.LABEL   = {'DATES','T_PI','T_CI','m_PI','m_CI','APITR','ACITR','PITB','CITB','GOV'};
DATASET.VALUE   = [  1,       2,     3,     4,    5 ,    6 ,     7 ,     8  ,   9 ,    10 ];
DATASET.UNIT    = [  0,       2,     2,     2,    2 ,    2,      2 ,     1  ,   1 ,    1  ];

save ('DATASET', 'DATASET');


text:
Q: How to use the IsEnabled to disable the parts of an Expander, but not the whole thing? I have an expander with a custom template:
<ControlTemplate TargetType="{x:Type Expander}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border Grid.Row="0">
            <DockPanel>
                <ToggleButton DockPanel.Dock="Right" Template="{DynamicResource ExpanderToggle}" />
                <ContentPresenter DockPanel.Dock="Right" ContentSource="Tag" />
                <ContentPresenter DockPanel.Dock="Left" ContentSource="Header">
            </DockPanel>
        </Border>
        <Border Visibility="Collapsed" Grid.Row="1">
            <ScrollViewer IsEnabled="True">
                <ContentPresenter IsEnabled="{TemplateBinding IsEnabled}" />
            </ScrollViewer>
        </Border>
    </Grid>
</ControlTemplate>

Basically, I'm attempting to make it so that if I set the IsEnabled property to false my scrollviewer still can scroll (it stays enabled, but other parts of my control disable). Any way to do that?

A: If Robert's answer doesn't work, you could always create an AttachedProperty called IsContentEnabled and bind your ContentPresenter's IsEnabled to that property.
<Expander local:IsContentEnabled="False" />

<ControlTemplate TargetType="{x:Type Expander}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border Grid.Row="0">
            <DockPanel>
                <ToggleButton DockPanel.Dock="Right" Template="{DynamicResource ExpanderToggle}" />
                <ContentPresenter DockPanel.Dock="Right" ContentSource="Tag" />
                <ContentPresenter DockPanel.Dock="Left" ContentSource="Header">
            </DockPanel>
        </Border>
        <Border Visibility="Collapsed" Grid.Row="1">
            <ScrollViewer>
                <ContentPresenter IsEnabled="{TemplateBinding local:IsContentEnabled}" />
            </ScrollViewer>
        </Border>
    </Grid>
</ControlTemplate>

A: Give your DockPanel a name.  Then use e FindName (see http://joshsmithonwpf.wordpress.com/2007/06/28/how-to-use-findname-with-a-contentcontrol/) to get at that DockPanel at runtime.  Set IsEnabled on it directly rather that on the higher level Expander control.  Do the same for your ContentPresenter if appropriate.


text:
Q: "Quarkus" Unsatisfied dependency for type on project's code when using "spring" compatibility extensions I'm new to Quarkus and I'm validating the migration viability of a quite complex Spring Boot application.
For now, I'm trying to make the first step into Quarkus world, which is to get the application running on Quarkus JVM (non native option) with as little changes as possible.
After dealing with "spring-orm", "spring-jdbc", "spring-web" (client part) and "spring-boot" (autoconfigure and web parts) dependencies not covered by Quarkus spring extensions, now I'm facing Quarkus deployment problems like below:
Unsatisfied dependency for type <APP_BASE_PACKAGE>.api.rulesengine.service.RulesDomainConfiguratorService and qualifiers
Unsatisfied dependency for type <APP_BASE_PACKAGE>.api.rulesengine.service.RulesEngineService and qualifiers
Unsatisfied dependency for type <APP_BASE_PACKAGE>.api.rulesengine.service.RulesEngineStatisticService and qualifiers
Unsatisfied dependency for type org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder and qualifiers
Unsatisfied dependency for type org.springframework.context.ApplicationContext and qualifiers
Unsatisfied dependency for type org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration and qualifiers
Unsatisfied dependency for type org.springframework.web.accept.ContentNegotiationStrategy and qualifiers
Unsatisfied dependency for type javax.persistence.EntityManager and qualifiers
Unsatisfied dependency for type org.springframework.security.config.annotation.ObjectPostProcessor<java.lang.Object> and qualifiers

I focused first on "EntityManager" and owned application code unsatisfied dependencies (leaving "spring-security" and others to deal with after).
The unsatisfied dependency regarding the "EntityManager" could be fixed by addition of "@Entity" annotation to one of the classes used on data retrieval as pointed out by "gsmet" here (this application I'm migrating uses only native queries to data access and therefore no entities were defined).
I was able to solve almost all dependency problems regarding services and repositories implemented on diferent modules of the same project (identified by "<APP_BASE_PACKAGE>" prefix) by the addition of "@ApplicationScoped" (as suggested by @Turing85 here), althought I thought It won't be necessary while using "quarkus-spring-*" compatibility extensions.
But one of the services keeps prompting the error below even with addition of "@ApplicationScoped" annotation:
[ERROR] [1] Unsatisfied dependency for type <APP_BASE_PACKAGE>.rulesengine.client.service.RulesEngineClient and qualifiers [@Default]
[ERROR]     - java member: <APP_BASE_PACKAGE>.api.rulesengine.service.impl.RulesEngineServiceImpl#rulesEngineClient
[ERROR]     - declared on CLASS bean [types=[<APP_BASE_PACKAGE>.api.rulesengine.service.impl.RulesEngineServiceAbstract, <APP_BASE_PACKAGE>.api.rulesengine.service.RulesEngineService, <APP_BASE_PACKAGE>.api.rulesengine.service.impl.RulesEngineServiceImpl, java.lang.Object], qualifiers=[@Named(value = "rulesEngineServiceImpl"), @Default, @Any], target=<APP_BASE_PACKAGE>.api.rulesengine.service.impl.RulesEngineServiceImpl]

Below is possible to see an almost equal scenario where the unsatisfied dependency was solved by addition of "@ApplicationScoped" to "DynamicJmxConfigurationPropertiesImpl".
[ERROR] [2] Unsatisfied dependency for type <APP_BASE_PACKAGE>.api.rulesengine.jmx.DynamicJmxConfigurationProperties and qualifiers [@Default]
[ERROR]     - java member: <APP_BASE_PACKAGE>.api.rulesengine.service.impl.RulesEngineServiceAbstract#dynamicJmxConfigurationProperties
[ERROR]     - declared on CLASS bean [types=[<APP_BASE_PACKAGE>.api.rulesengine.service.impl.RulesEngineServiceAbstract, <APP_BASE_PACKAGE>.api.rulesengine.service.RulesEngineService, <APP_BASE_PACKAGE>.api.rulesengine.service.impl.RulesEngineServiceImpl, java.lang.Object], qualifiers=[@Named(value = "rulesEngineServiceImpl"), @Default, @Any], target=<APP_BASE_PACKAGE>.api.rulesengine.service.impl.RulesEngineServiceImpl]

The only difference I could see between the two scenarios is that "DynamicJmxConfigurationProperties" is autowired to "RulesEngineServiceAbstract" and "RulesEngineClient" is autowired to "RulesEngineServiceImpl" (which extends "RulesEngineServiceAbstract").
I've tried several combinations of CDI annotations added to "RulesEngineClientImpl", "RulesEngineServiceImpl", etc, but nothing seems to solve the dependency.
Can anyone give me a hint about what am I missing here?
Maybe I'll need to create a producer as suggested by the answer of @loicmathieu here?
Thanks and best regards!


text:
Q: Segmentation fault on using memset instead of for loops to initialize int** Here is my code in c++
int** a;
try{
  a = new int*[m];
  for(int i = 0; i<m;i++)
    a[i] = new int[n];
}

...
Right now i am initializing the above using for loops as follows:
for(int i = 0; i<m; i++)
  for(int j = 0; i<n; j++)
      a[i][j] = 0;

I am trying to improve performance and hence thought using memset would be a good idea . So modified my code to use memset instead of for loop as follows:
memset(a, 0, sizeof(a[0][0]) * m * n);

But i get Segmentation fault on executing this . Can anybody help me figure out what I am doing wrong?

A: int** a;

This just gives you a single object. A int** object. It doesn't point anywhere at all. There are no ints to assign to. When you start assigning to the ints as though they exist, you get undefined behaviour.
In addition, the memory layout of an int** pointing to a "2d array" of ints is like so: the int** points at the first element in an array of int*s, and the int*s point at the first elements in an array of ints. This memory is not contiguous because it requires indirection to jump around memory, i.e. it's not a single block of memory. You can't just write to it using memset.
If you just want a fixed compile-time sized 2D array of ints, do:
int a[N][M];

where N and M are constant expressions. This is stored contiguously, but I still don't recommend using memset.
Or use a standard container, such as:
std::array<std::array<int, M>, N> a;

If you need it of dynamic size, try:
std::vector<std::vector<int>> a(M, std::vector<int>(N));

Alternatively, you can stick with your int** and make sure you dynamically allocate the int*s and ints:
int** a = new int*[M];
for (i = 0; i < N; i++) {
  a[i] = new int[N];
}

But this is ugly!

A: int** a;

is just a declaration of a pointer to pointer to int.

"Right now i am initializing the above using for loops"

You are not initializing it in your for loops, you're just trying to assign 0 to the elements that don't exist, which produces an undefined behavior. You need to either dynamically allocate the memory for these elements or yet even better: use std::vector instead:
std::vector< std::vector<int> > a(m, std::vector<int>(n, 0));

"I am trying to improve performance"

Don't do that unless it is necessary. Don't optimize prematurely.

EDIT: After you mentioned that you are facing the performance issues already, here's what you could do: Instead of this two-dimensional C-style array:
int** a = new int*[m];      // m = number of rows
for(int i = 0; i < m; i++)
    a[i] = new int[n];      // n = number of columns

you could use one-dimensional std::vector:
std::vector<int> vec(rows * cols, 0);
...
vec[i * cols + j] = 7;   // equivalent of vec[i][j]

this will have more advantages:

*

*your 2D array will be stored within the continuous block of memory

*this block of memory will be allocated at once, not in many small pieces

*frequent accessing of elements will be faster thanks to spatial locality
(elements that are "near" will be available in cache memory thus your
program will not have to load them from the main memory)

*and you will not be responsible for the memory management
(memory will be cleaned up automatically once the vector object is destructed)

A: With an int ** you won't normally have a single, contiguous block of memory. Assuming you use it correctly, you'll have an array of pointers. Each of those pointers will then have an array allocated for it individually.
That being the case, you can't convert your loops to a single memset (and still get defined behavior).

A: I think problem is with the memory not allocated for actual storage. Variable a is only pointer (in addition not initialized). To what place it points?

A: You said you allocated it like this:
a = new int*[m];
for(int i =0; i<m ;i++) a[i] = new int[n];

Like Jerry Conffin said - This won't give you a single, contiguous block of memory.
Each new array (new int[n]) will be allocated in a possibly totally different location and memset only works on contiguous blocks, so you have to reset each of them "by hand"
Btw - I'm pretty sure you're not going to see any performance improvements from using memset over a loop (memset itself use implemented using a loop I think).


text:
Q: There was an error in the forked prpcess org/apache/commons/io/FileUtils org.apache.maven.surefire.booter.SurefireBooterForkException When I am trying to perform the mvn test command, I got this error. It compile works fine. My code is running well I used to run this via Test-NG suite on Eclipse but getting error when trying to run this via maven on command prompt... Your assistance will be appreciable and thanks in advance.[Please find the screenshot link of the error below:-]
Error_Screenshot

A: I have solved this error by adding the commons-io dependency in pom.xml:-`
<dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>

`


text:
Q: "war-concomitant event" as a adjectival phrase Can I use "war-concomitant" with a hyphen as adjectival phrase?
I am aware that I can say "an event concomitant with war", but I need to use it as"war-concomitant" as in "war-concomitant event" for example

Thus war-concomitant The Four Quartets, I argue, should not be seen
  as  war poetry in relation to the Second World War in the same sense
  that post-war The Waste Land is in relation to Great War.

A: I'm very dubious about saying that The Four Quartets was concomitant with the war. Concomitant implies that there is an inherent, necessary connection between the work and the war; but you appear to be claiming just the opposite, that the fact that the work was composed during the war is merely a historical accident.
I think the word you are looking for is wartime. And some minor points:

*

*Thus implies argument, so postponing and parenthesizing I argue is very odd: you should either lead with I argue (and associate thus with it, if you feel the thus is necessary) or drop it altogether.

*It is usual to drop a leading The in the title to accommodate a necessary determiner before the modifiers.

*The is in the final clause is so remote from its antecedent be seen that the connection is lost; I'd echo, or build a less awkward expression than seen as war poetry in relation to to parallel.

I thus argue that The Four Quartets should not be seen as war poetry in the same sense as The Waste Land: the wartime Four Quartets does not stand in the same relation to the Second World War as the postwar Waste Land does to the Great War.

A: Simply put, yes. I've never seen that particular adjectival phrase before but it's grammatically correct and is easily understood.
For the sake of posterity, here are some references:

*

*http://www.grammar-monster.com/lessons/hyphens_in_compound_adjectives.htm

*http://www.getitwriteonline.com/archive/040201hyphadj.htm

A: "Concomitant" is such an unusual word that I can't really say there are any "normal" ways to use it. Anyone who knows the word will understand what you mean.
That said, it does seem odd to me. I'm guessing you want a hyphenated, adjectival phrase, in order to parallel "post-war"? I can't think of any other phrase that captures the meaning, and I think the majority of writers would simply change the structure. Enforcing that parallel structure makes your sentence seem, well poetic—which may be exactly what you want. And being poetic also lets you get away with all sorts of unusual-but-understandable word choices!


text:
Q: Javascript / JSON alert returning Undefined I am having a problem trying to alert the json data.
Here is the code part:
$.getJSON("http://myurl/api/get_data", function(data){
    var output = '';
    $.each(data, function(index, value){
    alert(data); // returns object
    alert(value.myurl) //Here is the problem - returns undefined
});

Here is the json data it's reading:
{"myurl":"http://somedomain.com/"}

How can I get the alert to return the value?

A: Your JSON text consists of a plain object. There is no array. There is no nested data structure. Get rid of all the each stuff.
$.getJSON("http://myurl/api/get_data", function(data){
    alert(data.myurl);
});

A: You are thinking too complicated. JSON stands for JavaScript Object Notations. It's basically the javascript syntax representation of the object it contains.
The value passed to the success handler of getJSON is already the unpacked object. So you can just do this:
$.getJSON("http://myurl/api/get_data", function(data){
    alert(data.myurl);
});


text:
Q: How to fix 2D animation while player walks? I'm trying to make my character idle, run, jump and fall. I did it, but i have bug with runing animation. While he goes left or right, he doesn't play animation "run", which called by integer "noob" with parameter "2",he plays animation "fall", which "noob" is parameter "4"
I'm using Unity 4.5.x and C# code
using UnityEngine;
using System.Collections;

public class movement : MonoBehaviour {

Rigidbody2D rb;
Animator anim;
public int jumpCount = 0;
public Camera main;
float jumpTimer = 0;

void Start () {
    rb = GetComponent<Rigidbody2D> ();
    anim = GetComponent<Animator>();
}

void Update () {
    if (Input.GetKeyDown (KeyCode.X) && jumpCount < 2 && jumpTimer == 0) {
        jump ();
        jumpCount += 1;
        jumpTimer = 1;
        StartCoroutine("jumpTime");
    }
    if (rb.velocity.y > 0) {
        Flip();
        anim.SetInteger ("noob", 3);
    }
    if (rb.velocity.y < 0) {
        Flip();
        anim.SetInteger ("noob", 4);
    }
    if (Input.GetAxis ("Horizontal") == 0 && rb.velocity.y == 0) {
        anim.SetInteger ("noob", 1);
    }
    if (rb.velocity.y == 0 && Input.GetAxis ("Horizontal") != 0) {
        Flip();
        anim.SetInteger("noob", 2);
    }
    if (rb.velocity.y == 0) {
        jumpCount = 0;
    }
}

void FixedUpdate(){
    rb.velocity = new Vector2 (Input.GetAxis ("Horizontal") * 12f, rb.velocity.y);
}

void jump(){
    rb.AddForce (transform.up * 14F, ForceMode2D.Impulse);
}
void Flip() {
    if (Input.GetAxis ("Horizontal") > 0) {
        transform.localRotation = Quaternion.Euler (0, 0, 0);
    }
    if (Input.GetAxis ("Horizontal") < 0) {
        transform.localRotation = Quaternion.Euler (0, 180, 0);
    }
}
IEnumerator jumpTime() {
    yield return new WaitForSeconds (0.4f);
    jumpTimer = 0;
}
}

I tried to do something with jumCount, jumpTimer and velocity.y, but nothing helped

A: I would suggested making a grounded and jumping bool, you can use this bool to determine whether your character is airbourne. Also using else if conditional statements may help here to avoid setting your value more than once. Then you can do something like this:
if (grounded && jumping) {
    Flip();
    anim.SetInteger ("noob", 3);
    jumping = false;
}
else if (!grounded) {
    Flip();
    anim.SetInteger ("noob", 4);
}
else if (Input.GetAxis ("Horizontal") == 0 && grounded) {
    anim.SetInteger ("noob", 1);
}
else if (grounded && Input.GetAxis ("Horizontal") != 0) {
    Flip();
    anim.SetInteger("noob", 2);
}


text:
Q: jquery plugin doesn't work? the jquery function ".textAnim" does nothing
textTyping_animation(); Works fine, but .textAnim doesn't work.
Here is the plugin code:
function textTyping_animation(text,location,speed){
var progress = 0;
var a = setInterval(function(){
    progress++;
    document.getElementById(location).innerHTML = text.substring(0,progress);
    if(progress == text.length){
        clearInterval(a);
    }
},speed);
};
(function($){
$.fn.textAnim = function(text,speed){
    var progress = 0;
    var a = setInterval(function(){
        progress++;
        $(this).html(text.substring(0,progress));
        if(progress == text.length){
            clearInterval(a);
        }
    },speed);
};
})(jQuery);

Here is the execution:
$(document).ready(function(){
starttext = function()
{
    document.getElementById("textbox").style.display = "block";
    //textTyping_animation("Dit is een dummy text!","textbox_inner",70);
        $("#textbox_inner").textAnim("Dit is een dummy text!",70);
}
});

Html load code:
<script type="text/javascript" language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
<script type="text/javascript" language="javascript" src="js/jqueryplugins.js" ></script>
<script type="text/javascript" language="javascript" src="js/libraries/gamelibrary.js"></script>

A: The problem is that this inside the callback function passed to setInterval() is the window, not the element you want it to be. Modify your code to save a reference to this inside the textAnim() function (which does refer to the correct element), then use that inside the callback passed to setInterval():
(function($){
    $.fn.textAnim = function(text,speed){
        var progress = 0,
            element = this; // this will be the element in the jQuery object
        var a = setInterval(function(){
            progress++;
            $(element).html(text.substring(0,progress));
            if(progress == text.length){
                clearInterval(a);
            }
        },speed);
    };
})(jQuery);

Here's an updated DEMO.

A: change
$(document).ready(function(){
starttext = function()
{
    document.getElementById("textbox").style.display = "block";
    //textTyping_animation("Dit is een dummy text!","textbox_inner",70);
        $("#textbox_inner").textAnim("Dit is een dummy text!",70);
}
});

to be
$(document).ready(function(){
starttext = function()
{
    document.getElementById("textbox").style.display = "block";
    //textTyping_animation("Dit is een dummy text!","textbox_inner",70);
        $("#textbox_inner").textAnim("Dit is een dummy text!",70);
}
starttext();
});

and it should work;


text:
Q: I want to only accept the A to Z in my textfield . And do not accept the numbers in swift 5 i created a username textfield and  i want my textfield do not accept the numbers in swift 5
i tried this bud didnt work
func OnlyCharacter(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
 let allowedcharacters = CharacterSet.decimalDigits
 let characterset = CharacterSet(charactersIn: string)
 return allowedcharacters.isSuperset(of: characterset)

 }

A: You have to change only CharacterSet.decimalDigits to NSCharacterSet.letterCharacterSet()
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
    if string.rangeOfCharacter(from: .letters) != nil {
        return true
    } else {
        return false
    }
}

A: func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
    let non_digits = NSCharacterSet.letters.inverted
    let range = string.rangeOfCharacter(from: non_digits)
    if range != nil { // found an invalid
        return false
    }
    return true
}

A:  func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
      let characterSet = CharacterSet.letters //accept letters only here
      if string.rangeOfCharacter(from:characterSet.inverted) != nil {
      return false
    }
    return true
 }


text:
Q: How to iterate over scatter data? I am trying to plot a time series on a scatterplot with dropdown boxes using Plotly express. I have 2 traces filtered on some unique values in the "name" column of my data. I'm using the 'color' function on px.scatter to filter by this column. Since the traces have the same name, they are duplicated on the plot and I can't tell which trace belongs to which 'color'.
I would like to change the names of each according to the color. I am trying to loop over fig.data, as I was able to store my values in a list labels (see below) but have not been successful in looping over names of the traces since it is of type scatter.
Earlier, I was able to hardcode it in the following way, however, I need it to be dynamic:
fig.data[0]['name'] = "color1 var1"
fig.data[1]['name'] = "color2 var1"
fig.data[2]['name'] = "color1 var2"
fig.data[3]['name'] = "color2 var2"

To make it dynamic I tried this and was able to update the values, but each of them updated to the last value in my list. I would like to update each value in the order of the list. Not sure how to do this.
labels = df['name'].unique().tolist()
for i in range(len(labels)):
    x = labels[i]+" Color2"
    labels.append(x)

for n in fig.data:
    for i in n:
        for q in range(len(labels)):
            if i == 'name':
                n[i] = labels[q]

Here is the code I used for the dropdown plot (data is a time series):
def tsplot(title,df):
# Create figure with secondary y-axis
    fig = make_subplots(specs=[[{"secondary_y": True}]])
    labels = df['name'].unique().tolist() #for var1

    for i in range(len(labels)):
        x = labels[i]+" for var2"
        labels.append(x)

    # Add traces
    trace1 = px.scatter(df, x="day", y="campaign_cpc", color="display_env_name", hover_name="display_env_name",
                       color_discrete_sequence=px.colors.qualitative.Set3).update_traces(
    mode="lines")

    trace2 = px.scatter(df, x="day", y="market_cpc", color="display_env_name", hover_name='display_env_name',
                        color_discrete_sequence=px.colors.qualitative.Antique,).update_traces(
    mode="lines")

    trace2.update_traces(yaxis="y2")

    fig.add_traces(trace1.data + trace2.data)

buttons = [{"label": t.name,
                    "method": "update",
                    "args": [{"visible": [t2.legendgroup == t.legendgroup for t2 in fig.data]}],
                     } for t in fig.data[0:3]]

    fig.update_layout(
    updatemenus=[
        {   "y": 1.1,
            "buttons": buttons,
            "active": 0
            }
        ]
    )

A: I found a solution to changing the trace names with a for loop.
Please note: df['color'] contains var1 by default. When adding var2, we need not remove var1.
   labels = df['color'].unique().tolist()

    for i in range(len(labels)):
        x = labels[i]+" var2"
        labels.append(x)

    for n in range(len(fig.data)):
        fig.data[n].name = labels[n]


text:
Q: socket timeout exception on ubuntu We have solr router and shards. This appears in the jetty log of the router when doing faceted search across all the shards.
org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request

followed by exception about Internal Server Error. We run eighty shards distributed across several servers. Router runs on its own node.
UPD:
In the HttpCommComponent class of SOLR which sumbits requests to shards using HttpClient class I have noticed the following set on the MultiThreadedHttpConnectionManager:
    mgr.getParams().setDefaultMaxConnectionsPerHost(20);
it seems to me like too little setting for 80+ shards.

A: After some more debugging I have found out, that one of the requests had a size of 4,4MB. The default maxPostSize in tomcat6 is 2MB (http://tomcat.apache.org/tomcat-6.0-doc/config/ajp.html).
Changing that to 10MB has greatly improved situation on the solr side.


text:
Q: Disable completion cache in zsh I have a script which can complete itself when called with complete arg. Following Zsh completion script transferring it to Zsh:
#compdef das

_das() {
        local -a commands
        self="$(echo $words | cut -d' ' -f1)"
        numargs=$(($CURRENT-2))
        if [ $numargs -ge 1 ]; then
                args=$(echo ${words#$self} | xargs | cut -d' ' -f-$numargs)
        fi
        $self complete $(echo ${args}) | while read line; do
                commands+=("$line")
        done
        _describe -t commands 'commands' commands
        return 0
}

_das

It works well, but after first entered command Zsh remembers last completion it showed and shows only it, without calling $self complete again.
How to force it to call script every time, not only first?


text:
Q: Crystal Reports in VS 2010 not working on Web Server I am using crystal reports to generate a report and save it as a PDF in a folder. Everything works fine on the local machine. The code is working fine and the report is generated and saved as a PDF as well.
Now, coming to the server, I do not have a VS 2010 installed on the web server. But I had a website application created in ASP.NET framework in VS2010 that I deployed on the server and it is working fine even with no VS2010 on the server.
But now I had to generate the crystal report and save it in the folder. This is another module of the same website. But when I put the .aspx and .aspx.cs and .rpt file on the server, I get an error "Parser Error Message: Could not load file or assembly 'CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified".
So, I tried installing the crystal report package from here but it says it needs VS 2010 for completing the installation. So, not sure if I can do it without VS 2010 on the server.
Is there any way to do it with no VS 2010 on the server, or I have to install VS 2010 for sure on the server, or any other installation that can help me?

A: You need the Crystal Reports 2010 Redistributable located here (The SAP website is not the friendliest):
SAP Crystal Reports, developer version for Microsoft Visual Studio Updates & Runtime Downloads
P.S. : SAP website is subject to change, don't mind editing or commenting this answer with up to date info.

A: Install the Crystal merge modules on the server. You should never need to install visual studio on a server.


text:
Q: Smart Pointer in C++ #include<iostream>
using namespace std;

class SmartPointer
{
    private:
        int *ptr;

    public:
        SmartPointer(int *p);
        //int operator &();
        //int operator *();
        int &operator *() {  return *ptr; }
        ~SmartPointer();
};

SmartPointer::SmartPointer(int *p = NULL)
{
    cout<<"Initilaize ABC"<<endl;
    ptr = p;
}

SmartPointer::~SmartPointer()
{

    cout<<"De-Initilaize ABC"<<endl;
    delete ptr;
}
/*
int SmartPointer:: operator &()
{
    return *ptr;
}

int SmartPointer:: operator *()
{
    return *ptr;
}

*/
int main()
{
    int iNumber = 10;
    //int *ptrToNumber;
    SmartPointer a(new int());
    *a = 10;
    cout<<"value in a:"<<*a<<endl;
    cout<<"Address of a:"<<&a<<endl;

    return 0;
}

Above is code for smart Pointer. but I am not getting few things.
1.
     int &operator *() {  return *ptr; }
I not understand above.

A: int &

Return value of this function is reference to int
operator *()

Override unary * (dereference) operator.
{  return *ptr; }

Return what is pointed.


text:
Q: How to call function from another component to another component Now I'm confused how to fire function from component to control something in another component. Can anyone help me on this?
Structure:
App.svelte
L checklist.svelte
  L button <-- this button want to call function in stage component
L stage.svelte

checklist.svelte:
<button on:click="handleMove" />

stage.svelte:
export function fly(x, y) {
   $map.flyto(x, y);
}

I have a button in checklist component that want to activate function that in stage component.
Stage component is a map that have x y position and function that move things inside this component.
How can I call function in stage component from the outside (checklist components)?

A: You have a couple of options:
first and the most flexible one is to create a writable store to use it anywhere
second it to use context
third is to declare it in App.svelte and bind it to both children

A: You could do the following:

*

*Dispatch a custom checklist-click event from Checklist.

*In App, listen to this click event and call fly on Stage.

App

<Checklist on:checklist-click={handleClick}></Checklist>

<Stage bind:this={stage}></Stage>

Checklist

<button on:click={handleMove}>
    Move
</button>

Stage

For more on dispatching component events, see the Svelte tutorial.


text:
Q: How to preserve spaces in input fields with awk I'm trying to do something pretty simple but its appears more complicated than expected...
I've lines in a text file, separated by the comma and that I want to output to another file, without the first field.
Input:
echo file1,item,      12345678 | awk -F',' '{OFS = ";";$1=""; print $0}'

Output:
;item; 12345678

As you can see the spaces before 12345678 are kind of merged into one space only.
I also tried with the cut command:
echo file1,item,      12345678 | cut -d, -f2-

and I ended up with the same result.
Is there any workaround to handle this?
Actually my entire script is as follows:
cat myfile | while read l_line
   do
      l_line="'$l_line'"
      v_OutputFile=$(echo $l_line | awk -F',' '{print $1}')
      echo $(echo $l_line | cut -d, -f2-) >> ${v_OutputFile}
   done

But stills in l_line all spaces but one are removed. I also created the quotes inside the file but same result.

A: The problem is with your invocation of the echo command you're using to feed awk the test data above.  The shell is looking at this command:
echo file1,item,      12345678

and treating file1,item, and 12345678 as two separate parameters to echo.  echo just prints all its parameters, separated by one space.
If you were to quote the whitespace, as follows:
echo 'file1,item,      12345678'

the shell would interpret this as a single parameter to feed to echo, so you'd get the expected result.

Update after edit to OP - having seen your full script, you could do this entirely in awk:
awk -F, '{ OFS = "," ; f = $1 ; sub("^[^,]*,","") ; print $0 >> f }' myfile

A: it has nothing to do with awk.  quote the string in your echo:
#with quotes
kent$  echo 'a,b,          c'|awk -F, -v OFS=";" '{$1="";print $0}'
;b;          c

#without quotes
kent$  echo a,b,          c|awk -F, -v OFS=";" '{$1="";print $0}'
;b; c


text:
Q: Parsing Json specific field from Response in Android {
    "status":"ok",
    "cookie":"dr.steve|akscjn",
    "cookie_name":"wordpress_logged_in",
    "user": {
        "id":330,
        "username":"dr.steve",
        "nicename":"steve",
        "email":"steve@docdirect.com",
        "url":"http:\/\/www.company.com",
        "registered":"2016-12-15 22:21:05",
        "displayname":"Dr.Steve",
        "firstname":"Dr",
        "lastname":"Steve",
        "nickname":"steve",
        "description":"Lorem ipsum",
        "capabilities":"",
        "avatar":null
    }
}

I have this json response and i want the only id field from this json , I think there are two nested arrays but i am geting error
E/Error: Json parsing error: Value {"id":330,.........}at user of type org.json.JSONObject cannot be converted to JSONArray
this my code
 if (jsonStr != null) {
                    try {

                        JSONArray ja = new JSONObject(jsonStr).getJSONArray("user");
                        JSONObject c =  ja.getJSONObject(1);
                        String id = c.getString("id");

                        temp2 = id;

                        Log.v("id---->",temp2);

                      }
                    } catch (final JSONException e) {
                        Log.e("Error", "Json parsing error: " + e.getMessage());
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(getApplicationContext(),
                                        "Json parsing error: " + e.getMessage(),
                                        Toast.LENGTH_LONG)
                                        .show();
                            }
                        });

                    }
                } else {
                    Log.e("Error", "Couldn't get json from server.");
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(getApplicationContext(),
                                    "Couldn't get json from server. Check LogCat for possible errors!",
                                    Toast.LENGTH_LONG)
                                    .show();
                        }
                    });

                }

can anyone tell where i am making a mistake how would i get id field from this json ?

A: The user property is a concrete object not an array so try to read it as an object:
JSONObject user = new JSONObject(jsonStr).getJSONObject("user");

A: "user":{ is  an object.
Arrays have square brackets. You have no arrays in your data


text:
Q: Preserve property attributes (writeable, configurable) after JSON.parse() Lets say that I'm creating an object in somewhere else and passing it somehow to my module. Maybe it was created on the server in node.js, maybe it was created in a different module and for whatever reason I'm JSON.stringify()ing it and passing the serialized version (especially if its coming from the server). But I want this particular property to be immutable:
var foo = {};

Object.defineProperty(foo, 'bar', {
    value: 'bar',
    writeable: false,
    enumerable: true
});

console.log(foo.bar); //bar
foo.bar = 'foo';      //fails, throws err in strict
console.log(foo.bar); //still bar

var fii = JSON.parse(JSON.stringify(foo));

console.log(fii.bar); //still bar
fii.bar = 'foo';      //succeeds
console.log(fii.bar); //now foo

Is there any way of preserving this meta-data so that the bar property is immutable without sending it separately?

A: You could stringify the property descriptors, as in
// set up object to be serialized--from OP question
var foo = {};
Object.defineProperty(foo, 'bar', {
    value: 'bar',
    writable: false,
    enumerable: true
});

// create an object of property descriptors
var descriptors = {};
Object.keys(foo).forEach(function(key) {
    descriptors[key] = Object.getOwnPropertyDescriptor(foo, key);
});

var json = JSON.stringify(descriptors);
// "{"bar":{"value":"bar","writable":false,"enumerable":true,"configurable":false}}"

Now, to reconstitute:
descriptors = JSON.parse(json);
foo = {};
Object.defineProperties(foo, descriptors);

Of course, this will not work with accessor-type descriptors which contain get and/or set, nested objects, etc. etc.
Using flags on keys
Another idea is to encode the writability into the keyname, via transformations on the way in and way out:
// Mark unwritable properties by changing keyname to 'prop:unwritable'.
function markImmutable(obj) {
    for (var p in obj) {
        if (!Object.getOwnPropertyDescriptor(obj, p).writable) {
            obj[p + ':unwritable'] = obj[p];
            delete obj[p];
        }
    }
}
markImmutable(foo)
> Object {bar:unwritable: "bar"}

Then stringify that, and after parsing do a reverse transformation.


text:
Q: How does aws elastic route requests via round robin? I am looking at graph which shows CPU load on EC2 instances. I spot that when for 1 EC2 CPU increases for 2 it decreases at same time. After some period (5 minutes) they changed that 1 decreases and 2 increases, after next 5 minutes they changed again and so on.
Questions

*

*Does this mean that aws ELB route request to the instance for some period of time? For example 10s for 1 instance then 10s for another one?

*Or it routes batch request? For example first 100 to the 1 EC2 and next 100 to 2 and so on?

The documentation says that aws ELB uses round robin. But I think that if they had routed every request to next instance there wouldn't have been different directions e.g. all instance loading would have been difference for 1-2% in load, but had the same trend (increasing or decreasing). Am I right?
The graph is like that (about 18 EC2, left is CPU loading percentage):

UPDATED

*

*It is classic load balancer

*There 2 avalaibility zones, per 9 instances at each zone.

A: From the AWS Site
A Classic Load Balancer, the load balancer node that receives the request selects a registered instance using the round robin routing algorithm for TCP listeners and the least outstanding requests routing algorithm for HTTP and HTTPS listeners.
But this might change if you have sticky sessions enabled. with sticky sessions:
you can use the sticky session feature (also known as session affinity), which enables the load balancer to bind a user's session to a specific instance. This ensures that all requests from the user during the session are sent to the same instance.
http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html
Could sticky sessions be causing the behaviour you are seeing?

A: As Michael mentioned, sticky sessions could be affecting how incoming connections are being loadbalanced.
I don't know what kind of application you are running, but you could always check the webserver's access log or your middleware access log, which could give you an insight which node(s) receive traffic and when.


text:
Q: MySQL Query cannot find column I have a query that runs fine, when I try to add one more column to where clouses it cannot find the column and gives an error.
SELECT '1' AS `row_count`, (
    SELECT
        COUNT(*)
    FROM
        `attendances`
    WHERE `program_sessions`.`id` = `attendances`.`program_session_id`
    AND `attendances`.`deleted_at` IS NULL
) AS `attendances_count`
FROM
    `program_sessions`
LEFT JOIN `programs` ON `programs`.`id` = `program_sessions`.`program_id`
LEFT JOIN `program_categories` ON `program_categories`.`id` = `programs`.`program_category_id`
LEFT JOIN `service_areas` ON `service_areas`.`id` = `program_categories`.`service_area_id`
LEFT JOIN `locations` ON `locations`.`id` = `programs`.`location_id`
WHERE (
    LOWER(`program_categories`.`name`) LIKE "%3%" OR
    LOWER(`programs`.`name`) LIKE "%3%" OR
    LOWER(`locations`.`name`) LIKE "%3%" OR
    (attendances_count = 3) OR
    LOWER(`service_areas`.`name`) LIKE "%3%"
)
AND `program_sessions`.`deleted_at` IS NULL

MySQL said:
#1054 - Unknown column 'attendances_count' in 'where clause'
The query somehow cannot reach the attendances_count. What is it that I am doing wrong?

A: Found the problem here, aparently where clouse is not able to see the aliased columns. I should use having instead.
Can you use an alias in the WHERE clause in mysql?


text:
Q: Center channel audio on windows 10 is muffled On my desktop, I use the multichannel outputs of my motherboard (MSI z170a gaming m5) to output 7.1 audio to my receiver, which in turn powers my 7.1 system. I also have it connected via optical cable. I noticed that my center channel audio (whether in games, or movies/tv shows) is muffled when using the multichannel output. This problem does not occur when using the digital output, but I prefer to use analog connections as games that support positional audio (basically everything) can't do positional audio over the optical cable -- only the multichannel surround. The center channel is the only channel I have this issue with, but it is significant. Especially when watching movies, there is a drastic change in clarity between dialogue coming from the center versus playing it in stereo mode and having it come from the R/L fronts.
To troubleshoot, I have tried:

*

*Using a different(identical model) speaker for the center, no luck

*Swapping cables from the PC to the receiver

*changing any and all Realtek audio manager settings I could find

I cant figure out why this is happening. I am on Windows 10 1903, and my receiver is the Onkyo HT-R340. Any help is much appreciated!


text:
Q: Reject input if the adjacent cell is empty Using below formula to Reject input if the adjacent cell is empty.
I am trying to made the condition for the Data validation rules that if R2:R500 is empty then Column M will Reject the input when try to add anything but below formula is not working in Validation.
=NOT(ISBLANK(R24))

Here is my Sheet

A: Try this validation setup.
=$R2:$R500<>""


text:
Q: Default implementation of Interface I've a c#.net project that uses multiple 3rd party dlls. These dlls exposes interface that are used throughout the project. My question is this: These interfaces are passed to the constructor of Controller class like this:
HomeController(IClientData clientdata, IClientRecord clientrecord)
{ }

Here clientdata and clientrecord are initialized to a default value needed to start the view(produces a list of client details). I've to use these initialized data somewhere else in my project but I don't know how to get these default initialized values.

A: What you have seen is a very general pattern in ASP.NET MVC . Here your home controller has 2 dependencies (one class inherited from IClientData and other from IClientRecord) . These dependencies are usually injected by some DI framework .
There are some good DI frameworks available for ASP.NET MVC

*

*Unity

*Autofac

*Castle Windsor

*StructureMap
etc...

and they usually provide two ways to setup the dependencies -

*

*through XML configuration files

*Fluent interface (inside code)

When Fluent interface is used, a general practice is to create a separate class file inside App_Start folder and call it from global.asax (Application_Start).


text:
Q: How to send back CSRF Token to server with Axios I have an Express Server with an endpoint that generates the csrf token for the client,
Now, I tried sending back the token in my axios request as below but I keep getting the usual Forbidden: invalid csrf token error.
Below is my code:
static async attachCSRFTokenToHeaders(headers) {
    let csrfTokenRequest = await axios.get(EndPoints.CSRF_TOKEN);
    let csRefToken = csrfTokenRequest.data;
    headers['X-CSRF-TOKEN'] = csRefToken.csrfToken;
}

static async getRequestHeaders() {
    let headers = {};
    //Possibly add more headers
    await this.attachCSRFTokenToHeaders(headers); //Attach the csrf token to the headers of each request
    return headers;
}

static async logInManually(email, password, cb) {
    let requestBody = { email, password};
    axios.post(EndPoints.SIGN_IN, requestBody, {
        headers: await this.getRequestHeaders() //Attach the headers here
    }).then((response) => {
        cb(HttpSuccessDataHandler.getSuccessResponseData(response), null);
    }).catch((e) => {
        cb(null, HttpErrorHandler.spitHttpErrorMsg(e));
    });
}

But the server still keeps throwing the usual:

ForbiddenError: invalid csrf token

Here is a snippet into my server setup
const csrf = require('csurf');
const cookieParser = require('cookie-parser');
const session = require('express-session');

....

initMiddleWare() {
        app.use(express.static('./static'));
        app.use(express.json());
        app.use(express.urlencoded({ extended: true }));
        app.use(cookieParser())
        app.use(session({
            secret: Constants.SESSIONS_SECRET,
            resave: false,
            saveUninitialized: false
        }));
        app.use(busboy({
            highWaterMark: 2 * 1024 * 1024,
            limits: {
                fileSize: maxFileSize,
            }
        }));
        app.use(csrf({ cookie: true }))
    }

 //Then somewhere in my routes, here is the route that provides the csrf token
.....
   app.get(Routes.CSRF_TOKEN, function (req, res) {
        res.send({ csrfToken: req.csrfToken() });
       });
....

A: Because of csrf({cookie: true}), the CSRF token is bound to a cookie. The axios.post request must contain not only the CSRF token in a header, but also the cookie that was received with the response to the previous axios.get request. Your code sets only the header. Unless axios handles the cookies automatically (like a browser would do), you must include client-side code for handling them as well.


text:
Q: Ionic unit testing: webpack version I've been trying to set up a testing example according to the common guidelines: Testing in Ionic, Ionic GitHub Example
My project's package.json:
{
  "name": "starter-with-testing",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve",
    "test": "karma start ./test-config/karma.conf.js"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/core": "4.7.0",
    "@ionic-native/splash-screen": "4.7.0",
    "@ionic-native/status-bar": "4.7.0",
    "@ionic/storage": "2.1.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.1.10",
    "@types/jasmine": "^2.8.8",
    "@types/node": "^10.3.4",
    "angular2-template-loader": "^0.6.2",
    "html-loader": "^0.5.5",
    "istanbul-instrumenter-loader": "^3.0.1",
    "jasmine": "^3.1.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^2.0.3",
    "karma-chrome-launcher": "^2.2.0",
    "karma-coverage-istanbul-reporter": "^2.0.1",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^1.1.0",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^3.0.0",
    "null-loader": "^0.1.1",
    "protractor": "^5.3.2",
    "ts-loader": "^4.4.1",
    "ts-node": "^6.1.2",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project"
}

Attempt at $ npm test results in an error:
Chrome 67.0.3396 (Linux 0.0.0) ERROR
{
"message": "An error was thrown in afterAll\nUncaught Error: Module build failed: Error: You may be using an old version of webpack; please check you're using at least version 4\n    at successfulTypeScriptInstance (/home/alexey/spaces/cordova/starter-with-testing/node_modules/ts-loader/dist/instances.js:168:15)\n    at Object.getTypeScriptInstance (/home/alexey/spaces/cordova/starter-with-testing/node_modules/ts-loader/dist/instances.js:51:12)\n    at Object.loader (/home/alexey/spaces/cordova/starter-with-testing/node_modules/ts-loader/dist/index.js:16:41)"

That is, webpack 4.x required. Indeed,
$ npm list webpack
starter-with-testing@0.0.1 /home/alexey/spaces/cordova/starter-with-
testing
└─┬ @ionic/app-scripts@3.1.10
  └── webpack@3.8.1

What am I supposed to do?
UPD:
I've got It looks like your post is mostly code; please add some more details. fatal error. Your question couldn't be submitted.
I'm really at a loss about more details. There is a dependency hell; please, help. I'll humbly submit whatever additional details you ask.

A: I had the same problem, and fixed it by downgrading my ts-loader and ts-node to the versions used in the ionic-unit-testing-example repository.
I.e. in package.json:
{
    //...
    "devDependencies": {
        //...
        "ts-loader": "^3.0.3",
        "ts-node": "^3.0.2",
        //...
    }
    //...
}

It's ts-loader that's complaining, so I'm not sure if the ts-node downgrade is actually required.

A: I solved the same error by simply give npm i webpack@latest.
I didn't have any custom configuration made so it seems to work now. I just found it takes really long time to compile but I haven't looked at it.


text:
Q: What does Windows use for dirty_background_ratio, dirty_bytes, etc? I keep running into problems with large file transfers in Linux. On one hand, transfers might be super slow. I apply a tweak, it fixes it but then my system will stutter while transferring a file. It is recommended to experiment with values such as:
echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes
echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes
echo 5 > /proc/sys/vm/dirty_background_ratio
echo 10 > /proc/sys/vm/dirty_ratio

Windows (Though I don't use win) never has this problem. Microsoft has clearly figured out the sweet spot. I seek to mirror the behavior of Windows in this regard. How to?


text:
Q: Eigen & OpenMP : No parallelisation due to false sharing and thread overhead System Specification:

*

*Intel Xeon E7-v3 Processor(4 sockets, 16 cores/sockets, 2
threads/core)

*Use of Eigen family and C++

Following is serial implementation of code snippet:
Eigen::VectorXd get_Row(const int j, const int nColStart, const int nCols) {

    Eigen::VectorXd row(nCols);
    for (int k=0; k<nCols; ++k) {
        row(k) = get_Matrix_Entry(j,k+nColStart);
    }

}

double get_Matrix_Entry(int x , int y){
    return exp(-(x-y)*(x-y));
}

I need to parallelise the get_Row part as nCols can be as large as 10^6, therefore, I tried certain techniques as:

*

*Naive parallelisation:
Eigen::VectorXd get_Row(const int j, const int nColStart, const int nCols) {
    Eigen::VectorXd row(nCols);

     #pragma omp parallel for schedule(static,8)
     for (int k=0; k<nCols; ++k) {
          row(k)    =   get_Matrix_Entry(j,k+nColStart);

     return row;
}

*Strip Mining:
Eigen::VectorXd get_Row(const int j, const int nColStart, const int nCols) {
    int vec_len = 8;
    Eigen::VectorXd row(nCols) ;
    int i,cols;
    cols=nCols;
    int rem = cols%vec_len;
    if(rem!=0)
        cols-=rem;

    #pragma omp parallel for
    for(int ii=0;ii<cols; ii+=vec_len){
         for(i=ii;i<ii+vec_len;i++){
             row(i) = get_Matrix_Entry(j,i+nColStart);
         }
    }

    for(int jj=i; jj<nCols;jj++)
        row(jj) = get_Matrix_Entry(j,jj+nColStart);

    return row;
}

*Somewhere from internet to avoid false sharing:
Eigen::VectorXd get_Row(const int j, const int nColStart, const int nCols) {
    int cache_line_size=8;
    Eigen::MatrixXd row_m(nCols,cache_line_size);

    #pragma omp parallel for schedule(static,1)
    for (int k=0; k<nCols; ++k)
        row_m(k,0)  =   get_Matrix_Entry(j,k+nColStart);

    Eigen::VectorXd row(nCols);
    row = row_m.block(0,0,nCols,1);

   return row;

}

OUTPUT:
None of the above techniques helped in reducing the time taken to execute get_row for large nCols implying naice parallelisation worked similar to the other techniques(although better from serial), any suggestions or method that can help to improve the time?
As mentioned by user Avi Ginsburg, I am mentioning some other system details:

*

*g++(GCC) is compiler with version 4.4.7

*Eigen Library Version is 3.3.2

*Compiler flags used: "-c -fopenmp -Wall  -march=native -O3 -funroll-all-loops -ffast-math -ffinite-math-only -I header" , here header is folder containing Eigen.

*Output of gcc -march=native -Q --help=target->(Description of some flags are mentioned only):
-mavx                             [enabled]
-mfancy-math-387                  [enabled]
-mfma                             [disabled]
-march=                           core2
For full desciption of flags please see this.

A: Try rewriting your functions as a single expression and let Eigen vectorize itself, i.e.:
Eigen::VectorXd get_Row(const int j, const int nColStart, const int nCols) {

    Eigen::VectorXd row(nCols);

    row = (-( Eigen::VectorXd::LinSpaced(nCols, nColStart, nColStart + nCols - 1).array()
                      - double(j)).square()).exp().matrix();

    return row;
}

Make sure to use -mavx and -mfma (or -march=native) when compiling. Gives me a x4 speedup on an i7 (I know you are talking about trying to use 64/128 threads, but this is with a single thread).
You can enable openmp for some further speedup by dividing the computation into segments:
Eigen::VectorXd get_Row_omp(const int j, const int nColStart, const int nCols) {

    Eigen::VectorXd row(nCols);

#pragma omp parallel
    {
        int num_threads = omp_get_num_threads();
        int tid = omp_get_thread_num();
        int n_per_thread = nCols / num_threads;
        if ((n_per_thread * num_threads < nCols)) n_per_thread++;
        int start = tid * n_per_thread;
        int len = n_per_thread;
        if (tid + 1 == num_threads) len = nCols - start;

        if(start < nCols)
            row.segment(start, len) = (-(Eigen::VectorXd::LinSpaced(len,
                               nColStart + start, nColStart + start + len - 1)
                            .array() - double(j)).square()).exp().matrix();

    }
    return row;

}

For me (4 cores), I get an additional ~x3.3 speedup when computing 10^8 elements, but expect this be lower for 10^6 and/or 64/128 cores (normalizing for number of cores, of course).
Edit
I hadn't placed any checks to make sure that the OMP threads didn't go out of bounds and
I had mixed up the second and third arguments in the Eigen::VectorXd::LinSpaced of the serial version. That probably accounted for any errors you had. Additionally, I've pasted the code that I used for testing here. I compiled with  g++ -std=c++11 -fopenmp -march=native -O3, adapt to your needs.
#include <Eigen/Core>
#include <iostream>
#include <omp.h>

double get_Matrix_Entry(int x, int y) {
        return exp(-(x - y)*(x - y));
}

Eigen::VectorXd get_RowOld(const int j, const int nColStart, const int nCols) {

        Eigen::VectorXd row(nCols);
        for (int k = 0; k<nCols; ++k) {
                row(k) = get_Matrix_Entry(j, k + nColStart);
        }
        return row;
}

Eigen::VectorXd get_Row(const int j, const int nColStart, const int nCols) {

        Eigen::VectorXd row(nCols);

        row = (-( Eigen::VectorXd::LinSpaced(nCols, nColStart, nColStart + nCols - 1).array() - double(j)).square()).exp().matrix();

        return row;
}

Eigen::VectorXd get_Row_omp(const int j, const int nColStart, const int nCols) {

        Eigen::VectorXd row(nCols);

#pragma omp parallel
        {
                int num_threads = omp_get_num_threads();
                int tid = omp_get_thread_num();
                int n_per_thread = nCols / num_threads;
                if ((n_per_thread * num_threads < nCols)) n_per_thread++;
                int start = tid * n_per_thread;
                int len = n_per_thread;
                if (tid + 1 == num_threads) len = nCols - start;

#pragma omp critical
{
        std::cout << tid << "/" << num_threads << "\t" << n_per_thread << "\t" << start <<
                                                         "\t" << len << "\t" << start+len << "\n\n";
}

                if(start < nCols)
                        row.segment(start, len) = (-(Eigen::VectorXd::LinSpaced(len, nColStart + start, nColStart + start + len - 1).array() - double(j)).square()).exp().matrix();

        }
        return row;
}

int main()
{
        std::cout << EIGEN_WORLD_VERSION << '.' << EIGEN_MAJOR_VERSION << '.' << EIGEN_MINOR_VERSION << '\n';
        volatile int b = 3;
        int sz = 6553600;
        sz = 16;
        b = 6553500;
        b = 3;
        {
                auto beg = omp_get_wtime();
                auto r = get_RowOld(5, b, sz);
                auto end = omp_get_wtime();
                auto diff = end - beg;
                std::cout << r.rows() << "\t" << r.cols() << "\n";
//              std::cout << r.transpose() << "\n";
                std::cout << "Old: " << r.mean() << "\n" << diff << "\n\n";

                beg = omp_get_wtime();
                auto r2 = get_Row(5, b, sz);
                end = omp_get_wtime();
                diff = end - beg;
                std::cout << r2.rows() << "\t" << r2.cols() << "\n";
//              std::cout << r2.transpose() << "\n";
                std::cout << "Eigen:         " << (r2-r).cwiseAbs().sum() << "\t" << (r-r2).cwiseAbs().mean() << "\n" << diff << "\n\n";

                auto omp_beg = omp_get_wtime();
                auto r3 = get_Row_omp(5, b, sz);
                auto omp_end = omp_get_wtime();
                auto omp_diff = omp_end - omp_beg;
                std::cout << r3.rows() << "\t" << r3.cols() << "\n";
//              std::cout << r3.transpose() << "\n";
                std::cout << "OMP and Eigen: " << (r3-r).cwiseAbs().sum() << "\t" << (r - r3).cwiseAbs().mean() << "\n" << omp_diff << "\n";
        }

        return 0;

}


text:
Q: import CSS and JS files using Webpack I have a directory structure like this:

and inside node_modules:
 >node_modules
  >./bin
   >webpack.config.js
  >bootstrap
   >bootstrap.css
   >bootstrap.js

I need to generate separate CSS and JS bundles like this:
custom-styles.css, custom-js.js, style-libs.css, js-libs.js
where style-libs and js-libs should contain syles and js files of all libraries like bootstrap and jQuery. Here's what I have done so far:
webpack.config.js:
const path = require('path');
const basedir = path.join(__dirname, '../../client');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const stylesPath = path.join(__dirname, '../bootstrap/dist/css');

var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
  watch: true,

  // Script to bundle using webpack
  entry: path.join(basedir, 'src', 'Client.js'),
  // Output directory and bundled file
  output: {
    path: path.join(basedir, 'dist'),
    filename: 'app.js'
  },
  // Configure module loaders (for JS ES6, JSX, etc.)
  module: {
    // Babel loader for JS(X) files, presets configured in .babelrc
    loaders: [
        {
            test: /\.jsx?$/,
            loader: 'babel',
            babelrc: false,
            query: {
                presets: ["es2015", "stage-0", "react"],
                cacheDirectory: true // TODO: only on development
            }
        },
        {
            test: /\.css$/,
            loader: ExtractTextPlugin.extract("style-loader", "css-loader")
        },
    ]
  },
  // Set plugins (for index.html, optimizations, etc.)
  plugins: [
     // Generate index.html
     new HtmlWebpackPlugin({
        template: path.join(basedir, 'src', 'index.html'),
        filename: 'index.html'
     }),
     new ExtractTextPlugin(stylesPath + "/bootstrap.css", {
        allChunks: true,
     })
  ]
};

Client.js
import * as p from 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App.jsx';

ReactDOM.render(<App />, document.getElementById('app'));

I am able to run the app and render all of the components correctly except loading the external JS and CSS file using webpack.
I'm not much experienced with webpack and find it really difficult it wrap my hear around it. There're are a few simple questions:
1- Is this configuration correct? If yes, then how can I include my CSS and JS files in components using ES6. Something like import keyword.
2- Should I even be using webpack for CSS files?
3- How to specify individual directories for input and their respective output files in webpack? Something like all-custom.js should be output for custom1.js and custom2.js?
I know these are some very basic question and I tried Google but didn't find a single tutorial for Webpack that is simple and targets beginners.

A: After playing out with Webpack in multiple projects, I figured out how Webpack loads stuff. Since the question is still unanswered, I decided to do it myself for anybody with same need.
Directory structure
->assets
  ->css
    ->my-style-1.css //custom styling file 1
    ->my-style-2.css //custom styling file 2

->src
  ->app
    ->app.js
    ->variables.js

  ->libs.js //require all js libraries here
  ->styles-custom.js //require all custom css files here
  ->styles-libs.js //require all style libraries here

->node_modules
->index.html
->package.json
->webpack.config.js

Bundle 1 (main code of app)
app.js: assuming this is main file and app starts from here
var msgs = require('./variables');
//similarly import other js files you need in this bundle

//your application code here...
document.getElementById('heading').innerText = msgs.foo;
document.getElementById('sub-heading').innerText = msgs.bar;

Bundle 2 (js modules)
libs.js: this file will require all modules needed
require('bootstrap');
//similarly import other js libraries you need in this bundle

Bundle 3 (external css files)
styles-libs.js: this file will require all external css files
require('bootstrap/dist/css/bootstrap.css');
//similarly import other css libraries you need in this bundle

Bundle 4 (custom css files)
styles-custom.js: this file will require all custom css files
require('../assets/css/my-style-1.css');
require('../assets/css/my-style-2.css');
//similarly import other css files you need in this bundle

webpack.config.js
const path = require('path');
const webpack = require('webpack');
const extractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
    entry: {
        'app': './src/app/app.js', //specifying bundle with custom js files
        'libs': './src/libs.js', //specifying bundle with js libraries
        'styles-custom': './src/styles-custom.js', //specifying bundle with custom css files
        'styles-libs': './src/styles-libs.js', //specifying bundle with css libraries
    },
    module: {
        loaders: [
            //used for loading css files
            {
                test: /\.css$/,
                loader: extractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'css-loader?sourceMap' })
            },
            //used for loading fonts and images
            {
                test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
                loader: 'file-loader?name=assets/[name].[hash].[ext]'
            }
        ]
    },
    output: {
        path: path.resolve(__dirname, 'dist'), //directory for output files
        filename: '[name].js' //using [name] will create a bundle with same file name as source
    },
    plugins: [
        new extractTextPlugin('[name].css'), //is used for generating css file bundles

        //use this for adding jquery
        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jQuery'
        })
    ]
}

index.html

  <link rel="stylesheet" href="dist/styles-libs.css" />
  <link rel="stylesheet" href="dist/styles-custom.css" />

A: *

*You can include css & JS files using import in es6 in the source files in your project. example:

import './style.css';
import Style from './path/style.js';

NB. Generally You need to code in es5 in webpack.config.js file. If you want to use es6 just follow the link How can I use ES6 in webpack.config.js?

*You can use https://github.com/webpack/css-loader for CSS configuration.

*You can use code splitting in webpack and specify multiple entry point but that will generate multiple output files. Have a look at multiple entry point section of that following link.
https://webpack.github.io/docs/code-splitting.html