text:
Q: How to remove overhead caused by increasing number of CPU cores We have a situation where in a server with 8 core initializes a service in 6 minutes and the other server with 32 cpu-cores takes 35 minutes to initialize the service. After profiling it properly we have seen that it is because of two kernel APIs(get_counters and snmp_fold_field) which tries to collect data from each existing cores and as the number of cpu-cores increases execution time takes longer than expected.In order to reduce initialization time we thought to make extra cores disabled and later to initialization enable all the cpu cores.But in this approach also once we enable all cores synchronization happens on newly enabled cores as this is SMP kernel.
Can someone suggest us how to reduce overhead caused by increased CPU cores efficiently?

Instead code i would rather explain initialization functionality of this user defined system service.During its initialization this service plumbs virtual interfaces on configured IPs. To avoid overlapping IPs situation for each configured IP it creates an internal IP and all communication is done on the interfaces plumbed on internal IP.As the packet reaches to system with destination as configured IP , Mangling/NATting/Routing table rules are applied on the system to mange it.
An interface is also plumb for configured Ip to avoid IP forwarding.Our issue is when we scale our system configured for 1024 IPs on 8 core machine it takes 8 minutes and on 32 cores it takes 35 minutes.
On further debugging done using system profiling We saw that ARPtables/IPtables's kernel module is consuming most time in "get_counters()" and IP's kernel module is consuming time in snmp_fold_field(). If i simply disable ARPtables Mangling rules time drops to 18 minutes from 35 minutes.I can share the kernel modules's callstacks collected using profiler.

A: A common bottleneck in applications utilizing multi-core is uncontrolled/-optimized access to shared resources. The biggest performance killer is the bus-lock (critical sections) followed by accesses to RAM, accesses to the L3 cache and accesses to the L2 cache. As long as a core is operating inside its own L1 (code and data) caches the only bottlenecks will be due to poorly-written code and badly-organized data. When two cores need to go outside their L1 caches they may collide when accessing their (shared) L2 cache. Who gets to go first? Is the data even there or must we move down into L3 or RAM to access it? For every further level required to find the data you're looking at a 3-4x time penalty.
Concerning your application it seems to have worked reasonably well because eight cores can only collide to a certain degree when accessing the shared resources. With thirty-two cores the problem becomes more than four times as large because you'll have four times the strain on the resource and four times as many cores to resolve who gets to access first. It's like a doorway: as long as a few people run in or out through the doorway now and then there's no problem. Someone approaching the doorway might stop a little to let the other guy through. Suddenly you have a situation where many people are running in and out and you'll not only have congestion, you'll have a traffic jam.
My advice to you is to experiment with restricting the number of threads (which will translate into number of cores) your application may utilize at any one time. The six minute startup time on eight cores could serve as a benchmark. You may find that it will execute faster on four cores than eight, not to mention thirty-two.
If this is the case and you still insist on running faster on thirty-two cores than you are today you're looking at an enormous amount of work both making the SNMP-server code more efficient and organizing your data to lessen the load on shared resources. Not for the faint-of-heart. You may end up re-writing the entire application.


text:
Q: I want to know how to use Github in open source I am a programming starter to try github for the first time.
https://github.com/froala/design-blocks
I completed the clone as described in the main link.
I have also completed the npm installation as described in the text and have successfully run it.
But if i simply want to use source code, do i not need to install the module using npm?
Why do I install the module using npm?..
How do I use the packages I installed using npm?
Even if I did a search on Google, there was no post for beginners like me.
I really appreciate your advice.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Java Android Studio Application Development - NullPointerException. My Application force closes when it loads second Activity I get a FATAL EXCEPTION: main java.lang.NullPointerException on my Android App (AA). My AA has two activities, The first screen is a basic profile home screen the second is a picture gallery. I'm not very good at debugging yet so I have not been able to figure out why the second activity force closes (FC).
Can you point me in the right direction?
Main Activity
package com.gallery.brien.picturegallery;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Picture;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

public class Main extends Activity {

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

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

public void changePicture(View view) {
    /* Open picture gallery activity */
    Intent intent = new Intent(this,PictureGallery.class);
    startActivity(intent);

     }
}

Second Activity
package com.gallery.brien.picturegallery;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;

public class PictureGallery extends Activity {

//variable array where pictures are store
Integer[] Profile = {R.drawable.brien, R.drawable.kick, R.drawable.mma, R.drawable.fun,
        R.drawable.run};

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

    //  UI of gallery display. Initializes the GridView and ItemView
    //  classes. Then wait for interaction from user.
    GridView gal = (GridView) findViewById(R.id.gridView);
    final ImageView imageView = (ImageView) findViewById(R.id.imageSelected);

    //  Calls the ImageAdapter Class.
    gal.setAdapter(new ImageAdapter(this));
    // Calls the onItemClickListener Class
    gal.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override

       /*                onItemClick Method
       The onItemClick method has four arguments.
        AdapterView<?> arg0 - Records where the user touched screen
        View arg1 - Parameters of the View user touched
        int arg2  - Integer value that holds the position of the View
                    in the adapter.
        long arg3 - Determines the row id of the item that was
                     selected by the user.
        */
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

            Toast.makeText(getBaseContext(), "You have selected picture " + (arg2 + 1)
                    + "Brien Calloway", Toast.LENGTH_SHORT).show();
            imageView.setImageResource(Profile[arg2]);
        }
    });

}

public class ImageAdapter extends BaseAdapter{

    private Context context;
    public ImageAdapter(Context c){
        context=c;
    }

    public ImageAdapter(PictureGallery pictureGallery) {

    }

    @Override
    public int getCount() {return Profile.length;}

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int arg0, View arg1, ViewGroup arg2) {
        ImageView pic = new ImageView(context);
        pic.setImageResource(Profile[arg0]);
        pic.setScaleType(ImageView.ScaleType.FIT_XY);
        pic.setLayoutParams(new GridView.LayoutParams(200,175));
        return pic;
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_picture_gallery, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
}

LOGCAT
OpenGL ES Shader Compiler Version: E031.24.00.07
    Build Date: 01/22/14 Wed
    Local Branch: base_au149_adreno_au169_patches
    Remote Branch:
    Local Patches:
    Reconstruct Branch:
01-12 16:21:20.914  24367-24367/com.gallery.brien.picturegallery D/OpenGLRenderer﹕ Enabling debug mode 0

01-12 16:21:53.704  24367-24367/com.gallery.brien.picturegallery W/ApplicationPackageManager﹕ getCSCPackageItemText()

01-12 16:21:53.734  24367-24367/com.gallery.brien.picturegallery E/MoreInfoHPW_ViewGroup﹕ Parent view is not a TextView

01-12 16:21:53.784  24367-24367/com.gallery.brien.picturegallery D/AbsListView﹕ Get MotionRecognitionManager

01-12 16:21:53.804  24367-24367/com.gallery.brien.picturegallery D/AbsListView﹕ onVisibilityChanged() is called, visibility : 4

01-12 16:21:53.804  24367-24367/com.gallery.brien.picturegallery D/AbsListView﹕ unregisterIRListener() is called

01-12 16:21:53.814  24367-24367/com.gallery.brien.picturegallery D/AbsListView﹕ onVisibilityChanged() is called, visibility : 0

01-12 16:21:53.814  24367-24367/com.gallery.brien.picturegallery D/AbsListView﹕ unregisterIRListener() is called

01-12 16:21:53.834  24367-24367/com.gallery.brien.picturegallery D/AbsListView﹕ unregisterIRListener() is called

01-12 16:21:53.844  24367-24367/com.gallery.brien.picturegallery D/AndroidRuntime﹕ Shutting down VM

01-12 16:21:53.844  24367-24367/com.gallery.brien.picturegallery W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x42068da0)

01-12 16:21:53.864  24367-24367/com.gallery.brien.picturegallery E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.gallery.brien.picturegallery, PID: 24367
    java.lang.NullPointerException
            at android.view.ViewConfiguration.get(ViewConfiguration.java:329)
            at android.view.View.<init>(View.java:3578)
            at android.widget.ImageView.<init>(ImageView.java:118)
            at com.gallery.brien.picturegallery.PictureGallery$ImageAdapter.getView(PictureGallery.java:85)
            at android.widget.AbsListView.obtainView(AbsListView.java:2733)
            at android.widget.GridView.onMeasure(GridView.java:1049)
            at android.view.View.measure(View.java:17367)
            at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
            at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
            at android.view.View.measure(View.java:17367)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
            at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            at android.view.View.measure(View.java:17367)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
            at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:382)
            at android.view.View.measure(View.java:17367)
            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5352)
            at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2505)
            at android.view.View.measure(View.java:17367)
            at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2174)
            at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1315)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1512)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1199)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6383)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
            at android.view.Choreographer.doCallbacks(Choreographer.java:603)
            at android.view.Choreographer.doFrame(Choreographer.java:573)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5293)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
            at dalvik.system.NativeStart.main(Native Method)

01-12 16:26:54.014  24367-24367/com.gallery.brien.picturegallery I/Process﹕ Sending signal. PID: 24367 SIG: 9

A: Remove the line:
 public ImageAdapter(PictureGallery pictureGallery) {

 }

You're calling this constructor and your context is null.

A: Your ImageAdapter is being constructed with its second constructor, which does not set the context. That null context leads to the NullPointerException later on in the ImageView constructor, which is called in getView.
Change the constructor to set the context or remove the constructor alltogether.


text:
Q: Merge two dataframes of different lengths with matching ID and fill NaN values of main dataframe on two columns I have two dataframes, the main dataframe has two columns for Lat and Long some of which have values and some of which are NaN. I have another dataframe that is a subset of this main dataframe with Lat and Long filled in with values. I'd like to fill in the main DataFrame with these values based on matching ID.
Main DataFrame:
        ID      Lat         Long
0   9547507704  33.853682   -80.369867
1   9777677704  32.942332   -80.066165
2   5791407702  47.636067   -122.302559
3   6223567700  34.224719   -117.372550
4   9662437702  42.521828   -82.913680
... ... ... ...
968552  4395967002  NaN NaN
968553  6985647108  NaN NaN
968554  7996438405  NaN NaN
968555  9054647103  NaN NaN
968556  9184687004  NaN NaN

DataFrame to fill:
    ID          Lat         Long
0   2392497107  36.824257   -76.272486
1   2649457102  37.633918   -77.507746
2   2952437110  37.511077   -77.528711
3   3379937304  39.119430   -77.569008
4   3773127208  36.909731   -76.070420
... ... ... ...
23263   9512327001  37.371059   -79.194838
23264   9677417002  38.406665   -78.913133
23265   9715167306  38.761194   -77.454184
23266   9767568404  37.022287   -76.319882
23267   9872047407  38.823017   -77.057818

The two dataframes are of different lengths.
EDIT for clarification: I need to replace the NaN in the Lat & Long columns of the main DataFrame with the Lat & Long from the subset if ID matches in both DataFrames. My DataFrames are both >60 columns, I am only trying to replace the NaN for those two columns.
Edit:
I went with this mapping solution although it isn't exactly what I'm looking for, I know there is a much more simple solution.
#mapping coordinates to NaN values in main
m = dict(zip(fill_df.ID,fill_df.Lat))
main_df.Lat = main_df.Lat.fillna(main_df.ID.map(m))
n = dict(zip(fill_df.ID,fill_df.Long))
main_df.Long = main_df.Long.fillna(main_df.ID.map(n))

A: new_df = pd.merge(main_df, sub_df, how='left', on='ID')

I guess the left join will do the job.

A: One approach is to use DataFrame.combine_first. This method aligns DataFrames on index and columns, so you need to set ID as the index of each DataFrame, call df_main.combine_first(df_filler), then reset ID back into a column. (Seems awkward; there's probably a more elegant approach.)
Assuming your main DataFrame is named df_main and your DataFrame to fill is named df_filler:
df_main.set_index('ID').combine_first(df_filler.set_index('ID')).reset_index()

A: This should do the trick:
import math
A = pd.DataFrame({'ID' : [1, 2, 3], 'Lat':[4, 5, 6], 'Long': [7, 8, float('nan')]})
B = pd.DataFrame({'ID' : [2, 3], 'Lat':[5, 6], 'Long': [8, 9]})
print('Old table:')
print(A)
print('Fix table:')
print(B)
for i in A.index.to_list():
    for j in B.index.to_list():
        if not A['ID'][i] == B['ID'][j]:
            continue
        if math.isnan(A['Lat'][i]):
            A.at[i, 'Lat'] = B['Lat'][j]
        if math.isnan(A['Long'][i]):
            A.at[i, 'Long'] = B['Long'][j]
print('New table:')
print(A)

Returns:
   ID  Lat  Long
0   1    4   7.0
1   2    5   8.0
2   3    6   NaN
Fix table:
   ID  Lat  Long
0   2    5     8
1   3    6     9
New table:
   ID  Lat  Long
0   1    4   7.0
1   2    5   8.0
2   3    6   9.0

Not very elegant but gets the job done :)


text:
Q: Shorter method for getting the name of the current method dynamically I'm looking for a way to get the name of the current method without having to create a blank object. Is there a way to do this? This would tidy up our logging code.
Here is what we do now:
new Object() {}.getClass().getEnclosingMethod().getName(

A: You can also use
Thread.currentThread().getStackTrace()[1].getMethodName()

contains the last method call, but is not shorter that
new Object() {}.getClass().getEnclosingMethod().getName

I am not aware of a sorter way to do it.

A: You can use thread.currentThread().getStacktrace()[0].getMethodName(). But this even takes more time than new Throwable().getStacktrace() (see http://alexradzin.blogspot.co.il/2011/12/how-slow-getstacktrace-is.html)

A: How about Thread.currentThread().getStackTrace()[1]?
Since this enables you to examine higher levels of the stack trace, you could easily wrap this in a helper method (see below). It also gives you the option to get quite a bit more info than just the method name, such as the file name, line number etc.
edit The helper method could look something like this (thanks @Esailija):
public static String getMethodName() {
    return Thread.currentThread().getStackTrace()[2].getMethodName();
}


text:
Q: Why does this question not have an "edit" button? I am not seeing an edit button on this question: I'm making a program which needs to make a division by 10, but it throws Floating Point Error (ignore the spanish) (I wanted to add a "nasm" tag.) This is on Mozilla Firefox 68.0.2 on Android 9, both in the native (mobile) view as well as the "Request Desktop Site" view.
I already read Why is the edit button disabled? but the top answer says:

In most cases, you will still see the edit button, but you will get an error message if you try to click it. However, in case 5 above, no edit button will be shown,

And point 5 is:

You are not logged in and the post is less than 10 minutes old, or you are trying to edit a tag wiki.


text:
Q: Ansible role variable heirarchy when looping over dictionaries I am new to Ansible and am setting up a role to generate configs for multiple devices.  For this post lets use switches as the example.  Let's say I want to configure switches for multiple customers.  This means there will be many settings are that are similar and some that are unique.  I want all the similar settings to go in defaults/main.yml and the unique settings to go vars/main.yml with ability to overwrite defaults/main.yml.
What I have so far...
tasks/main.yml
---
- name: Write config out to file
  template:
    src: swtiches.j2
    dest: /opt/ansible-output/{{ item.customer_name }}/{{ item.hostname }}.cfg
  with_items: "{{switches}}"

vars/main.yml
---
switches:
  - hostname: SW1
    customer_name: ACME1
    mgmt_ip: 10.0.0.8
    mgmt_ip_subnet_mask: 255.255.255.0
    mgmt_gateway: 10.0.0.1

  - hostname: SW2
    customer_name: ACME2
    mgmt_ip: 10.1.1.8
    mgmt_ip_subnet_mask: 255.255.255.0
    mgmt_gateway: 10.1.1.1

My understanding is that because I am using with_items in tasks/main.yml my variables in vars/main.yml need to be a dictionary (to iterate over multiple devices).  This is where the problem comes in.  How do I format things in defaults/main.yml in order to preserve variable precedence rules?
Let's say the majority of my customers are in eastern timezone so I want to put
timezone: America/New_York

in defaults/main.yml but on occasion I want to add
timezone: America/Chicago

to vars/main.yml to override the default.
NOTE1: If I don't use with_items in tasks/main.yml so that I only configure one device and I use key:value pairs in both defaults/main.yml and vars/main.yml I can get to override to work.  This shows the concept of overriding works....just not when I add the complexity of multiple devices.
NOTE2: If I setup my variables as a dictionary in both main.yml files and use the combine function (which I was given in a previous post) I can combine and use variables from both defaults/main.yml and vars/main.yml BUT....I lose the ability to override variables given the nature of combining dictionaries.
QUESTIONS:  Do precedence rules only work when using key:value pairs?
If not, how do I set up defaults/main.yml to work using with_items and preserve the ability to overwrite using the various precedence rules (group_vars, host_vars, extra_vars, etc)?


text:
Q: How do I call a stored procedure exposed as an Entity Framework Function Import through ADO.NET Data Services (Astoria)? I've created an Entity Data Model and imported several stored procedures as Function Imports.  I'm exposing the EDM through ADO.NET Data Services (ANDS).  Does ANDS automatically expose the functions through its REST API, or do I need to manually add operations to the service?

A: You will need to expose the sproc through a ServiceOperation.  From what I can tell, all mapping to a FunctionImport does is make it usable within the service via CurrentDataSource.  Think of it as only a link between the concept and store.


text:
Q: First L'Hospital Rule's proof (Bartle 4th ed) On the page 183,  case (a) for example, how can we choose/construct such $c\in (a,b)$ and this $c$ is larger than or equal to $\beta.$
Any help would be appreciated.

A: You don't construct $c$ such that $c \geq \beta$. You find $c$ as in previous step. And then assert that if $\alpha$ and $\beta$ satisfy the inequalities $a<\alpha <\beta \leq c$ then $L-\epsilon <\frac {f(\beta)-f(\alpha)} {g(\beta)-g(\alpha)} <L+\epsilon$.

A: Using the definition of
$$
\lim_{x\to a^+} \frac {f'(x)}{g'(x)} = L,
$$
i.e.
$$
\forall \varepsilon > 0, \exists \delta > 0 \colon \left(a <x < a+\delta \implies L-\varepsilon < \frac {f'(x)}{g'(x)} < L+\varepsilon \right).
$$
If this $\delta$ is large enough, your $c = a+\delta$ could be bigger than $\beta$. Although we do not require $c > \beta$.
UPDATE
$\alpha, \beta$ are arbitrary. In fact the proof could also be written as the following.

If $L \in \mathbb R$, then given $\varepsilon > 0$, there exists $c \in (a,b)$ s.t. $$u \in (a,c) \implies L-\varepsilon < \frac {f'(u)}{g'(u)} < L+\varepsilon. $$ Now for $a < \alpha < \beta \leqslant c$, by the Cauchy MVT we have $(2)$. Hence we have $(3)$.


text:
Q: Sync data between azure database and local database using cloud power shell We are trying to sync an azure database and local SQL database using power shell. We are referencing the following URL for the sync process.
https://learn.microsoft.com/en-us/azure/azure-sql/database/scripts/sql-data-sync-sync-data-between-azure-onprem
Up to the database schema section, we can execute the script successfully. But when we execute the following code it is showing an error.
$newSchema  = [AzureSqlSyncGroupSchemaModel]::new()

Error is "InvalidOperation: Unable to find type [AzureSqlSyncGroupSchemaModel]".
Even we used the following statement in the script it is still showing error.
using namespace Microsoft.Azure.Commands.Sql.DataSync.Model
using namespace System.Collections.Generic

We have researched a lot for a solution but couldn't find a proper one yet. We had tried "[System.Reflection.Assembly]::LoadWithPartialName( " option also, but this also not lead us to success. Please let us know if you have a solution. It would be very helpful for us.

A: I know it's a bit old thread but wanted to provide an update if you are still looking for a response on it.
I believe it is related to this thread so I recommend you to check answer in it and see if it resolves your issue.
On the other hand, I recommend you to share the document enhancement feedback for this Azure document by clicking on "This page" option (shown in below screenshot) that's available at the bottom of the referred Azure document so that related document's author would review the feedback and consider enhancing the document as appropriate with a note or with a workaround for the issue.

A: I was able to get around this by only including the one using statement:
using namespace Microsoft.Azure.Commands.Sql.DataSync.Model

In the rest of the code I used the fully qualified name for generic collections like System.Collections.Generic.List


text:
Q: Prevent touchstart event when scrolling/swiping on mobile devices I have a site that needs to work on mobile devices. If I touch a link while attempting to scroll down the page, it triggers the touchstart event (in most cases loading a new window, but in the case of the header, navigating through the menu). I want to be able to scroll without touchstart events being triggered. How can I accomplish this?

A: I've figured out a solution that works for most clickable items on the page:
$(document).bind("touchstart", function (e) {
    touchStartPos = $(window).scrollTop();
}).bind("touchend", function (e) {
    var distance = touchStartPos - $(window).scrollTop();
    if (distance > 20 || distance < -20) {
        e.preventDefault;
    }
});

A few items on my page seem to not get bound, but you can just specifically bind each item as needed in addition to doing a general $(document).bind().


text:
Q: Where to find a HTML dictionary I'm looking for some document, or website, where I can find EVERYTHING about HTML. Something like an HTML Dictionary/Encyclopedia. I want to read about the most unknown tags, attributes, and structures of this markup language. I've been looking for a document or a website, but I can't find any. Does someone know where I can find like a 'full documentation page' or something like that?
I'm looking for something like official documentation, not a course in Udemy or a Youtube video. I'm looking for just text and text about this markup language.
Can someone help me?

A: There are many places for HTML and Web Dev reference, some of the common and good ones are listed below:-

*

*w3Schools

*Tutorials Point

*Mozilla Developer Network

*Dev Docs
These should be sufficient for your needs in HTML and other programming languages.
Note: None of these are HTML specific, or documentation specific, some of them are also learning platforms. Look around in these websites for references and resources alike.


text:
Q: Where we have to upload Chimera abuse prevention token and what is Target URL in the New Scan page I am trying to scan my application in Chimera portal, I have logged into the portal and downloaded the abuse prevention token. Now I am not understanding where to upload it. In portal it says "You must upload the token to the root of the target site or its parent domain."
I am not understanding this point, can anyone explain with an example. Also in New Scan what will be the Target. (Say I have a managed package which I want to post on App Exchange, here what will be my Target).
Thanks in advance. I am new to this, please help.

A: Its important to understand that Chimera scan assumes you own the site or the app (Note its not your force.com app but an external app thats integrated with the force.com app)you are scanning .It implies you have built the external app (Not force.com app) and you have access to the root of the application .
Look at this answer to get a feel how this can be done for Node.js application .Same can be applied to Java or php apps .You need to keep the token file in the root folder .
The target there is your site url .Again not your force.com URL .Lets say your force.com app integrates with a website https://www.sample.com then the target will be https://www.sample.com.
Note that Chimera Report is needed for only external apps and in case you do not have access to the code base of the application you are integrating(lets say amazon or google API) then submit a ZAP report or if your client is ready to spend some $$$ you can go for BURP

A: Download the token from Chimera and store it as a .txt file.  Then go to your application and upload it to the ROOT of the project.
Specifically for IntelliJ, drag the .txt file directly over the name of the overall app/project and place it there.
The root of the project means that this .txt file (URL that displays it) is available publicly on the internet, without authenticating or doing anything else.
It's quite easy to see if it was uploaded correctly:
Once the file is uploaded and in place, make sure you can access the file by going to "YourExternalSite" .com/ChimeraToken.txt. If you can access the file, it is placed correctly.  If not, the Chimera scan will not be able to either.
My specific use case was a Java app built in IntelliJ but I assume this will work on any app.


text:
Q: Will SSD silent my computer? Do you think my computer will be silent if I replace my HDD with a SSD? Actually, I realise thanks to Task Manager that only my HD is (most of time) 100% used when CPU and memory are only 10 to 15%. I have a i7 (8 cores) Toshiba computer.
Thanks

A: As a general rule, no it won't make your computer silent.  In general, unless you're dealing with 15k RPM enterprise hard drives, your fans are going to be noisier than your hard disk (if you have no fans though, and have a power supply that doesn't make any noise (a lot of cheap ones hum), it might make the system silent other than the keyboard and mouse).
An SSD will probably reduce the noise your system produces, and is likely a good investment for other reasons too (it will reduce your power consumption and most likely speed up your system).


text:
Q: Getting imshow to display a separate colour per value in a 2D array in python I'm currently classifying an image and outputting a 2D array of values between 0 and 30.
Instead of using a default colour map, is it possible to get imshow to easily display a different colour per value? Possibly a set of selected colours?
I'm looking to highlight differences rather than having a smooth colour change. Any suggestions would be appreciated.


text:
Q: chrome packaged app image access I am having trouble accessing images in the chrome packaged app. These images are stored locally. Code works fine in the browser.
following image tag
   <img ng-src="pics/{{employee.pic}}">

I am using angularjs.
Thanks,
Niranjan

A: See:
https://developer.chrome.com/apps/app_external#external
What you have to do is fetch the binary contents of the image with XMLHttpRequest as a blob, then convert that blob to an object URL, and that's the URL you set as the src attribute of the img. It's easier than it sounds, and the cited web page gives you the code.


text:
Q: How to search with JavaScript I need to make a search bar to find h1 in divs but I need also to hide the hall div not only h1 that not matches I found this on w3school but I don't know how $(this) works I need to select the div with class blog-card
        <input id="myInput" type="text" placeholder="Search.." />

John Doe

Aug. 24, 2015

Learn

Code

HTML

CSS

Learning to Code

Opening a door to the future

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad eum dolorum architecto obcaecati enim dicta praesentium, quam nobis! Neque ad aliquam facilis numquam. Veritatis, sit.

                    Read More

$(document).ready(function () {
    $("#myInput").on("keyup", function () {
        var value = $(this).val().toLowerCase();
        $(".blog-card .description h1").filter(function () {
            $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
        });
    });
});

A: $(document).ready(function () {
    $('#searchbuttonid').on('click',function(){
        $(".blog-card h1").each(function(){
            console.log($(this).attr('Id'));
        });
    });
});

This code will return all the h1 tag's Id in console in div with class blogcard
this line hits the event handler on clicking of search button
$('#searchbuttonid').on('click',function(){

then the h1 element inside blog-card is searched by jquery
so it is written as
$(".blog-card h1").each(function(){

the reason we apply .each to select all h1 in the main class
after entering into the function, it then gets all the Id's of the h1 element in the loop using $(this).attr('Id')
then its printed on console using
console.log($(this).attr('Id'));

A: HTML code
<input id="search" type="text" placeholder="Search.." />

John Doe

Aug. 24, 2015

Learn

Code

HTML

CSS

Learning to Code

Opening a door to the future

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad eum dolorum architecto obcaecati enim dicta praesentium, quam nobis! Neque ad aliquam facilis numquam. Veritatis, sit.

                Read More

Javascript Code
$(document).ready(function () {
        $("#search").on("keyup", function () {
            var value = $(this).val().toLowerCase();
            $(".blog-card .description h1").filter(function () {
                $(this).parent(".description").parent(".blog-card").toggle($(this).text().toLowerCase().indexOf(value) > -1)
            });
        });
    });


text:
Q: Skip/bypass approval process I want to skip/bypass an approval process by using some other VF page/apex class/trigger, is it possible ? what kind of framework should I think of ?
Basically I want the record to be editable, even when it goes to an approval process !! I have 6 different segment users to use the approval process functionality simultaneously.
So I would want to use an approach which is not native salesforce and maybe done using triggers and workflows.


text:
Q: Subversion Hook wont run 'svn update' when run automatically but will when run from bash prompt I have created a subversion hook which does various things including sending out emails and updating a working copy on the server. When this is run from the bash propt it works perfectly. When run through either TortoiseSVN or Netbeans on commit, emails etc are sent but the update is not executed, no errors appear either. The file is a php file and I am using the backtick method to run bash commands. Other bash commands are run to compose the emails so that isn't the issue.
Here is the line which should run the update and log the outcome. $location is pulled from a database of working copy locations.
$update_output = `/usr/local/bin/svn update /home/$location >> update.log`;

Thanks
James
Edit, More Complete Script:
#!/usr/local/bin/php
<?
$REPOS = $argv[1];
$REV = $argv[2];

$output[] = `/usr/local/bin/svnlook dirs-changed -r $REV $REPOS`;

foreach($output as $line)
{
        preg_match("$([^/]+)$", $line, $array);
        $projects[] = $array[0];
}

$projects = array_unique($projects);

$mysqli = new mysqli('localhost', 'svn_user', 'pringles', 'svn_maindb');

if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}

foreach($projects as $project)
{
        $query = "SELECT * FROM Project WHERE name = '$project' LIMIT 1";
        $result = $mysqli->query($query);
        $row = $result->fetch_assoc();
        $proj_id = $row['id'];
        $location = $row['location'];
        if(!empty($location))
        {
                $update_output = `/usr/local/bin/svn update /home/$location >> update.log`;
        }

        /* The below line only works when the script is run by hand */
        $test = `/usr/bin/lessecho test >> /home/svn/repo/hooks/update.log`;

        /* Grab user from DB and call send_email for user */
}

function send_email($REPOS, $REV, $programmer, $email)
{
        $author = `/usr/local/bin/svnlook author -r $REV $REPOS`;
        $message .= "Project Committed By $author
        Comments:
        ";
        $message .= `/usr/local/bin/svnlook log -r $REV $REPOS`;
        $message .= "
        ===========List of Changes========

        U = Updated
        A = Added
        D = Deleted

        ";
        $message .= `/usr/local/bin/svnlook changed -r $REV $REPOS`;

        /* Compose and Send Email */
}

A: root      4231  0.0  0.0  61180   748 pts/0    S+   17:09   0:00 grep svnserve
Is this because I ran it as root? If it is running as root however then there should be no permissions issue?

A: I assume that by "SVN hook", you mean a repository hook script that is executed by the server. Note the following warning in the SVN book:

For security reasons, the Subversion
  repository executes hook programs with
  an empty environment—that is, no
  environment variables are set at all,
  not even $PATH (or %PATH%, under
  Windows). Because of this, many
  administrators are baffled when their
  hook program runs fine by hand, but
  doesn't work when run by Subversion.
  Be sure to explicitly set any
  necessary environment variables in
  your hook program and/or use absolute
  paths to programs.

In this case, the lack of a $PATH means that you have to invoke svn with its full path, e.g. /usr/bin/svn.
edit: since svn update is still not working even with the full path, I would try to log the error output like this:
$update_output = `/usr/local/bin/svn update /home/$location 2>>/var/tmp/update-error.log`;

edit2: as the error output of svn update shows, it is a permission issue. Find out as which user the script runs (e.g. by executing whoami > /var/tmp/whoami-output in the script) and make sure that this user is allowed to manipulate the working copies you are trying to update.

A: I had same issue, fixed it as following:
   #add apache user to group of target svn folder (project folder):
   usermod -a -G [group_of_current_target_svn_folder] [apache_user, e.g. dhapache]

   #change owner of target svn folder:
   D=/home/pfu5er/public_html/dev2
   chown -R [apache_user, e.g. dhapache] $D


text:
Q: Powershell script - get Distinguised Name from AD based on either username OR e-mail address I've got a Powershell script written at work mass-disabling users based on the given username in a CSV.
This week I was asked to do a bulk job but was only given e-mail addresses so I amended the script & CSV.
What I'd like to do now is to keep the CSV with headers "Username" & "Email" and then have the script find the Distinguished Name based on whichever value is given.
Eg.:

Here is the script I've currently got that has got both values in the script (script modified slightly to remove sensitive data). The script has to search on two different servers as we have users across two domains:
$Imported_csv | ForEach-Object {

$UserDN = $null
$TargetOU = $Null
$Server= $null

# Retrieve Username Address of user.
$User = $_.UserName

# Retrieve E-mail Address of User
$Email = $_.Email

# Retrieve DN of user based on e-mail address
$UserDNxxx  = (Get-ADUser -Server xxx -Filter {mail -eq $Email}).distinguishedName
$UserDNxxx = (Get-ADUser -Server xxx -Filter {mail -eq $Email}).distinguishedName

# Retrieve DN of user based on Username address
$UserDNxxx  = (Get-ADUser -Server xxx -Identity $_.UserName).distinguishedName
$UserDNxxx  = (Get-ADUser -Server xxx -Identity $_.UserName).distinguishedName

Any tips would be greatly appreciated.

A: Sounds like you just need an If block:
If ($_.UserName) {
    # Username has a value
    $UserDNxxx  = (Get-ADUser -Server xxx -Identity $_.UserName).distinguishedName
} elseif ($_.Email) {
    # Email has a value
    $UserDNxxx = (Get-ADUser -Server xxx -Filter {mail -eq $_.Email}).distinguishedName
} else {
    # It doesn't have either, so throw an error if you want
}


text:
Q: How to Build a Summary Table Connecting Communities in a Hierarchical Community Graph Plot Working from the code below, how can the table it generates produce these results for the hierarchical community (where there are 6 communities given by common node color) instead of the 5 communities produced?
edges = {NS <-> N1, NS <-> N11, NS <-> N18, NS <-> N24, NS <-> N27,
   NS <-> N35, NS <-> N37, N1 <-> N4, N1 <-> N5, N1 <-> N6, N1 <-> N7,
    N1 <-> N8, N1 <-> N9, N2 <-> N5, N3 <-> N5, N3 <-> N15, N4 <-> N2,
    N4 <-> N3, N4 <-> N5, N4 <-> N12, N4 <-> N13, N4 <-> N14,
   N5 <-> N15, N5 <-> N16, N5 <-> N19, N6 <-> N15, N7 <-> N10,
   N8 <-> N16, N9 <-> N10, N10 <-> N5, N10 <-> N6, N10 <-> N8,
   N11 <-> N6, N11 <-> N8, N11 <-> N21, N12 <-> N17, N12 <-> N40,
   N13 <-> N6, N13 <-> N21, N14 <-> NG, N15 <-> N30, N16 <-> N6,
   N17 <-> NG, N18 <-> N15, N19 <-> N20, N20 <-> N21, N20 <-> N30,
   N21 <-> N22, N22 <-> N23, N22 <-> N43, N23 <-> NG, N24 <-> NG,
   N25 <-> NG, N26 <-> N29, N26 <-> N40, N27 <-> N28, N27 <-> N40,
   N28 <-> NG, N29 <-> NG, N30 <-> N31, N30 <-> N32, N30 <-> N33,
   N30 <-> N34, N31 <-> N36, N32 <-> N36, N33 <-> N36, N34 <-> N31,
   N35 <-> N34, N36 <-> N12, N36 <-> N39, N37 <-> N36, N38 <-> N40,
   N38 <-> N43, N39 <-> N40, N40 <-> N41, N41 <-> N42, N42 <-> NG,
   N43 <-> N25, N43 <-> N26, N36 <-> N38};

g = Graph[edges, VertexLabels -> "Name", VertexLabels -> Automatic,
  VertexSize -> 0.9, VertexLabelStyle -> 14,
  VertexStyle -> {NS | N1 | N11 | N18 | N24 | N27 | N35 ->
     Darker[Red], N37 | N4 | N5 | N6 | N7 | N8 | N9 -> Red,
    N2 | N3 | N15 | N12 | N13 -> Lighter[Lighter[Orange]],
    N14 | N16 | N19 | N10 | N21 | N17 | N40 -> Yellow,
    NG | N30 | N20 | N22 | N23 | N43 | N25 | N26 | N29 | N28 | N31 ->
     Darker[Green],
    N32 | N33 | N34 | N36 | N39 | N38 | N41 | N42 -> Lighter[Green]}]

cg = CommunityGraphPlot[g,
  VertexStyle -> {v_ :> PropertyValue[{g, v}, VertexStyle]}]
communities =
  GatherBy[VertexList[g], PropertyValue[{g, #}, VertexStyle] &];
CommunityGraphPlot[g, communities,
  VertexStyle -> PropertyValue[g, VertexStyle]];
CommunityGraphPlot[g, communities, Method -> "Hierarchical",
 VertexStyle -> PropertyValue[g, VertexStyle]]

ClearAll[connectingEdgesF, tabulateF]
connectingEdgesF =
  Module[{g = #},
    Complement[EdgeList[#],
     Flatten[EdgeList[Subgraph[g, #]] & /@
       FindGraphCommunities[g]]]] &;
tabulateF =
  Module[{rule =
      Join @@ MapIndexed[Thread[# -> #2[[1]]] &,
        FindGraphCommunities[#], 1], edges = connectingEdgesF[#]},
    TableForm[(List @@@ edges) /. {a_, b_} :>
       Join[{a, a /. rule}, {b, b /. rule}],
     TableHeadings -> {None, {"From Vertex", "in Community",
        "To Vertex", "in Community"}}, TableAlignments -> Center]] &;
connectingEdgesF[g];
tabulateF[g]

A: Use communities instead of FindGraphCommunities[g] when you define connectingEdgesF:
ClearAll[connectingEdgesF, tabulateF]
connectingEdgesF = Module[{g = #},
    Complement[EdgeList[g], Flatten[EdgeList[Subgraph[g, #]] & /@ communities]]] &;

tabulateF = Module[{rule = Join @@ MapIndexed[Thread[# -> #2[[1]]] &, communities, 1],
     edges = connectingEdgesF[#]},
    TableForm[(List @@@ edges) /. {a_, b_} :>
       Join[{a, a /. rule}, {b, b /. rule}],
     TableHeadings -> {None, {"From Vertex", "in Community",
        "To Vertex", "in Community"}}, TableAlignments -> Center]] &;

tabulateF[g] // TeXForm

$\small\begin{array}{cccc}
 \text{From Vertex} & \text{in Community} & \text{To Vertex} & \text{in Community} \\
 \text{N1} & 1 & \text{N4} & 2 \\
 \text{N1} & 1 & \text{N5} & 2 \\
 \text{N1} & 1 & \text{N6} & 2 \\
 \text{N1} & 1 & \text{N7} & 2 \\
 \text{N1} & 1 & \text{N8} & 2 \\
 \text{N1} & 1 & \text{N9} & 2 \\
 \text{N10} & 4 & \text{N5} & 2 \\
 \text{N10} & 4 & \text{N6} & 2 \\
 \text{N10} & 4 & \text{N8} & 2 \\
 \text{N11} & 1 & \text{N21} & 4 \\
 \text{N11} & 1 & \text{N6} & 2 \\
 \text{N11} & 1 & \text{N8} & 2 \\
 \text{N12} & 3 & \text{N17} & 4 \\
 \text{N12} & 3 & \text{N40} & 4 \\
 \text{N13} & 3 & \text{N21} & 4 \\
 \text{N13} & 3 & \text{N6} & 2 \\
 \text{N14} & 4 & \text{NG} & 5 \\
 \text{N15} & 3 & \text{N30} & 5 \\
 \text{N16} & 4 & \text{N6} & 2 \\
 \text{N17} & 4 & \text{NG} & 5 \\
 \text{N18} & 1 & \text{N15} & 3 \\
 \text{N19} & 4 & \text{N20} & 5 \\
 \text{N2} & 3 & \text{N5} & 2 \\
 \text{N20} & 5 & \text{N21} & 4 \\
 \text{N21} & 4 & \text{N22} & 5 \\
 \text{N24} & 1 & \text{NG} & 5 \\
 \text{N26} & 5 & \text{N40} & 4 \\
 \text{N27} & 1 & \text{N28} & 5 \\
 \text{N27} & 1 & \text{N40} & 4 \\
 \text{N3} & 3 & \text{N5} & 2 \\
 \text{N30} & 5 & \text{N32} & 6 \\
 \text{N30} & 5 & \text{N33} & 6 \\
 \text{N30} & 5 & \text{N34} & 6 \\
 \text{N31} & 5 & \text{N36} & 6 \\
 \text{N34} & 6 & \text{N31} & 5 \\
 \text{N35} & 1 & \text{N34} & 6 \\
 \text{N36} & 6 & \text{N12} & 3 \\
 \text{N37} & 2 & \text{N36} & 6 \\
 \text{N38} & 6 & \text{N40} & 4 \\
 \text{N38} & 6 & \text{N43} & 5 \\
 \text{N39} & 6 & \text{N40} & 4 \\
 \text{N4} & 2 & \text{N12} & 3 \\
 \text{N4} & 2 & \text{N13} & 3 \\
 \text{N4} & 2 & \text{N14} & 4 \\
 \text{N4} & 2 & \text{N2} & 3 \\
 \text{N4} & 2 & \text{N3} & 3 \\
 \text{N40} & 4 & \text{N41} & 6 \\
 \text{N42} & 6 & \text{NG} & 5 \\
 \text{N5} & 2 & \text{N15} & 3 \\
 \text{N5} & 2 & \text{N16} & 4 \\
 \text{N5} & 2 & \text{N19} & 4 \\
 \text{N6} & 2 & \text{N15} & 3 \\
 \text{N7} & 2 & \text{N10} & 4 \\
 \text{N8} & 2 & \text{N16} & 4 \\
 \text{N9} & 2 & \text{N10} & 4 \\
 \text{NS} & 1 & \text{N37} & 2 \\
\end{array}$


text:
Q: how can I get seperate the HTML in the_content(); output? I want to be able to seperate the first image form the post into a
 tag and link it to the post page and be able to add html around the post text elements seprately.
Any help is greatly appreciated
This is what I have tried
                query_posts('posts_per_page=1&tag=food');
                while (have_posts()) : the_post();
                echo "
\n";
                    echo the_content();
                    echo '';
                    the_title();
                    echo '';

                echo "
\n";
                endwhile;

A: Look at this snippet from CSS-Tricks. It gets the first image from a post.


text:
Q: How to get specific object from data {
    type: 'Text',
    firstLanguage: {
      translation: 'When the Constituent Assembly passed the Objective Resolution?',
      option_a: '14th February 1949',
      option_b: '12th March 1949',
      option_c: '9th June 1949',
      option_d: '15th August 1949',
      correct_answer: 4
    },
    secondLanguage: {
      translation: 'متى أقرت الجمعية التأسيسية القرار الموضوعي؟',
      option_a: '14th February 1949',
      option_b: '12th March 1949',
      option_c: '9th June 1949',
      option_d: '15th August 1949',
      correct_answer: 4
    }
  },

This is the data I am getting in reposne
I want to get the firstLanguage objects in a single variable . These are comming multiple

A: suppose you getting this data is response variable. you can do like this in node JS.
const response = {
    type: 'Text',
    firstLanguage: {
      translation: 'When the Constituent Assembly passed the Objective Resolution?',
      option_a: '14th February 1949',
      option_b: '12th March 1949',
      option_c: '9th June 1949',
      option_d: '15th August 1949',
      correct_answer: 4
    },
    secondLanguage: {
      translation: 'متى أقرت الجمعية التأسيسية القرار الموضوعي؟',
      option_a: '14th February 1949',
      option_b: '12th March 1949',
      option_c: '9th June 1949',
      option_d: '15th August 1949',
      correct_answer: 4
    }
};
const firstLanguage = response.firstLanguage;
console.log(firstLanguage,'firstLanguage');

Add Comment for any query Thanks.


text:
Q: How to make git svn clone on an SVN tag fetch the complete history? In SVN tags are just another URL. So when I clone a URL which points to a tag using git svn clone <url_of_tag>, I expected it to fetch the complete history of the tag but it does not. A git log after the clone shows,
<some_hash> git-svn-id: <tag_url>@12256 eaa63c25-6722-0410-8f96-99d88de8df57

git svn clone <url_of_trunk> works fine.
How do I clone a tag URL along with the complete history?

A: Considering that a tag, in SVN is supposed to be immutable (in that you should not do any more version in a SVN tag), it is not surprising that the git svn script doesn't find many commit to create when reading the history of the SVN repo under a tag url.
(See What do "branch", "tag" and "trunk" really mean? in SVN)


text:
Q: how do I make CSV Uploader select certain values if CSV file is put in different order I am currently working on an CSV Uploader project and I have it working correctly but my question is - How would I make it select (firstname, lastname, email, phone, etc) if clients CSV file is put together differently.  Or would the client who is uploading the file have to have it in the order the program is made?
Here is php code ----------------------------------------------
try {
  # MySQL with PDO_MYSQL
  $DBH = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);
  $DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

}
catch(PDOException $e) {
    echo "I'm sorry, I'm afraid I can't do that.";
    file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
}

if (isset($_POST['submit'])){

    $file = $_FILES['files']['tmp_name'];

    $handle = fopen($file , "r");

    while (($fileop = fgetcsv($handle,1000,",")) !== false)
    {
        $firstname = $fileop[0];
        $lastname = $fileop[1];
        $email = $fileop[2];
        $phone = $fileop[3];

        $insertdata = $DBH->prepare("INSERT INTO csv (firtname, lastname, email, phone) VALUES ('$firstname','$lastname','$email','$phone')");
        $insertdata->execute();
    }
    if ($insetdata){
        echo "Successfully Uploaded. Thank you.";
    }
}

Thank you for your time!
UPDATED----------------------------------------------
New code
   try {
      # MySQL with PDO_MYSQL
      $DBH = new PDO("mysql:host=$hostname;dbname=$database", $username, $password);
      $DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

    }
    catch(PDOException $e) {
        echo "I'm sorry, I'm afraid I can't do that.";
        file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
    }

    function returnBack(){

        header("Location:http://pcgprotects.com/PCG/csvuploader/csvuploaderform.php?seterror=1");
        exit;

    }

    if (isset($_POST['submit'])){

        /*******************************GET NAME OF COLUMNS IN CSV FILE *********************************************************/
        if (empty($_POST['files'])){
            returnBack();
        }
        if (empty($_POST['firstname'])){
            returnBack();
        }
        if (empty($_POST['lastname'])){
            returnBack();
        }if (empty($_POST['email'])){
            returnBack();
        }
        if (empty($_POST['phone'])){
            returnBack();
        }
$file = $_FILES['files']['tmp_name'];

        $handle = fopen($file , "r");
        $fileop = fgetcsv($handle,1000,",");
        $firstname_index = array_search($_POST['firstname'],$fileop);
        if (empty($firstname_index)){
            returnBack();
        }
        $lastname_index = array_search($_POST['lastname'],$fileop);
        if (empty($lastname_index)){
            returnBack();
        }
        $email_index = array_search($_POST['email'],$fileop);
        if (empty($email_index)){
            returnBack();
        }
        $phone_index = array_search($_POST['phone'],$fileop);
        if (empty($phone_index)){
            returnBack();
        }

        /***********************ASSIGN COLUMN VALUES TO ACCORDING VARIABLES AND INSERT THEN INTO CSV TABLE IN DB *************************************/

        while (($fileop = fgetcsv($handle,1000,",")) !== false)
        {
            $firstname = $fileop[$firstname_index];
            $lastname = $fileop[$lastname_index];
            $email = $fileop[$email_index];
            $phone = $fileop[$phone_index];

            $insertdata = $DBH->prepare("INSERT INTO csv (firtname, lastname, email, phone) VALUES ('$firstname','$lastname','$email','$phone')");
            $insertdata->execute();
        }
        if ($insetdata){
            echo "Successfully Uploaded. Thank you.";
        }
    }

In my csv trial file i used columns named - First name, Last name, Phone, Email.  Then in my form I entered those values but I got kicked back - here is my Form code -----

<form method="post" action="csvuploader.php" enctype="multipart/form-data">

CSV Uploader

Enter Name of First Name Column
:
<input name="fisrtname" type="text" ><?php
    $setError=$_GET['seterror'];
    if($setError == 1){
    echo "Need Exact Name";
    }
        ?>

Enter Name of Last Name Column
:
<input name="lastname" type="text" ><?php
    $setError=$_GET['seterror'];
    if($setError == 1){
    echo "Need Exact Name";
    }
        ?>

Enter Name of Email Column
:
<input name="email" type="text" ><?php
    $setError=$_GET['seterror'];
    if($setError == 1){
    echo "Need Exact Name";
    }
        ?>

Enter Name of Phone Number Column
:
<input name="phone" type="text" ><?php
    $setError=$_GET['seterror'];
    if($setError == 1){
    echo "Need Exact Name";
    }
        ?>

<input type="file" name="files" /><?php
    $setError=$_GET['seterror'];
    if($setError == 1){
    echo "Select a File";
    }
        ?>

<input type="submit" name="submit" value="Submit" />

</form>

A: You can ask the customer to add one line in the beginning of the CSV that will show the structure, for example:
firstname,lastname,email,phone
joe,smith,j@gmail.com,41595648855
joe2,smith2,j2@gmail.com,41595648852

...
from reading the first line - you'll be able to know which token you should use with which index.
$file = $_FILES['files']['tmp_name'];
$handle = fopen($file , "r");
$fileop = fgetcsv($handle,1000,",");
$firstname_index = array_search("firstname",$fileop);
$lastname_index = array_search("lastname",$fileop);
...
//and then
while (($fileop = fgetcsv($handle,1000,",")) !== false)
{
  $firstname = $fileop[$firstname_index];
  $lastname = $fileop[$lastname_index];
  ...


text:
Q: Specific Square Bracket Citation using Natbib I want to use natbib package. This is the requirement of the journal citations:

*

*References should be cited in text in square brackets by giving the last name of the author and the date of publication, e.g. [Wong (1989)]. For papers by two authors, the last names are joined by "and" e.g. [Al-Hussaini and Abd-El-Hakim (1989)].

With natbib, two authors will be joined using '&', how to change that?

2.References are given in brackets unless the author's name is part of the sentence,
e.g. "the a-model [Gupta et al. (1997)]" but "according to Gupta et al. [1997]."

I cannot use the square option in natbib as it will change all other citation of year to square. But I want to use [year] in text citation only. How to set that?

A: It's straightforward to achieve your formatting objective by creating variants of the \citet and \citep commands.

\documentclass{article}
\begin{filecontents}[overwrite]{mybib.bib}
@misc{wong:89,author="Wong",title="{AA}",year=1989}
@misc{aa:89,author="Al-Hussaini and Abd-El-Hakim",title="{BB}",year=1989}
@misc{gupta:97,author={Gupta and X and Y},title="{CC}",year=1997}
\end{filecontents}

\usepackage[round,authoryear]{natbib}
\bibliographystyle{unsrtnat} % or some other suitable bib style
%% created "bracketed" variants of \citep and \citet
\newcommand\brcitep[1]{[\citet{#1}]}
\newcommand\brcitet[1]{\citeauthor{#1} [\citeyear{#1}]}

\begin{document}
\setlength\parindent{0pt} % just for this example
\brcitep{wong:89}

\brcitep{aa:89}

\brcitep{gupta:97}

\dots\ according to \brcitet{gupta:97} \dots
\bibliography{mybib}
\end{document}


text:
Q: ASP.NET 5 - DataSet, DataTable and friends I'm creating a new webservice in ASP.NET 5 using the new .NET Core library, so far I've only hit an issue with using DataSet and DataTable.
According to this site they are not included at this moment in time, which is fine, but I don't know what alternatives I have at this time, so I'm just looking for some guidance.
I have the following code:
        public string Get(string p_sUserId, string p_sUserPassword, int p_iCustId)
        {
            Select qrySelect = new Select();
        using (SqlConnection conn = new SqlConnection(Startup.ConnectionString))
        {
            using (SqlCommand cmd = new SqlCommand(qrySelect.getData(), conn))
            {
                cmd.Parameters.AddWithValue("@Id", sTestId);

                using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                {
                    using (DataSet ds = new DataSet())
                    {
                        // foo
                        // bar
                    }
                }
            }
        }

        return "value";
    }

How should I handle the data that is being return from the query? I need to build and return a string using the above data fetched from the query. Any help and guidance would be appreciated.

A: I believe SqlDataReader should work.
       string sql = "SELECT * FROM Table";
       using (SqlConnection con = new SqlConnection(Startup.ConnectionString)) {
            con.Open();
            using (SqlCommand command = new SqlCommand(sql, con)) {

                using (IDataReader dr = command.ExecuteReader()) {
                    while (dr.Read()) {
                        //process data
                    }
                }
            }
        }

A: DataTable and SqlDBAdapter are now supported using .NET Standard 2.0.  Upgrade to VS2017 Preview, add System.Data.Common and System.Data.SqlClient nugets, and the code below should work.  More detail at the blog post here ->  https://blogs.msdn.microsoft.com/devfish/2017/05/15/exploring-datatable-and-sqldbadapter-in-asp-net-core-2-0/ .  GitHub repo here -> https://github.com/jhealy/aspdotnetcore/tree/master/SqlClientPlay20 .
public static DataTable ExecuteDataTableSqlDA(SqlConnection conn, CommandType cmdType, string cmdText, SqlParameter[] cmdParms)
{
    System.Data.DataTable dt = new DataTable();
    System.Data.SqlClient.SqlDataAdapter da = new SqlDataAdapter(cmdText, conn);
    da.Fill(dt);
    return dt;
}


text:
Q: React Native - Which module do you use to make in-app payments? I develop a game app to drink with React Native and ExpoKit so without authentication, I wanted to know if I wanted to make a monthly payment how I could know if the person had paid or not? AsyncStorage? Or develop a back end? Or to use Stripe as back end? And which module is the most recommended to be able to develop a payment with Apple Pay & Google Pay? I have test : https://github.com/tipsi/tipsi-stripe but I don't success to import StripeModule for iOS and also https://github.com/naoufal/react-native-payments but that doesn't work)

A: You can use react-native-iap.
https://github.com/dooboolab/react-native-iap
And here are some medium articles about that.
https://medium.com/dooboolab/react-native-in-app-purchase-121622d26b67?
https://medium.com/dooboolab/react-native-iap-v3-1259e0b0c017
In here you could find, product and subscription. You can make a subscription in both android and ios. Also, you could send the result to backend after the user subscribes.

A: The way i have integrated in-app purchase is by following this article on medium which precisecly described how to integrate both on ios and android with ease.
But keep in mind i've used bare react native ,i.e not expo. and i would recommend you to use pure react native for such complex functions.
RN -IAP
But if you wan to use expo , ive checked this on expo docs, hope it helps ::
expo -in app purchase
And you would need a backend so that you can store the users after succesfull transactions. Hence backend is required.
Hope it helps. feel free for doubts,


text:
Q: SAML getUnmarshaller(element) returns null I am trying to construct XML object from XmlString but getUnmarshaller(element) is returning null :
This is the code :
     try {
        InitializationService.initialize();
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = docBuilder.parse(new ByteArrayInputStream(xmlString.trim().getBytes()));
        Element element = document.getDocumentElement();
        UnmarshallerFactory unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
        org.opensaml.core.xml.io.Unmarshaller unmarshaller = unmarshallerFactory
              .getUnmarshaller(element); //This is coming out be null
        System.out.println(unmarshaller);
     } catch (Exception e) {
        e.printStackTrace();
     }

This is the XMLString
static String xmlString ="<?xml version=\"1.0\"?>" +
          "  <!DOCTYPE address" +
          "  [" +
          "     <!ELEMENT address (buildingnumber, street, city, state, zip)>" +
          "     <!ATTLIST address xmlns CDATA #IMPLIED>" +
          "     <!ELEMENT buildingnumber (#PCDATA)>" +
          "     <!ELEMENT street (#PCDATA)>" +
          "     <!ELEMENT city (#PCDATA)>" +
          "     <!ELEMENT state (#PCDATA)>" +
          "     <!ELEMENT zip (#PCDATA)>" +
          "  ]>" +
          "" +
          "  <address>" +
          "    <buildingnumber> 29 </buildingnumber>" +
          "    <street> South Street</street>" +
          "    <city>Vancouver</city>" +
          "" +
          "    <state>BC</state>" +
          "    <zip>V6V 4U7</zip>" +
          "  </address>";

Any help would be appreciated.

A: Most probably there's an issue with the initialization process of OpenSAML3. My guess is that unmarshallerFactory is null. First check if you have the below dependency:
<dependency>
    <groupId>org.opensaml</groupId>
    <artifactId>opensaml-saml-impl</artifactId>
    <version>3.0.x</version>
</dependency>

If it is there then try to initialize the OpenSAML library manually, just like https://github.com/wso2-extensions/carbon-identity-saml-common/blob/931e6164ee64350b15c6aa6ae080a0c5fb280828/components/org.wso2.carbon.identity.saml.common.util/src/main/java/org/wso2/carbon/identity/saml/common/util/SAMLInitializer.java#L41-L85 and then you'll get the correct unmarshaller.

A: I don't know if it's still needed but
DefaultBootstrap.bootstrap();

at the beginning resolved the problem for me.


text:
Q: Google Analytics - Tracking Multiple Properties Including Parent I'm trying to setup tracking for multiple subdomain properties while also sending data to the main property.
Right now, we have the following setup:
domain.com - UA-XXX-1
foo.domain.com - UA-XXX-2
bar.domain.com - UA-XXX-3
If a user visits the domain "foo.domain.com", I want there to be data sent to UA-XXX-1 and UA-XXX-2 for a pageview. From my understanding, I need to setup the GA code as such:

Setting this up for all subdomains as such would mean that if I go to UA-XXX-1, I will see a mixture of data from all the subdomain properties I've setup, and if I go into the individual ones, I'll only see data for those specific properties. Easy.
However, what I'm trying to figure out is, if this the proper method to use when it comes to adding things like event/conversion tracking?
If I had a link as such:
Teletubbies

This would only send the event to the UA-XXX-1 property, and not the second property UA-XXX-2 that was setup as well, correct? Does this mean, that for each tracking code I will need to add in two separate tracking codes just to send an event tracking or is there a simpler solution?
Teletubbies

A: Everything you have above is correct. And yes, you'll need to send the hits twice to have them show up in two separate properties.
If you don't like repeating yourself so much, you can abstract away the two send commands into a single JavaScript function that always sends the hit to both properties.
For example:
function runGACommand() {
  var mainTrackerArgs = [].slice.call(arguments, 0);
  var fooTrackerArgs = mainTrackerArgs.slice(0);

  // Sets the "Foo" name on the second set of arguments.
  fooTrackerArgs[0] = 'Foo.' + fooTrackerArgs[0];

  // Runs the command on both trackers.
  ga.apply(null, mainTrackerArgs);
  ga.apply(null, fooTrackerArgs);
}

Now you can simplify your event handlers to be just this:
Teletubbies

And it will send the data to both properties.


text:
Q: viewing public status updates for a keyword Need some help. Is there anyway (api) using which we can read the public statuses of all the people? I mean i want to search whether a keyword that I want to search has been used by any of the folks in their public status messages. Functionality similar to www.youropenbook.org.
Any help would be appreciated.
Thanks,
Saurabh

A: I don't think Facebook has a publicly available search or streaming API like Twitter.


text:
Q: First derivative of a quadratic function I have the following question about the derivative.

Find out the quadratic function, which takes the value $41$ at $x=-2$ and the value $20$ at $x=5$ and is minimized at $x=2$ . Calculate the minimum value of this function.

If the function is minimized at $x=2$, then $f'(2) = 0$.
My question is: the derivative of the quadratic is a line tangent to the function or the slope of the function for a given $x$? Then the derivative equals $0$ because it is minimized at the vertex and at the vertex there is no slope?
This is not really about the question above but i just want to be sure if that is the case.

A: Given

*

*$f(x) = Ax^2 + Bx + C.$

*$f(-2) = 41.$

*$f(5) = 20.$

*$f(x)$ achieves a minimum at $x = 2.$
To do:

*

*Determine $A,B,C.$

*Determine $f(2).$

$f'(x) = 2Ax + B$ and $f''(x) = 2A.$
From the constraint that $f(x)$ has a minimum at $x=2,$ you conclude that $f'(2) = 0$ and $f''(2) > 0.$
This implies that
$$A > 0 ~\text{and that}~ B = (-4A).\tag1$$
At this point it is well to take a step back and realize that the constraint re the location (i.e value of $x$) that generates the minimum value of $f(x)$ is absolutely independent of $C$.  The only effect of the term $C$ is to translate the graph of the function $f(x) ~:~C$  units (either up or down).  Therefore, from an intuitive viewpoint, equation (1) above exhausts the info re $f$ has a minimum at $x=2$.
Therefore, there is no choice re continuing the problem.  Coefficient $B$ has been solved (re $B = -2A$) and you are forced to use the other premises (i.e. Given's) to solve for $A$ and $C$.  Once this is done, then $f$ will be completely determined, so the computation of $f(2)$ will then be straightforward.

$$A(5^2) + (-4A)(5) + C = 20 \implies 5A + C = 20.\tag2$$
$$A([-2]^2) + (-4A)(-2) + C = 41 \implies 12A + C = 41.\tag3$$
Subtracting equation (2) from equation (3) above, you have that
$$A = 3 \implies \{C = 5 ~\text{and}~ B = (-12)\}.$$

A: You don't need derivatives to solve this problem; it is known from high school that a quadratic polynomial $q(x)=ax^2+bx+1$ has an extremum at $\xi=-\frac b{2a}$, which is a minimum if $a>0$, a maximum if $a<0$, and that this extremum is equal to
$$q(\xi)=\frac{4ac-b^2}{4a}=-\frac{\Delta(q)}{4a}.$$
To determine the coefficients of $q(x)$, you simply have to solve the system of equations:
$$\begin{cases}\begin{aligned}
q(-2)&=\phantom{2}4a-2b+c=41 \\
q(5)&= 25a+5b+c=20 \\
-\frac b{2a}&= 2
\end{aligned}\end{cases}
\implies
\begin{cases}\begin{aligned}
  21a+7b &=20 \\
b&= -4a
\end{aligned}\end{cases}
$$
Can you end the calculations?
Added: To answer the question of why the derivative is $0$ at a vertex $S(x_0,f(x_0))$ on the curve, suppose $S$ corresponds, say, to a local minimum. The intuitive explanation is that the slope of a chord $(SM)$ is negative is $M$ is before $M(x,f(x))$, i.e. since $x<x_0$ and $f(x)>f(x_0)$ the rate of variation is negative. Passing to the limit on left, we obtain that $f'(x_0)\le 0$.
On the other hand, if $M$ is  *after $s$, we have $x>x_0$ and still $f(x)>f(x_0)$, so the rate of variation is positive, and wwe can conclude <ith the same argument that $f'(x_0)\ge 0$.
Therefore we have both $f'(x_0)\le 0$ and  $f'(x_0)\ge 0$. Conclusion?
Note: This is only a necessary condition  to have a local extremum, certainly not a sufficient condition.

A: Just start with $f(x)=a(x-2)^2+c$.  From $f(-2)=41$ and $f(5)= 20$ you'll easily derive $a=3$ and $c=-7$.
Concerning the slope: According to Archimedes the slope of the straight line between the points $(x_1,f(x_1)$ and $(x_2,f(x_2))$ of a parabola equals the slope of the tangent at the mean of $x_1$ and $x_2$, that is $f'\bigl((x_1+x_2)/2\bigr)$.
Hence the slope at the vertex is zero due to the symmetry of the parabola.


text:
Q: Why won't my AJAX call insert to the database? I have an ajax function that I'm using to store information in the database. The success message goes off in the console log, but nothing actually gets stored. Any ideas?
If you want me to turn on error messages, please tell me exactly how to do this, and in which file.
AJAX (goes off on a button click)
 var id = ranNum;
    //.cart-content is an item inside a shopping cart
    $('.cart-content').each(function() {
        //I know this is not the best way to grab data, but for now it's what I have to do
        var item = $(this).find('.item').text();
        var price = $(this).find('.price').text();

        //These return the proper text, so I'm grabbing the information fine.
        console.log("id: " + id);
        console.log("item: " + item);
        console.log("price: " + price);

        $.ajax({
            url : '../controllers/insertOrder.php',
            //I even added extra letters just in case I couldn't use the same word twice.
            data: {idd: id, itemm: item, pricee: price},
            type : 'POST',
            success : function(){console.log("success");},
            error : errorHandler
        });

    });

insertOrder.php (the path is correct)
<?php
require_once '../../models/database.php';
require_once 'Order.php';

$order = new Order;
$order->insertOrder($_POST['idd'], $_POST['itemm'], $_POST['pricee']);

Order.php

class Order{

    public function __construct() {

    }

    public function insertOrder ($id, $item, $price) {

        $db = Dbclass::getDB();
        $query = "INSERT INTO orders (order_id, order_item, order_price)
               VALUES(:id, :item, :price)";

        $statement = $db->prepare($query);
        $statement->bindParam(':id', $id, PDO::PARAM_INT, 11);
        $statement->bindParam(':item', $item, PDO::PARAM_STR, 50);
        $statement->bindParam(':price', $price, PDO::PARAM_STR, 10);

        $statement->execute();

    }

}

A: Figured it out. My path to the database in my insertOrder.php file wasn't right. D'oh!


text:
Q: artificial intelligence - Creative Writing I am trying to find information (and hopefully c# source code) about trying to create a basic AI tool that can understand english words, grammar and context.
The Idea is to train the AI by using as many written documents as possible and then based on these documents, for the AI to create its own creative writitng in proper english that makes sense to a human.
While the idea is simple, I do realise that the hurdles are huge, any starting points or good resoueces will be appriacted.

A: A basic AI tool that you can use to do something like this is a Markov Chain. It's actually not too tricky to write!
See: http://pscode.com/vb/scripts/ShowCode.asp?txtCodeId=2031&lngWId=10
If that's not enough, you might be able to store WordNet synsets in your Markov chain instead of just words. This gives you some sense of the meaning of the words.

A: To be able to recompose a document you are going to have to have away to filter through the bad results.
Which means:

*

*You are going to have to write a program that can evaluate if the output is valid (grammatically and syntactically is the best you can do reliablily) (This would would NLP)

*You would need lots of training data and test data

*You would need to watch out for overtraining (take a look at ROC curves)

Instead of writing a tool you could:

*

*Manually score the output (will take a long time to properly train the algorigthm)

*

*With this using the Amazon Mechanical Turk might be a good idea

The irony of this: The computer would have a difficult time "Creatively" composing something new. All of its worth will be based on its previous experiences [training data]

A: Some good references and reading at this Natural Language article.

A: As others said, Markov chain seems to be most suitable for such a task. Nice description of implementing Markov chain can be found in Kernighan & Pike, The Practice of Programming, section 3.1. Nice description of text-generating is also present in Programming Pearls.

A: One thing, though not quite what you need, would be a Markov chain of words. Here's a link I found by a quick search: http://blog.figmentengine.com/2008/10/markov-chain-code.html, but you can find much more information by searching for it.

A: Take a look at http://www.nltk.org/ (Natural Language Toolkit), lots of powerful tools there.  They use Python (not C#) but Python is easy enough to pick up.  Much easier to pick up than the breadth and depth of natural language processing, at least.

A: I agree, that you will have troubles in creating something creative. You could possibly also use a keyword spinner on certain words. You might also want to implement a stop word filter to remove anything colloquial.


text:
Q: How do I prove that the union of two simply connected open sets whose intersection is path connected is simply connected? I'm trying to understand Ronnie Brown's answer here: union of two simply connected open , with open and non empty intersection in $R^2$

Let $X$ be a topological space and $U,V$ be simply connected open subsets of $X$ such that $U\cap V $ is path-conneted.
Fix $x\in U\cap V$.
Let $r$ be a loop in $X$ based at $x$.
By Lebesgue number lemma, there is a partition $\{s_0,\cdots,s_n\}$ of $[0,1]$ such that $r([s_i,s_{i+1}])\subset U$ or $r([s_i,s_{i+1}])\subset V$.
Now, define $r_j(t)=r((1-t)s_j + t\cdot s_{j+1})$ for $1\leq i < n$. ($t\in [0,1]$)
Then, each $r_j$ is a path from $r(s_j)$ to $r(s_{j+1})$.

I completely understand till here.
However, he says that for each $j$, it is possible to choose a path $\alpha$ "in $U\cap V$" such that $\alpha(0)=x$ and $\alpha(1)=r(x_j)$.
How is that possible?
Since $r$ is an arbitrary path, it ranges over all $X$ not restricted in $U\cap V$. Since $U\cap V$ is path connected, if $r(x_j)$ is in $U\cap V$, then that makes sense, but it's possible that $r(s_j)\notin U\cap V$.
Would someone please complete the proof?

A: You are correct - there is a gap in the proof, but it is easily filled. It is possible that you have chosen the partition so that two consecutive $s_j$'s are in $U$, and then it is possible that $r(s_j)$ is not in $U \cap V$, and no such $\alpha$ exists.
However, all you need to do to fix this is to change your partition. It is always possible to choose a subset $\{t_1,\dots,t_k\} \subseteq \{s_1,\dots,s_n\}$ which satisfies

*

*For each $i$, either $r([t_{i-1},t_i]) \subseteq U$ or $r([t_{i-1},t_i]) \subseteq V$

*If $r([t_{i-1},t_i]) \subseteq U$, then $r([t_{i},t_{i+1}]) \subseteq V$, and vice versa.

The second condition ensures that $r(t_i) \in U \cap V$ for each $i$, and then you know you can choose a path as Brown suggested.

A: We can show this property using the Seifert-van-Kampen's theorem.
Infact $U$,$V$ and $U\cap V$ are path connected for hypothesis.
Let's consider a point $x_0\in U\cap V$and the fundamental group of $X$ based at $x_0$ $$\Pi_1(X,x_0)=\langle\text{generators of }\Pi_1(U),\text{generators of }\Pi_1(V)|R_U\cup R_V\cup R_S\rangle=\langle S_1\cup S_2|R_1\cup R_2\cup R_S\rangle,$$
but $S_1,S_2=\emptyset\implies \Pi_1(X,x_0)=\langle\emptyset|\emptyset\rangle\implies X$ is simply connected, since its fundamental group is trivial.


text:
Q: Moments of the Conditional variance If $X$ and $Y$ are two random variables, then the law of total variance allows us to calculate the first moment of $\text{Var}(X|Y)$ by
$$E[\text{Var}(X|Y)] = \text{Var}(X) - \text{Var}(E[X|Y]).$$
In particular we have that $E[\text{Var}(X|Y)] < \text{Var}(X)$.
I'm wondering if similar relations may hold for higher moments of $\text{Var}(X|Y)$. For example can we say something about $E[\text{Var}(X|Y)^2]$ compared to  $\text{Var}(X)^2$?
I will just comment that for any $n\in \mathbb{N}$ we have the following
$$\text{Var}(X|Y)^n \leq E[X^2|Y]^n$$ and so $$E[\text{Var}(X|Y)^n]\leq E[X^{2n}].$$


text:
Q: Exchange 2010 SP3 Apply KB4536989 Error Ended Prematurely
I am not sure if this is the right place to ask this question.
I was trying to apply the latest KB4536989 patch to my Exchange 2010 SP3 server which has hub transport, mail server and edge transport in one place.
When I tried to apply it, it came back with the following error.
I reran it again by using "Run as Admin" but the same result.
Does anyone encounter the same error?

A: Try running from elevated command prompt:
msiexec /update Exchange2010-KB4536989-x64-en.msp
I encountered the same issue and so far, running from command prompt is allowing it to proceed as expected.

A: According to your description, I found a similar thread "Exchange 2010 SP3 Apply KB4536989 Error Ended Prematurely", you could refer to Vera Shen or others' replies. Hope it helpful to you :)


text:
Q: Differentiation with $e$ I'm attempting to understand the sign of the result of this differentiation :
$$
\frac{d}{dt}(1 - e{^{-t^3})} = 0-(-3t^2)e^{-t^3} = 3t^2e^{-t^3}
$$
If $e^{-t^3}$ becomes $e^{t^3}$
then is this correct differentiation :
$$
\frac{d}{dt}(1 - e{^{t^3})} = 0-(3t^2)e^{t^3} = -3t^2e^{t^3}
$$

A: It is :
$$(1-e^{-t^3})' = (1') + (-e^{-t^3})' =0 +(-(-t^3)'e^{-t^3}) = 3t^2e^{-t^3}$$
Similarily follows for your second differentiation as well.
Both are indeed correct.
Above it is used that $(f+g)' = f' + g'$ and that $(e^{f(x)})' = f'(x)e^{f(x)}$, of course if $f$ and $g$ are differentiable.

A: $\dfrac{d}{dt}e^{g(x)}=e^{g(x)}\dfrac{d}{dt} g(x)$

A: Yes that's correct since we are using that by chain rule
$$f(x)=e^{g(x)}\implies f'(x)=g'(x)e^{g(x)}$$
note also that by intuition as $t \to \infty$

*

*$1 - e^{-t^3}\to 1$ is strictly increasing and indeed $\frac{d}{dt}(1 - e{^{-t^3})}>0$

*$1 - e^{t^3}\to -\infty$ is strictly decreasing and indeed $\frac{d}{dt}(1 - e{^{t^3})}<0$

A: Yup, all that is correct.
The reason for the sign changing comes from the chain rule. Since we are considering $e^{-t^3}$ in the first one, and the derivative of the exponential is itself, the derivative would be given by
$$\frac{d}{dt} e^{-t^3} = (-t^3)' e^{-t^3}$$
and, similarly, for the positive exponent,
$$\frac{d}{dt} e^{t^3} = (t^3)' e^{t^3}$$

A: Both results are special cases of $$\frac{d}{dt}(1-e^f)=\frac{d}{dt}(-e^f)=-\frac{d}{dt}e^f=-\frac{df}{dt}e^f,$$where for constant $c$ the first $=$ uses $\frac{dc}{dt}=0$, the second uses $\frac{d}{dt}(cg)=c\frac{dg}{dt}$, and the third uses the chain rule and $\frac{d}{df}e^f=e^f$. Your first example also uses $-(-x)=x$.


text:
Q: How to update SwiftUI's ForEach in a TabView with PageTabViewStyle modifier when inserting a new element to the collection at first index This is a very specific issue when using ForEach in a TabView with PageTabViewStyle modifier.
Every time I'm inserting an element at the beginning of my array my app crashes.
I'm getting a

attempt to delete item 11 from section 0 which only contains 11 items before the update

error.
In the canvas it crashes too.
Regular appending at the end works fine, also when I remove the PageTabViewStyle modifier it works.
Let me know if I need to elaborate more or if there are questions.
Update: I seems in iOS 15 this issue has been fixed and my code works. I'm still hoping to find a iOS 14 workaround.
I've reproduced the issue with a simple one page app:
import SwiftUI

struct SwiftUIView: View {

    @State var myArray: [String] = ["C", "D", "E", "F", "G"]

    var body: some View {

        VStack {
            Button("Insert before", action: {
                myArray.insert("A", at: 0)
            })
            TabView {
                ForEach(myArray, id: \.self) { value in
                    Text("\(value)")
                }
            }
            .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
        }
    }
}

struct SwiftUIView_Previews: PreviewProvider {
    static var previews: some View {
        SwiftUIView()
    }
}

A: Here is tested workaround for Xcode 12.5 / iOS 14.5.
TabView {
    ForEach(myArray, id: \.self) { value in
        Text("\(value)")
    }
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
.id(myArray.count)      // << here !!

A: Had same problem of crashing TabView in PageTabViewStyle for ios 14.4 or lower. It was crashing because my list initially was empty and I was populating list in onAppear.
Just changed it to check if list is empty.
if myArray.count > 0{
 TabView {
   ForEach(myArray, id: \.self) { value in
       Text("\(value)")
    }
  }
  .tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
  .id(myArray.count)      //necessary if array size is changing
}


text:
Q: How to recursively calculate yearly rollover in SQL? I need to calculate yearly rollover for a system that keeps track of when people have used days off.
The rollover calculation itself is simple: [TOTALDAYSALLOWED] - [USED]
Provided that number is not higher than [MAXROLLOVER] (and > 0)
Where this gets complicated is the [TOTALDAYSALLOWED] column, which is [NUMDAYSALLOWED] combined with the previous year's rollover to get the total number of days that can be used in a current year.
I've tried several different ways of getting this calculation, but all of them have failed to account for the previous year's rollover being a part of the current year's allowed days.
Creating columns for the LAG of days used, joining the data to itself but shifted back a year, etc.  I'm not including examples of code I've tried because the approach was wrong in all of the attempts.  That would just make this long post even longer.
Here's the data I'm working with:

Here's how it should look after the calculation:

This is a per-person calculation, so there's no need to consider any personal ID here.  DAYTYPE only has one value currently, but I want to include it in the calculation in case another is added. The [HOW] column is only for clarity in this post.
Here's some code to generate the sample data (SQL Server or Azure SQL):
IF OBJECT_ID('tempdb..#COUNTS') IS NOT NULL DROP TABLE #COUNTS
CREATE TABLE #COUNTS (USED INT, DAYTYPE VARCHAR(20), THEYEAR INT)
INSERT INTO #COUNTS (USED, DAYTYPE, THEYEAR)
SELECT 1, 'X', 2019
UNION
SELECT 3, 'X', 2020
UNION
SELECT 0, 'X', 2021

IF OBJECT_ID('tempdb..#ALLOWANCES') IS NOT NULL DROP TABLE #ALLOWANCES
CREATE TABLE #ALLOWANCES (THEYEAR INT, DAYTYPE VARCHAR(20), NUMDAYSALLOWED INT, MAXROLLOVER INT)
INSERT INTO #ALLOWANCES (THEYEAR, DAYTYPE, NUMDAYSALLOWED, MAXROLLOVER)
SELECT 2019, 'X', 3, 3
UNION
SELECT 2020, 'X', 3, 3
UNION
SELECT 2021, 'X', 3, 3

SELECT C.*, A.NUMDAYSALLOWED, A.MAXROLLOVER
FROM #COUNTS C
JOIN #ALLOWANCES A ON C.DAYTYPE = A.DAYTYPE AND C.THEYEAR = A.THEYEAR

A: The tricky part is to limit the rollover amount. This is maybe possible with window functions, but I think this is easier to do with a recursive query:
with
    data as (
        select c.*, a.numdaysallowed, a.maxrollover,
            row_number() over(partition by c.daytype order by c.theyear) rn
        from #counts c
    inner join #allowances a on a.theyear = c.theyear and a.daytype = c.daytype
    ),
    cte as (
        select d.*,
            numdaysallowed as totaldaysallowed,
            numdaysallowed - used as actualrollover
        from data d
        where rn = 1
    union all
    select d.*,
        d.numdaysallowed + c.actualrollover,
        case when d.numdaysallowed + c.actualrollover - d.used > d.maxrollover
            then 3
            else d.numdaysallowed + c.actualrollover - d.used
        end
    from cte c
    inner join data d on d.rn = c.rn + 1 and d.daytype = c.daytype
)
select * from cte order by theyear

Demo on DB Fiddle


text:
Q: Help with functional equation $F(x,x)+F(x,c-x)-F(c-x,x)-F(c-x,c-x)=0$ How can we find $F$ satisfying: exists a $c$ such that $$F(x,x)+F(x,c-x)-F(c-x,x)-F(c-x,c-x)=0 \text{ for all } x,y $$
Several quadratic polynomials in $x,y$ satisfy the above property. I'm trying to generate more examples of functions that satisfy it. I will be very grateful for any other examples.
The property says there is one $c$ that works for all $x$ but given $F$ we have freedom to find a $c$ that works. For example:

*

*If $F(x,y)=Ax^2+By^2+Cxy+Dx+Ey+F$ and $A+C\neq 0$ we set $c=\frac{-2D}{A+C}$ and one can easily verify $F$ satisfy the functional equation.

*Also if $F(x,y)=(A+By)x^2+Cy^2+Dxy+Ex+Fy+H$ there are two values of $c$.

*As Jeb pointed in the comments if $F(x,y)$ is even in $x$ and also even in $y$ then $c=0$ works.

My first idea was to try to transform the equation into a PDE by differentiating wrt $x$  but we do not get a PDE because we are evaluating $F$ at different points: $x$ and $c-x$. Honestly, I'm not even sure of what tags to use.

A: Not sure if this is what you're looking for, but here is a very general
construction (in fact it is a full characterization of all
solutions). Partition ${\mathbb R}^2$ as follows :
${\mathbb R}^2=A \cup B_- \cup B_+ \cup C$ where
$$
\begin{array}{lcl}
A &=& \lbrace (x,c-x) | x\in{\mathbb R} \rbrace \\
B_{-} &=& \lbrace (x,x) | x < \frac{c}{2} \rbrace \\
B_{+} &=& \lbrace (x,x) | x > \frac{c}{2} \rbrace \\
C &=& {\mathbb R}^2 \setminus (A \cup B_- \cup B_+)
\end{array}
$$
So $A$ is a full straight line, and $B_-$ and $B_+$ are half-lines.
Let $f:{\mathbb R}\to \mathbb R$ and $g:(-\infty,\frac{c}{2}) \to \mathbb R$
be maps. Then, put
$$
F(x,y)=\left\lbrace\begin{array}{lcl}
f(x) &\text{if} & (x,y)\in A \\
g(x) &\text{if} & (x,y)\in B_{-} \\
g(c-x)+f(c-x)-f(x)  &\text{if} & (x,y)\in B_{+} \\
\text{anything you like } &\text{if} & (x,y)\in C \\
\end{array}\right.
$$
This $F$ will satisfy your functional equation (and in fact any solution
is of this form).

A: For any function, $F(x,y)$, define the function $g(x,c)$ satisfying
$$
g(x,c) = F(x,x)+F(x,c-x)-F(c-x,x)-F(c-x,c-x)
$$
We therefore require that $\exists c$ s.t. $\forall x,\ g(x,c)=0$.
If we let $x=z+\frac{c}2$ and $\hat F(x,y)=F(x+\frac{c}2,y+\frac{c}2)$, then we have
$$
\hat g(z,c)=g(z+\frac{c}2,c)=\hat F(z,z)+\hat F(z,-z)-\hat F(-z,z)-\hat F(-z,-z)
$$
Therefore, without loss of generality, we can consider the case of $c=0$, for which we require that $\hat g(z,0)=0$. In this case, we may split the even and odd components of our function in each of the two dimensions, thus giving us
$$
\hat F(x,y) = A(x,y)+B(x,y)+C(x,y)+D(x,y)
$$
satisfying
$$A(x,y)=A(-x,y)=A(x,-y)\\B(x,y)=-B(-x,y)=B(x,-y)\\C(x,y)=C(-x,y)=-C(x,-y)\\D(x,y)=-D(-x,y)=-D(x,-y)$$
From which (letting $\hat g(x,c)=\hat g(x,0)=G(x)$), we may determine that
$$\begin{align}
G(x)=&A(x,x)+A(x,-x)-A(-x,x)-A(-x,-x)\\&+B(x,x)+B(x,-x)-B(-x,x)-B(-x,-x)\\&+C(x,x)+C(x,-x)-C(-x,x)-C(-x,-x)\\&+D(x,x)+D(x,-x)-D(-x,x)-D(-x,-x)\\
=&4B(x,x)
\end{align}$$
Therefore, the requirement is that $B(x,x)=0$. Recall that $B(x,y)$ represents the component of $\hat F(x,y)$ that is even in $y$ and odd in $x$. This provides us with a "natural" method of creating a solution. Given a function $\hat F(x,y)$, we can find $B(x,y)$ as
$$
B(x,y)=\frac{\hat F(x,y)-\hat F(-x,y)+\hat F(x,-y)-\hat F(-x,-y)}4
$$
and therefore, we may define a modified function
$$
\tilde F(x,y)=\begin{cases}\frac{3\hat F(x,x)+\hat F(-x,x)-\hat F(x,-x)+\hat F(-x,-x)}4 & x=y\\ \hat F(x,y) & \text{otherwise} \end{cases}
$$
Note that this leads to a result identical to that given by Ewan Delanoy, it is merely expressed in a different manner. For a more "natural" solution, we can require that $B(x,y)=0$, and thus define
$$
\tilde F(x,y) = \frac{3\hat F(x,y)+\hat F(-x,y)-\hat F(x,-y)+\hat F(-x,-y)}4
$$
From here, we may choose any $c$, and shift the function so that
$$
F(x,y)=\tilde F\left(x-\frac{c}2,y-\frac{c}2\right)
$$
and we have a solution for a given $c$. Notice that, for
$$
F(x,y)=Ax^2+By^2+Cxy+Dx+Ey+F
$$
with $c=\frac{-2D}{2A+C}$ we have
$$
\hat F(x,y) = Ax^2+By^2+Cxy-\frac{2BD-CD+E(2A+C)}{2A+C}y+\frac{C^2F+4ACF+4A^2F−CDE−2ADE+BD^2−AD^2}{(2A+C)^2}
$$
which, you can see, does not have the $x$ term, which is the only term in a bivariate quadratic polynomial that is even in $y$ and odd in $x$. Note the $2A+C$ on the denominator of $c$ - the value given in the question is incorrect.

A: Do you mean to replace the second $x$ with $y$? On second glance this only seems true for linear functions. Take
  $F(x,y) = xy$ ,
you'll end up with $c^2$ term that will not vanish.


text:
Q: Unable to create hive table for hbase I am running with hive version 1.1.0 , Hbase version 1.0.1 and hadoop version 2.7.0. Now for the below command I am getting error

hive> CREATE TABLE hbase_table_1(eid int, ename string, esal double)
    > STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    > WITH SERDEPROPERTIES
    > ("hbase.columns.mapping" = ":key,cfstr:enm,cfsal:esl")
    > TBLPROPERTIES ("hbase.table.name" = "emp1");
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org.apache.hadoop.hbase.HTableDescriptor.addFamily(Lorg/apache/hadoop/hbase/HColumnDescriptor;)V

If I create a table in HBase and refer that from Hive using external table, that is working fine.
In the hive home I have created an auxlib directory and copied the below jar files.

hduser@ubuntu:/usr/lib/hive/auxlib$ ls
commons-beanutils-1.7.0.jar       commons-httpclient-3.0.1.jar       hbase-checkstyle-1.0.1.jar      hbase-protocol-1.0.1.jar
commons-beanutils-core-1.8.0.jar  commons-io-2.4.jar                 hbase-client-1.0.1.jar          hbase-rest-1.0.1.jar
commons-cli-1.2.jar               commons-lang-2.6.jar               hbase-common-1.0.1.jar          hbase-server-1.0.1.jar
commons-codec-1.4.jar             commons-logging-1.1.3.jar          hbase-common-1.0.1-tests.jar    hbase-server-1.0.1-tests.jar
commons-collections-3.2.1.jar     commons-math-2.1.jar               hbase-examples-1.0.1.jar        hbase-shell-1.0.1.jar
commons-compiler-2.7.6.jar        commons-pool-1.5.4.jar             hbase-hadoop2-compat-1.0.1.jar  hbase-testing-util-1.0.1.jar
commons-compress-1.4.1.jar        commons-vfs2-2.0.jar               hbase-hadoop-compat-1.0.1.jar   hbase-thrift-1.0.1.jar
commons-configuration-1.6.jar     guava-14.0.1.jar                   hbase-it-1.0.1.jar              hive-hbase-handler-1.1.0.jar
commons-dbcp-1.4.jar              hbase-annotations-1.0.1.jar        hbase-it-1.0.1-tests.jar        zookeeper-3.4.6.jar
commons-digester-1.8.jar          hbase-annotations-1.0.1-tests.jar  hbase-prefix-tree-1.0.1.jar

The below details are set in .bashrc file

export JAVA_HOME=/usr/lib/jvm/jdk1.8.0/
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATH
#alias java="`which java` -Dwhatever"

export HADOOP_HOME=/usr/local/hadoop
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB=$HADOOP_HOME/share/hadoop/common/lib
export HADOOP_TOOLS_LIB=$HADOOP_HOME/share/hadoop/tools/lib
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
export HIVE_HOME="/usr/lib/hive"
export HBASE_HOME="/usr/lib/hbase"
export PATH=$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HIVE_HOME/bin:$HBASE_HOME/bin:$HADOOP_COMMON_LIB:$HADOOP_TOOLS_LIB:$PATH

Can you please suggest what is wrong here actually.

A: It seems you're missing the hbase.jar
First check your hive-site.xml file for the property hive.aux.jars.path and make sure hbase.jar, zookeeper.jar & hive-hbase-handlerXXXX.jar are specified.
After that, enter into the hive shell and run list jars to make sure they've been loaded. You can also load them manually (for your current session) with the command add jar [your-jar].jar

Additionally, if you don't want to mess with configuration files, you can create your own .hiverc file in your home path with your preferred initialization commands, i.e:
SET hive.cli.print.header=true;
SET hbase.scan.cacheblock=0;
SET hbase.scan.cache=10000;
SET hbase.client.scanner.cache=10000;
add JAR /usr/lib/hive/lib/zookeeper.jar;
add JAR /usr/lib/hive/lib/hbase.jar;
add JAR /usr/lib/hive/lib/hive-hbase-handler-0.10.0-cdh4.7.1.jar;
...

A: At the current time, according to HBaseIntegration

Hive 2.x will be compatible with HBase 1.x and higher. (See
  HIVE-10990 for details.) Consumers wanting to work with HBase 1.x
  using Hive 1.x will need to compile Hive 1.x stream code themselves.

In short, until Hive 2.x release, you need to compile the Hive 1.x stream code yourself!

A: This issue got fixed after using hbase version 0.98.14 with hive version 1.1.0; plz visit http://stackoverflow.com/questions/32701905/unable-to-load-data-in-hbase-table-from-hive for details

A: To day I got same issue, and build hive-src again with new pom.xml config
Please refer and change this line in pom.xml
enter code here1.1.2
Note: I use Hadoop 2.7.1, Hive 1.2.1 and Hbase 1.1.2


text:
Q: SPICE simulation of MOSFET switch Trying to understand the SPICE output for this basic MOSFET circuit:

The input (left) is a crude square wave:

A simple spice simulation shows the output voltage (right) as follows:

Why does the capacitor level off at 7V?  My thinking was that as it charges up, the current through the transistor would decrease until VDS = 0, and at that point the voltage across the capacitor would be 9V, but SPICE thinks differently.

A: nmos cuts off when \$V_{GS} \lt V_{th}\$, so the maximum voltage an nmos can "pass" is \$V_{DD}-V_{th}\$.
pmos cuts off when \$V_{GS} \gt -V_{th}\$, so the minimum voltage an pmos can "pass" is \$V_{SS}+V_{th}\$.


text:
Q: Flutter: Get the local position from the GestureDetector I'm using the GestureDetector to get this events using:
onHorizontalDragStart: _onDragStart,
onHorizontalDragUpdate: _onDragUpdate,

But how can I transform the global position into local? The child that is moved is a Container.

A: You can use a RenderObject and then transform the global positions into a local one similar to this simple example:
import "package:flutter/material.dart";

class Test extends StatefulWidget {
  @override
  _TestState createState() => new _TestState();
}

class _TestState extends State<Test> {
  _onDragStart(BuildContext context, DragStartDetails start) {
    print(start.globalPosition.toString());
    RenderBox getBox = context.findRenderObject();
    var local = getBox.globalToLocal(start.globalPosition);
    print(local.dx.toString() + "|" + local.dy.toString());
  }

  _onDragUpdate(BuildContext context, DragUpdateDetails update) {
    //print(update.globalPosition.toString());
    RenderBox getBox = context.findRenderObject();
    var local = getBox.globalToLocal(update.globalPosition);
    //print(local.dx.toString() + "|" + local.dy.toString());
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Center(
        child: new GestureDetector(
          child: new Text("Drag"),
          onHorizontalDragStart: (DragStartDetails start) =>
              _onDragStart(context, start),
          onHorizontalDragUpdate: (DragUpdateDetails update) =>
              _onDragUpdate(context, update),
        ),
      ),
    );
  }
}


text:
Q: New control in Form from another Class I have a class in the same file as the Form1 : Form class (directly proceeding) and would like to create a new control (label thisObj = new label();) from within the class. I tried to use the following code:
Form1 form = new Form1();
label thisObj = new label();
thisObj.Name = "One";
form.Controls.Add(thisObj);

However, when I do this, the form window doesn't load when starting the debugging.
EDIT: The line "Form1 form = new Form1()" causes the form not to load.

A: Try with:
this.Controls.Add(thisObj);

It will add the control to the current form.

A: To just add a control to the current Form, the code from Frederick is correct, like this:
var thisObj = new Label { Name = "One", Text = "Some Text" };
Controls.Add(thisObj);

It is normal that Form1 does not show, you never call the Show() method. If you want to show Form1 with the new Label added this is the code:
var form = new Form1();
var thisObj = new Label { Name = "One", Text = "Some Text" };
form.Controls.Add(thisObj);
form.Show();

The form that will be loaded by default in your WindowsForms application is defined in the file 'Program.cs':
Application.Run(new Form1);

A: I worked around this by sending an instance of the Form through the constructor of the class.