text:
Q: Python: Sorting incremented numbers based on values in a dictionary I just got something working, but realized I have a missing piece. I'm trying to get duplicate values in a dictionary, increment the numbers based on the number of duplicates (to leave one the same), but all based on an order (which is in reality a distance along a road).
Starting with a dictionary like this:
Deca_dict = {
    "1": "2_506",
    "2": "2_506",
    "3": "2_506",
    "4": "2_600",
    "5": "1_650",
    "6": "2_600"
}

With the help of an SO answer, I counted the number of occurrences and kept track of the original number i'm interested in incrementing:
decaAdd_occurrences = {k: (int(k.split('_')[0]), v) for k,v in
                                Counter(Deca_dict.values()).items()}

I adapted the answer's code like so:
changed_deca_dict = {}
alpha_deca_dict = {}
for key, value in Deca_dict.items():
    num, cnt = decaAdd_occurrences[value]
    if cnt > 1:
        route = value.split('_')[1]
        next_num = num + 1
        next_add = str(next_num) + '_' + str(route)
        if not next_add in Deca_dict.values():
            Deca_dict[key] = '{}_{}'.format(next_num, route)
            decaAdd_occurrences[value] = next_num, cnt-1
            changed_deca_dict[key] = '{}_{}_{}'.format(num, next_num, route)
        else:
            alpha_deca_dict[key] = value

This gives dictionaries:
Deca_dict -> {
    "1": "3_506",
    "2": "2_506",
    "3": "4_506",
    "4": "3_600",
    "5": "1_650",
    "6": "2_600"
}

changed_deca_dict = {'1':'2_3_506', '3':'2_4_506','4':'2_3_600'}

I have another dictionary with the same keys and their distances along an axis (the order in which I'm trying to number these values)
distance_dict = {'3': 1.0,'1': 2.2,'2': 3.1,'4': 2.0,'5': 1.5,'6': 3.0}

How can I either incorporate into the previous code or update Deca_dict like this:
Deca_dict -> {
    "1": "3_506",
    "2": "4_506",
    "3": "2_506",
    "4": "2_600",
    "5": "1_650",
    "6": "3_600"
}

I'm trying to start by grouping the keys by similar values. I don't want the whole value compared, so this is what I have so far:
for deca_key, deca_value in changed_deca_dict:
    old_num = value.split('_')[0]
    new_num = value.split('_')[1]
    route = value.split('_')[2]
    old_add = str(old_num) + str(route)
    for dist_key, dist_value in distance_dict:
        if dist_key == deca_key:
            check the distance and compare with other Deca_dict.items(), including the one that didn't change
            re-order new_num according to distance along route


text:
Q: Another service JAR is creating Spring's autoconfiguration (Error creating bean with name 'mongoTemplate') I have one Java spring boot application (call it utility service) and many other Java spring boot applications (call them as clients).
Both (utility service and clients) use Spring's autoconfiguration. When I am trying to put JAR of utility service into a client, after building the client, it is throwing error at bootrun. The error is:
Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]:
Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.data.mongodb.MongoDbFactory]: :
Error creating bean with name 'mongoDbFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]:
Unsatisfied dependency expressed through constructor argument with index 0 of type [com.mongodb.MongoClient]: :
Error creating bean with name 'mongo' defined in class path resource [org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.class]:
Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [com.mongodb.MongoClient]:
Factory method 'mongo' threw exception;
nested exception is java.lang.NoSuchMethodError:
org.bson.io.BasicOutputBuffer.<init>(I)V;

I can fix this problem by applying @EnableAutoConfiguration(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class}) in the client's Application.java.
But I have many such clients and I don't want to modify client's code (except it's build.gradle).
Is there any way from utility service to modify and achieve above?

A: You can try to exclude the class when you include the dependency in any of your clients. Once you exclude the mongoTemplate configuration class it should not appear in your classpath while building the client service code.
Hope this helps.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Display Div text on mouse hover using css I am new to css and ui designing.
Here's the case.
I have a div(divmain). Inside that divmain, I have an image and another div (sub_div). There are texts inside sub_div which I want to display on mouse hover, hidden otherwise using just css (no javascript/jquery).
Kindly suggest the approach I should follow.
Right now I am doing something like:
Html:

Some Text

Css:
.divmain .sub_div {
    height: 70px;
    opacity: 0;
    position: absolute;
    bottom: 0px;
    left: 0px;
    right: 0px;
    padding: 2px 0px;
    color: #ffffff;
    text-decoration: none;
    vertical-align: middle;
    text-align: center;
    -webkit-transition: opacity 500ms;
    -moz-transition: opacity 500ms;
    -o-transition: opacity 500ms;
    transition: opacity 500ms;
    margin-top: 35px;
    line-height: 70px;

}

.divmain:hover .sub_div {
    opacity: 0.8;
}

A: The Below Code should help you:

.divmain{
width: 200px;
}

.sub_div{
display:none; /* This code hides the text initially */
/* Your sub_div styles can go here*/
 }

.divmain:hover .sub_div{
  display:block; /*Here we are making the .sub_div visible on hover*/
}

Some Text

A: This should help you

Some Text

.divmain .sub_div {
      display: none;
}

.divmain:hover .sub_div {
    display: block;
}

Click to view CodePen


text:
Q: Keras- Loss per sample within batch How do I get the sample loss while training instead of the total loss? The loss history is available which gives the total batch loss but it doesn't provide the loss for individual samples.
If possible I would like to have something like this:
on_batch_end(batch, logs, **sample_losses**)

Is something like this available and if not can you provide some hints how to change the code to support this?

A: To the best of my knowledge it is not possible to get this information via callbacks since the loss is already computed once the callbacks are called (have a look at keras/engine/training.py). To simply inspect the losses you may override the loss function, e.g.:
def myloss(ytrue, ypred):
    x = keras.objectives.mean_squared_error(ytrue, ypred)
    return theano.printing.Print('loss for each sample')(x)

model.compile(loss=myloss)

A: Actually this can be done using a callback. This is now included in the keras documentation on callbacks. Define your own callback like this
class LossHistory(keras.callbacks.Callback):
    def on_train_begin(self, logs={}):
        self.losses = []

    def on_batch_end(self, batch, logs={}):
        self.losses.append(logs.get('loss'))

And then pass in this callback to your model. You should get per batch losses appended to the history ojbect.

A: I have also not found any existing functions in the Keras API that can return individual sample losses, while still computing on a minibatch. It seems you have to hack keras, or maybe access the tensorflow graph directly.

A: set batch size to 1 and use callbacks in model.evaluate OR manually calculate the loss between prediction (model.predict) and ground truth.


text:
Q: Code Review before checking in to TFS 2013 I'm trying to implement a process so that the manager can Review the
code of all developers before the developers can check in to TFS 2013.
Is there any process to require a review of the code by a human being before it is added to a real project?
I'm using TFS 2013 with Visual Studio 2013.

A: TFS 2013 supports this out of the box, and is very straight forward to use.
Developer needs to file a request for review in the team explorer:

*

*Go to Team Explorer

*Open pending changes

*Under "Actions" menu, choose Request Review

*Specify the reviewer, and send.

The target user (in your case, the manager) will get notified (if you've configured the Email settings on the TFS), and can also see the review requests in Team Explorer > My Work.
Reviewer can see all the changes made by the developer, comment on them, and send the comments to the developer. The whole thing happens inside Visual Studio, and all the comments are kept on TFS and can be reported later.
Also, upon completion of review, the reviewer can specify his/her opinion of the changes as "Looks Good", "With Comments" or "Needs Work".
Make sure you read this page on MSDN regarding this:
http://msdn.microsoft.com/en-us/library/hh474795.aspx
You can also check out this video on Channel 9:
http://channel9.msdn.com/Series/Visual-Studio-2012-Premium-and-Ultimate-Overview/Visual-Studio-Ultimate-2012-Using-Code-Review-to-Improve-Quality

EDIT
To prevent check-in without a review, you can use a check-in policy. Here's a custom check-in policy that requires code review before check-in:
https://visualstudiogallery.msdn.microsoft.com/c476b708-77a8-4065-b9d0-919ab688f078
But I should point out that check-in policies are not security mechanisms, think of them as a reminder for the developer to send the code for check-in. Developers can easily override them.
If you really need to prevent any check-ins, you should deny commit permission for developers, and have them send their changes to the manager using a code-review (or shelve set). The manager can then unshelve the changes and commit after reviewing.


text: Q: Flutter show marker's infoWindowText by default in Google map widget Can anyone suggest if there is a way of keeping infoWindowText showing when I open the Google map widget in Flutter (without having to click the marker first)? or a similar way of keeping a Text widget above a specific marker? Thanks in advance ~~


text:
Q: The straight line $L_1$ touches the curves $y^2=4x$ at $A$ and $x^2=4y$ at $B$ The straight line $L_1$ touches the curves $y^2=4x$ at $A$ and $x^2=4y$ at $B$.The straight line $L_2$ is normal to both the curves cutting the first curve at $C$ and $D$ and the second curve at $E$ and $F$.Find the area bounded by $L_1$ and the coordinate axes and the area bounded by $L_2$ and the coordinate axes.

This question is given in my book in the solved examples.Solution is like this.Since $x^2=4y$ and $y^2=4x$ are mirror images of each other in line $x=y$.Therefore the slopes of common tangent and common normal are $-1$ each.
I did not understand this line.Why the slopes of common tangent and common normal are $-1$ each?If this concept had been clear,rest of the solution is understandable.Please help me understand this concept.

A: Does it help to see the graphs?


text:
Q: My app crash when loading other xml layout I developed an android app. My app crash when I load another layout like this. I don't know how to explain it!!!! Please give me a keyword or everything to search and debug it!!
My app can launch and load main activity
logcat

                                                                         [ 03-27 06:37:57.264  1419: 1419 D/         ]
                                                                         HostConnection::get() New Host Connection established 0xb8073fa8, tid 1419
03-27 06:37:57.272 1419-1419/com.xuanlocfashion.xuanlocfashion D/libEGL: loaded /system/lib/egl/libGLESv1_CM_genymotion.so
03-27 06:37:57.272 1419-1419/com.xuanlocfashion.xuanlocfashion D/libEGL: loaded /system/lib/egl/libGLESv2_genymotion.so
03-27 06:37:57.336 1419-1419/com.xuanlocfashion.xuanlocfashion W/EGL_genymotion: eglSurfaceAttrib not implemented
03-27 06:37:57.336 1419-1419/com.xuanlocfashion.xuanlocfashion E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache
03-27 06:37:57.336 1419-1419/com.xuanlocfashion.xuanlocfashion E/OpenGLRenderer: MAX_TEXTURE_SIZE: 16384
03-27 06:37:57.348 1419-1419/com.xuanlocfashion.xuanlocfashion E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
03-27 06:37:57.352 1419-1419/com.xuanlocfashion.xuanlocfashion E/OpenGLRenderer: MAX_TEXTURE_SIZE: 16384
03-27 06:37:57.352 1419-1419/com.xuanlocfashion.xuanlocfashion D/OpenGLRenderer: Enabling debug mode 0
03-27 06:38:00.036 1419-1419/com.xuanlocfashion.xuanlocfashion I/Choreographer: Skipped 69 frames!  The application may be doing too much work on its main thread.
03-27 06:38:05.540 1419-1419/com.xuanlocfashion.xuanlocfashion D/AndroidRuntime: Shutting down VM
03-27 06:38:05.540 1419-1419/com.xuanlocfashion.xuanlocfashion W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4d5eb20)
03-27 06:38:05.540 1419-1419/com.xuanlocfashion.xuanlocfashion E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: com.xuanlocfashion.xuanlocfashion, PID: 1419
                                                                                java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xuanlocfashion.xuanlocfashion/com.xuanlocfashion.xuanlocfashion.DatLichHenActivity}: java.lang.NullPointerException
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
                                                                                at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:136)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5001)
                                                                                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:785)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                                at dalvik.system.NativeStart.main(Native Method)
                                                                                Caused by: java.lang.NullPointerException
                                                                                at com.xuanlocfashion.xuanlocfashion.DatLichHenActivity.intentButton(DatLichHenActivity.java:189)
                                                                                at com.xuanlocfashion.xuanlocfashion.DatLichHenActivity.onCreate(DatLichHenActivity.java:50)
                                                                                at android.app.Activity.performCreate(Activity.java:5231)
                                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
                                                                                at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:136)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5001)
                                                                                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:785)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                                at dalvik.system.NativeStart.main(Native Method)

package com.xuanlocfashion.xuanlocfashion;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

    Button buttonDatDichVu;
    Button buttonGioiThieu;
    ImageView imvSuaQuanAo;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        buttonDatDichVu = (Button)findViewById(R.id.buttonDatDichVu);
        buttonGioiThieu = (Button)findViewById(R.id.buttonGioiThieu);
        imvSuaQuanAo = (ImageView)findViewById(R.id.imvSuaQuanAo);
        intentButton();

    }

    protected void openDatDichVu(){
        Intent myIntent = new Intent(this, DatLichHenActivity.class);
        startActivity(myIntent);
    }
    protected void openGioiThieu(){
        Intent myIntent = new Intent(this, GioiThieuActivity.class);
        startActivity(myIntent);
    }
    protected void openSuaQuanAo(){
        Intent myIntent = new Intent(this, SuaQuanAoActivity.class);
        startActivity(myIntent);
    }

    protected void intentButton(){
        buttonDatDichVu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                openDatDichVu();
            }
        });
        buttonGioiThieu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                openGioiThieu();
            }
        });
        imvSuaQuanAo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                openSuaQuanAo();
            }
        });
    }

}

y layout.
Thanks so much!
//ps
Nothing in logcat,

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_datlichhen"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.xuanlocfashion.xuanlocfashion.DatLichHenActivity">

    <CheckBox
        android:text="Giặt sấy tận nơi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="21dp"
        android:id="@+id/checkBoxGiatUi"
        android:layout_below="@+id/textView6"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <CheckBox
        android:text="Sửa quần áo tận nơi"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/checkBoxSuaQuanAo"
        android:layout_alignBaseline="@+id/checkBoxGiatUi"
        android:layout_alignBottom="@+id/checkBoxGiatUi"
        android:layout_toRightOf="@+id/textView6"
        android:layout_toEndOf="@+id/textView6" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:hint="Tên của bạn"
        android:ems="10"
        android:layout_below="@+id/checkBoxGiatUi"
        android:layout_marginTop="22dp"
        android:id="@+id/editTextHoTen"
        android:singleLine="false"
        android:selectAllOnFocus="false"
        android:maxLength="15"
        android:textColor="@color/colorAccent"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="70dp"
        app:srcCompat="@drawable/hotline"
        android:id="@+id/imageViewGoiNgay"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_centerHorizontal="false"
        android:layout_centerVertical="false"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentTop="false"
        android:layout_alignWithParentIfMissing="true"
        android:layout_centerInParent="false" />

    <TextView
        android:text="Đặt lịch hẹn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="30dp"
        android:textColor="@color/colorPrimary"
        android:id="@+id/textView5"
        android:layout_marginTop="40dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <TextView
        android:text="Bạn muốn sử dụng dịch vụ gì?"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="25dp"
        android:id="@+id/textView6"
        android:layout_below="@+id/textView5"
        android:layout_alignParentStart="true" />

    <Button
        android:text="Đặt ngay"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/buttonDatNgay"
        android:textSize="30dp"
        android:layout_weight="0.16"
        android:textColor="@color/colorAccent"
        android:gravity="center"
        android:layout_above="@+id/imageViewGoiNgay"
        android:layout_alignParentStart="true" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Địa chỉ"
        android:inputType="textPersonName"
        android:ems="10"
        android:textSize="8pt"
        android:id="@+id/edtDiaChi"
        android:layout_below="@+id/editTextSoDienThoai"
        android:layout_alignParentStart="true" />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="phone"
        android:ems="10"
        android:id="@+id/editTextSoDienThoai"
        android:hint="Số điện thoại"
        tools:maxLength="13"
        android:textColor="@color/colorAccent"
        android:layout_below="@+id/editTextHoTen"
        android:layout_alignParentStart="true" />

    <TextView
        android:text="Bạn muốn sửa sản phẩm gì?"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20dp"

        android:id="@+id/textView4"
        android:layout_alignBaseline="@+id/btnChonLoaiDo"
        android:layout_alignBottom="@+id/btnChonLoaiDo"
        android:layout_alignParentStart="true" />

    <Button
        android:text="Chọn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/btnChonLoaiDo"
        android:layout_marginBottom="19dp"
        android:layout_above="@+id/buttonDatNgay"
        android:layout_toEndOf="@+id/textView4" />

</RelativeLayout>

package com.xuanlocfashion.xuanlocfashion;

import android.Manifest;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;

public class DatLichHenActivity extends AppCompatActivity {

    CheckBox checkBoxGiatUi;
    CheckBox checkBoxSuaQuanAo;
    EditText editTextHoTen;
    EditText editTextSoDienThoai;
    Button buttonDatNgay;
    ImageView imageViewGoiNgay;
    SmsManager sms;
    String hotlineXuanLocFashion1 = "0908418036";
    String hotlineXuanLocFashion2 = "0936208806";
    String smsMessage;
    Button btnChonLoaiDo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dat_lich_hen);
        AnhXa();
        GuiMessage();
        imageViewGoiNgay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                call();
            }
        });
        intentButton();
    }

    private void GuiMessage() {
        sms = SmsManager.getDefault();
        smsMessage = editTextHoTen.getText().toString() + " " + editTextSoDienThoai.getText().toString() + " " + " ";
        buttonDatNgay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (checkBoxGiatUi.isChecked()) {
                    smsMessage += "(GU)";
                }
                if (checkBoxSuaQuanAo.isChecked())
                    smsMessage += "(SQA)";
                dialogDatLichHen();
            }
        });
    }
    private void AnhXa() {
        checkBoxGiatUi = (CheckBox) findViewById(R.id.checkBoxGiatUi);
        checkBoxSuaQuanAo = (CheckBox) findViewById(R.id.checkBoxSuaQuanAo);
        editTextHoTen = (EditText) findViewById(R.id.editTextHoTen);
        editTextSoDienThoai = (EditText) findViewById(R.id.editTextSoDienThoai);
        buttonDatNgay = (Button) findViewById(R.id.buttonDatNgay);
        imageViewGoiNgay = (ImageView) findViewById(R.id.imageViewGoiNgay);
    }
    protected void call() {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + hotlineXuanLocFashion1));//change the number
        if (ActivityCompat.checkSelfPermission(DatLichHenActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }
        if (ActivityCompat.checkSelfPermission(DatLichHenActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }
        startActivity(callIntent);
    }
    protected void sendSMS(String phoneNumber, String message) {
        String SENT = "SMS_SENT";
        String DELIVERED = "SMS_DELIVERED";

        PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
        PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);

        //---when the SMS has been sent---
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        // SMS sent

                        break;
                    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                        // SMS fail without reason

                        break;
                    case SmsManager.RESULT_ERROR_NO_SERVICE:
                        // No service

                        break;
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                        // Null PDU

                        break;
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                        // Radio off

                        break;
                }
            }
        }, new IntentFilter(SENT));

        //---when the SMS has been delivered---
        registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context arg0, Intent arg1) {
                switch (getResultCode()) {
                    case Activity.RESULT_OK:
                        // SMS delivered"

                        break;
                    case Activity.RESULT_CANCELED:
                        // SMS not delivered

                        break;
                }
            }
        }, new IntentFilter(DELIVERED));

        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
    }
    protected void dialogDatLichHen() {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
        // khởi tạo dialog
        alertDialogBuilder.setMessage("Đặt lịch hẹn ngay.");
        // thiết lập nội dung cho dialog
        alertDialogBuilder.setPositiveButton("Đồng ý", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                sendSMS(hotlineXuanLocFashion1, smsMessage);
                sendSMS(hotlineXuanLocFashion2, smsMessage);

            }
        });

        alertDialogBuilder.setNegativeButton("Không", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                // button "no" ẩn dialog đi
            }
        });

        AlertDialog alertDialog = alertDialogBuilder.create();
        // tạo dialog
        alertDialog.show();
        // hiển thị dialog
    }
    protected void openChonLoaiDo(){
        Intent myIntent = new Intent(this, ChonLoaiDoActivity.class);
        startActivity(myIntent);
    }
    protected void intentButton(){
        btnChonLoaiDo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                openChonLoaiDo();
            }
        });
    }
}

A: I try to dry run your code in your DatLichHenActivity.java may be you forget to get the view of the  Button btnChonLoaiDo; so it generate the null object reference there.


text:
Q: print numbers from 200 to 150 in reverse order and print numbers from 200 to 150 in a sequential order using while? how to print numbers from 200 to 150 in reverse order and print numbers from 200 to 150 in a sequential order using single while loop?
class test {
    public static void main(String[]args) {
        while(n>=150) {
            System.out.println(n);
            n--;
        }
        n=0;
        while(n<=150) {
            System.out.println(n);
            n++;
        }
    }
}

A: Here you go:
public static void main(String[] args) {
    int n = 150;
    while(n <= 200) {
        System.out.println("Decreasing : " + (150 + (200 - n)));
        System.out.println("Increating : " + (n++));
    }
}


text:
Q: wordpress file upload with ajax when site is ajaxyfi I am getting problem in upload any file. My word press site is using Ajax Page Loader Plugin.So page is not refreshing when the form is submitting..
I am not getting any value in PHP code in functions.php in print_r($_FILES);
But when i am printing any string with echo(); it is printing but why print_r($_FILES); is not getting any value.
HTML form
<form id="career_form" name="career_form" enctype="multipart/form-data">

    Upload : <input id="career_resume" class="field" style="height: 25px;" type="file" name="career_resume" multiple />
    <input type="hidden" name="action" value="career" />
    <input id="submit_button" onclick="submit_career();" type="button" value="Send" />
</form>

j Query
function submit_career()
{
    jQuery.post(the_ajax_career.ajaxurl_career,
        jQuery("#career_form").serialize(),
            function(response_from_the_action_function){
                jQuery("#errfrmMsg").html(response_from_the_action_function).css({"display":"block"});
            }
        );
}

Php code in functions.php
wp_register_script("ajax-career", get_bloginfo('template_directory')."/js/custom_js.js", array( "jquery"));
    wp_enqueue_script('ajax-career');
    wp_localize_script("ajax-career","the_ajax_career", array("ajaxurl_career" => admin_url("admin-ajax.php")));
    // add actions
    add_action( "wp_ajax_career", "ajax_action_career" );
    add_action( "wp_ajax_nopriv_career", "ajax_action_career" );

    function ajax_action_career(){

        //Nothing getting in this print_r($_FILES) function;

        foreach ($_FILES["career_resume"]["error"] as $key => $error) {
            if ($error == UPLOAD_ERR_OK) {
                $name = $_FILES["career_resume"]["name"][$key];
                move_uploaded_file( $_FILES["career_resume"]["tmp_name"][$key], "uploads/" . $_FILES['career_resume']['name'][$key]);
            }
        }
    }


text:
Q: NatTable filtering row header layer for dynamic list When I use dynamic list for Nattable the filtering via filter header layer it does not work for me.
I want to be able to filter all columns. I have respective code for each column in the filter row configuration class and it works if the input is a static list.
Attached my code snippet:
public Control createPeopleTable(Composite parent) {
    // create a new ConfigRegistry which will be needed for GlazedLists
    configRegistry = new ConfigRegistry();
    peopleTableColumns = PeopleTableColumnDefinition.getPeopleTableColumns();

    final Map<String, String> propertyToLabelMap = new HashMap<>();
    final String[] propertyNames = new String[peopleTableColumns.size()];
    for (int i = 0; i < peopleTableColumns.size(); ++i) {
        final PeopleTableColumnDefinition col = peopleTableColumns.get(i);
        propertyNames[i] = col.getProperty();
        propertyToLabelMap.put(propertyNames[i], col.getDisplayName());
    }

    columnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor<>(propertyNames);columnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor<>(propertyNames);

    peopleList = new ArrayList<>();
    eventList = GlazedLists.eventList(peopleList);
    dynamicValues = GlazedLists.threadSafeList(eventList);
    bodyLayerStack = new BodyLayerStack(dynamicValues, columnPropertyAccessor);
    .....

    IFilterStrategy<People> filterStrategy = new DefaultGlazedListsFilterStrategy<>(
            bodyLayerStack.getFilterList(), columnPropertyAccessor, configRegistry);
    // Note: The column header layer is wrapped in a filter row composite.
    // This plugs in the filter row functionality
    FilterRowHeaderComposite<People> filterRowHeaderLayer = new FilterRowHeaderComposite<>(filterStrategy,
            sortHeaderLayer, bodyLayerStack.getBodyDataProvider(), configRegistry);

    // build the row header layer
    IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyLayerStack.getBodyDataProvider());
    DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
    ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, bodyLayerStack,
            bodyLayerStack.getSelectionLayer());

    // build the corner layer
    IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider,
            rowHeaderDataProvider);
    DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
    cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, filterRowHeaderLayer);

    // build the grid layer
    GridLayer gridLayer = new GridLayer(bodyLayerStack, filterRowHeaderLayer, rowHeaderLayer, cornerLayer);

    // turn the auto configuration off as we want to add our header menu
    // configuration
    natTable = new NatTable(parent, gridLayer, false);

    .....

    natTable.addConfiguration(new FilterRowConfiguration());
    natTable.configure();
    ...

    return natTable;

}
    class FilterRowConfiguration extends AbstractRegistryConfiguration {

    @Override
    public void configureRegistry(IConfigRegistry configRegistry) {

        // register the FilterRowTextCellEditor in the first column which
        // immediately commits on key press
        configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new FilterRowTextCellEditor(),
                DisplayMode.NORMAL, FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX
                        + PeopleTableColumnDefinition.Name.columnIndex());

        .....
    }

    class BodyLayerStack extends AbstractLayerTransform {

    private FilterList<People> filterList;
    private final SelectionLayer selectionLayer;
    private SortedList<People> sortedList;
    private ViewportLayer viewportLayer;

    public BodyLayerStack(EventList<People> values,
            IColumnPropertyAccessor<People> columnPropertyAccessor) {

        // use the SortedList constructor with 'null' for the Comparator
        // because the Comparator
        // will be set by configuration
        sortedList = new SortedList<>(values, null);
        // wrap the SortedList with the FilterList
        filterList = new FilterList<>(sortedList);

        peopleListDataProvider = new PeopleListDataProvider<>(filterList, columnPropertyAccessor);
        bodyDataLayer = new DataLayer(peopleListDataProvider);

        final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(
                bodyDataLayer);
        for (int i = 0; i < peopleTableColumns.size(); i++) {
            PeopleTableColumnDefinition peopleTableColumnDefinition = peopleTableColumns.get(i);
            columnLabelAccumulator.registerColumnOverrides(i, peopleTableColumnDefinition.getTableLabel());
        }
        bodyDataLayer.setConfigLabelAccumulator(columnLabelAccumulator);

        // layer for event handling of GlazedLists and PropertyChanges
        GlazedListsEventLayer<People> glazedListsEventLayer = new GlazedListsEventLayer<>(bodyDataLayer,
                filterList);

        selectionLayer = new SelectionLayer(glazedListsEventLayer);
        viewportLayer = new ViewportLayer(selectionLayer);
        FreezeLayer freezeLayer = new FreezeLayer(selectionLayer);
        compositeFreezeLayer = new CompositeFreezeLayer(freezeLayer, viewportLayer, selectionLayer);
        setUnderlyingLayer(compositeFreezeLayer);
    }

    public SortedList<People> getSortedList() {
        return sortedList;
    }

    public SelectionLayer getSelectionLayer() {
        return this.selectionLayer;
    }

    public FilterList<People> getFilterList() {
        return this.filterList;
    }

    public PeopleListDataProvider<People> getBodyDataProvider() {
        return peopleListDataProvider;
    }
}

public void setListOfPeople(List<People> listOfPeople) {

    this.eventList.getReadWriteLock().writeLock().lock();
    this.dynamicValues.getReadWriteLock().writeLock().lock();
    try {
        peopleList.clear();
        eventList.clear();
        dynamicValues.clear();
        peopleList.addAll(listOfPeople);
        eventList.addAll(listOfPeople);
        dynamicValues.addAll(listOfPeople);
        peopleListDataProvider.setPeopleList(peopleList);
    } finally {
        eventList.getReadWriteLock().writeLock().unlock();
        dynamicValues.getReadWriteLock().writeLock().unlock();
    }
}

A: It seems you haven't understood the principles of GlazedLists and Java object references.
First you don't have to call clear() and addAll() on all lists. The GlazedLists are views on the base list, so it should be enough to call on the EventList or a higher list like the FilterList.
Second mistake is that you set another list on the IDataProvider. And that list is not the FilterList. So actually you disable the filter as the FilterList is doing the filter magic. And setting the list is not necessary as you performed a list modification. So why changing it then?


text:
Q: Get same json data to root I have a json data like in the block below.
Same data are "id", "ip", "port", "name" and "mac_id" .
Difference data are "cam_id","dvr_analog_channel" and "cam _name".
[
    {
        "id": 76,
        "ip": "1.1.1.1",
        "port": 5000,
        "name": "Server",
        "mac_id": "asdasdaad121",
        "cam_id": 15363,
        "dvr_analog_channel": 33,
        "cam_name": "IP Channel 33"
    },
    {
        "id": 76,
        "ip": "1.1.1.1",
        "port": 5000,
        "name": "Server",
        "mac_id": "asdasdaad121",
        "cam_id": 15364,
        "dvr_analog_channel": 34,
        "cam_name": "IP Channel 34"
    },
    {
        "id": 76,
        "ip": "1.1.1.1",
        "port": 5000,
        "name": "Server",
        "mac_id": "asdasdaad121",
        "cam_id": 15365,
        "dvr_analog_channel": 35,
        "cam_name": "IP Channel 35"
    }
]

I want to above json data like this to JavaScript.
[
    {
        "id": 76,
        "serverIp": "1.1 1

1",
"serverPort": 5000,
"serverName": "Server",
"serverMacId": "asdasdaad121",
"channels": [
{
"id": 15274,
"channelNo": 33,
"name": "IP Channel 33"
},
{
"id": 12363,
"channelNo": 34,
"name": "IP Channel 34"
},
{
"id": 15323,
"channelNo": 35,
"name": "IP Channel 35"
}
]
}
]
How to convert this json?

A: const data = [
    {
        "id": 76,
        "ip": "159.146.00.11",
        "port": 5000,
        "name": "Server",
        "mac_id": "asdasdaad121",
        "cam_id": 15363,
        "dvr_analog_channel": 36,
        "cam_name": "IP Channel 34"
    },
    {
        "id": 76,
        "ip": "159.146.00.11",
        "port": 5000,
        "name": "Server",
        "mac_id": "asdasdaad121",
        "cam_id": 15364,
        "dvr_analog_channel": 35,
        "cam_name": "IP Channel 35"
    },
    {
        "id": 76,
        "ip": "159.146.00.11",
        "port": 5000,
        "name": "Server",
        "mac_id": "asdasdaad121",
        "cam_id": 15365,
        "dvr_analog_channel": 36,
        "cam_name": "IP Channel 36"
    }
]

my solution here we go
const result = data.reduce((accumulator, current) => {
  if (accumulator?.length === 0) {
    accumulator[0] = {
      id: current.id,
      ip: current.ip,
      port: current.port,
      name: current.name,
      mac_id: current.mac_id,
      nestedJson: [
        {
          cam_id: current.cam_id,
          dvr_analog_channel: current.dvr_analog_channel,
          cam_name: current.cam_name,
        },
      ],
    };
  } else {
    const index = accumulator.findIndex(
      (item) => item.mac_id === current.mac_id
    );
    if (index !== -1) {
      accumulator[index].nestedJson.push({
        cam_id: current.cam_id,
        dvr_analog_channel: current.dvr_analog_channel,
        cam_name: current.cam_name,
      });
    } else {
        accumulator[accumulator.length] = {
      id: current.id,
      ip: current.ip,
      port: current.port,
      name: current.name,
      mac_id: current.mac_id,
      nestedJson: [
        {
          cam_id: current.cam_id,
          dvr_analog_channel: current.dvr_analog_channel,
          cam_name: current.cam_name,
        },
      ],
    };
    }
  }
  return accumulator;
}, []);

result will be
[
    {
        "id": 76,
        "ip": "159.146.00.11",
        "port": 5000,
        "name": "Server",
        "mac_id": "asdasdaad121",
        "nestedJson": [
            {
                "cam_id": 15363,
                "dvr_analog_channel": 36,
                "cam_name": "IP Channel 34"
            },
            {
                "cam_id": 15364,
                "dvr_analog_channel": 35,
                "cam_name": "IP Channel 35"
            },
            {
                "cam_id": 15365,
                "dvr_analog_channel": 36,
                "cam_name": "IP Channel 36"
            }
        ]
    }
]

A: Here is another way to achieve the result:

const data = [{
    id: 76,
    ip: '159.146.00.11',
    port: 5000,
    name: 'Server',
    mac_id: 'asdasdaad121',
    cam_id: 15363,
    dvr_analog_channel: 36,
    cam_name: 'IP Channel 34',
  },
  {
    id: 76,
    ip: '159.146.00.11',
    port: 5000,
    name: 'Server',
    mac_id: 'asdasdaad121',
    cam_id: 15364,
    dvr_analog_channel: 35,
    cam_name: 'IP Channel 35',
  },
  {
    id: 76,
    ip: '159.146.00.11',
    port: 5000,
    name: 'Server',
    mac_id: 'asdasdaad121',
    cam_id: 15365,
    dvr_analog_channel: 36,
    cam_name: 'IP Channel 36',
  },
]

const result = data.reduce((a, c) => {
  const { cam_id, dvr_analog_channel, cam_name, ...rest } = c
  const cameras = { cam_id, dvr_analog_channel, cam_name }
  const exist = a.find(obj => obj.id === c.id)

  if (exist) {
    if (exist.channels) exist.channels.push(cameras)
    else exist.channels = [cameras]
  } else {
    a.push({ ...rest, channels: [cameras] })
  }

  return a
}, [])

console.log(JSON.stringify(result, null, 2))


text:
Q: Quick way to sqrt squared values in Tensorflow I have the following code
a = tf.constant([3.0, 8.1])
squared_sum = tf.math.reduce_sum(tf.math.square(a))
sqrt = tf.math.sqrt(squared_sum)

Something obvious such us sqrt(3.0**2 + 8.1**2) has to be made in 3 steps (square, reduce_sum and sqrt). Is there any other faster way in Tensorflow?


text:
Q: How to manage overlaying polygons and empty space inside a map? I have a map of provinces, but the file is not so good. there are a lot of white space and overlapping provinces. I don't care about the correctness of the map. I need to somehow deal with the overlapping issue and then fill the white space.
for the overlapping again I just need to keep one province and clip the other( the precision of the map is not important).
for the white space, one province could be chosen to fill up. no matter which.
Do you have any idea to handle these two problems?


text:
Q: Is it possible to have more than one parse client configured in a single app? So I have a few different parse servers setup.
One server is just to capture error logs from various applications (I have a LOT out there) in nice uniformed database.
So I might have a specific standalone data migration tool that if it encounters an error, will write out the exception into this Error_log parse table/class. No problem there.
But, if I have an app that uses a Parse Database for itself, I have not been able to figure out how to let it work on it's own parse server configuration for it's own stuff, but write out error logs to this other Parse server instance.
Yes...  I could go through the trouble of writing out something via the REST api just for writing out logs,but I am I trying to avoid that and stick with native parse APIs for the particular platform I am on because of the benefits that the APIs give over REST (like save eventually for the none .NET stuff).
EDIT
Some clarification was requested so here I go...
On the app side of things (c# for this example but the same holds true for iOS etc)… I do the usual initialization of the Parse client as such …
                ParseClient.Initialize(new ParseClient.Configuration
                {
                    ApplicationId =  "MyAppID",
                    WindowsKey = "MyDotNetKey",
                    Server = "www.myparseserver.com/app1"
                });

So for all calls to save a parse object go through that parse client connection
But what I need to do would be something like this ….
//Main App cloud database
                ParseClient1.Initialize(new ParseClient.Configuration
                {
                    ApplicationId =  "MyAppID",
                    WindowsKey = "MyDotNetKey",
                    Server = "www.myparseserver.com/app1"
                });

                ParseClient2.Initialize(new ParseClient.Configuration
                {
                    ApplicationId =  "MyAppID",
                    WindowsKey = "MyDotNetKey",
                    Server = "www.myparseserver.com/errorcollection"
                });

try{
                ParseConfig config = null;
                config = await ParseConfig.GetAsync().ParseClient1;
} catch (Exception ex){
   ParseObject MyError = new ParseObject("Error_Log");

   MyError["Application"] = "My First App-App2";
   MyError["Error"] = ex.message;
   await MyError.Save().ParseClient2;

}

Yes - this is all fake code... my point is I want to be able to have multiple ParseClient instances in one app.
Now... I can simply write a routine that writes out errors that resets the ParseClient.Initialization to the error parse server instance and then redo it back to the original (primary app data) instance when it's done... but that is just asking for trouble in a multi threaded environment and will cause conflicts if some other thread in the app goes to write out parse data right at the moment the error method resets the init.
If ParseClient were IDisposable I could probably do that using :

ParseClient ParseErrorServer = new ParseClient();
ParseErrorServer.ApplicationId = "hmmm";
ParseErrorServer.WindwosKey= "hmmm";
ParseErrorServer.Server= "www.hmmm.com/errorcollection";

using ParseErrorServer {

   //Do The Work

}

Is that clear as mud yet? ;P

A: Without alteration I believe none of the Parse SDKs have the ability to initialise multiple instances.
In the iOS SDK for example, is possible to make a new instance (say with a different server url) upon restarting the app but you cannot have multiple. There has also been discussion on the iOS SDK about being able to change the configuration without restart but no one has implemented this yet.
We would happily review a PR for this, however it would require a major and complex overhaul as you would have to manage cache, users etc across multiple instances.


text:
Q: Analog of spring @Controller annotation in Java config In Spring DI I love to use @Bean with factory method in @Configuration class instead of using @Component annotation explicitly. Is there a way to do the same with @Controller annotation for Spring Web? In another words, could I declare controller via factory method in some @Configuration class instead of explicit annotation?

A: Thats not possible since @Controller can only be placed on types. But more important are the methods. I assume you have multiple methods with @RequestMethod annotations. You can place as much methods as you like in this controller with differnet paths. Which should end up in around the same thing as you want?


text:
Q: Why is only the last object's function getting called here? Wow. I finally figured about what is causing the bug, but I can't figure out why. I have an object with a property (excuse the massive code dump)
    // relatives second indices in the video to events
    // that are called when the video reaches that second
    this.PausePoints = [
        {
            sec: 10,
            name: "Point number 1",
            passed: false,
            func: (function(that) {

                this.$layer = that.GetLayerElement(10);
                this.$layer.hide();

                this.to = function () {
                    that.videlem.pause(); // pause video
                    $(window).resize(); // re-proportion stuff
                    // point the 3 mouse pointers
                    var $mptrs = this.$layer.find('.filmstrip-pointer');
                    for (var i = 0; i < $mptrs.length; ++i) {
                        (function (j) {
                            setTimeout(function () {
                                Point($mptrs.eq(j));
                            }, j * 1000);
                        })(i);
                    }
                };

                // attach click event to 3 sections
                $clickRegions = $layer.find('div.click-region');
                $clickRegions.click(function(){
                    $clickRegions.removeClass('clicked');
                    $(this).addClass('clicked');
                });

                this.away = function () {
                    this.$layer.hide();
                }

                // attach event to next button
                $layer.find('.next-btn').click(function(){
                    this.away();
                    that.videlem.play();
                }.bind(this));

                return this;

            })(this)
        },
        {
            sec: 26,
            name: "Point number 2",
            passed: false,
            func: (function(that) {

                this.$layer = that.GetLayerElement(26);
                this.$layer.hide();

                this.to = function () {

                    // loop video between 0:26-0:31
                    this.loop = setInterval(function () {
                        that.videlem.currentTime = 26;
                        that.videlem.play();
                    }, 5000);

                    // point the 3 mouse pointers
                    var $mptrs = this.$layer.find('.filmstrip-pointer');
                    for (var i = 0; i < $mptrs.length; ++i) {
                        (function (j) {
                            setTimeout(function () {
                                Point($mptrs.eq(j));
                            }, j * 1000);
                        })(i);
                    }

                    this.$layer.show();

                }

                // separate pargraph words by spans
                this.$layer.find('p').each(function () {
                    var spanned = $(this).text().split(" ").map(function (w) { return '' + w + ''; }).join(" ");
                    $(this).html(spanned);
                });

                // add event click event on headlines
                var timeouts = [];
                this.$layer.find('h3').click(function () {
                    // clear any current 'showing' animations
                    timeouts.forEach(function(t){ clearTimeout(t); });
                    timeouts = [];
                    // unshow all words on the slide
                    this.$layer.find('span.word').removeClass('shown');
                    // show all words associated with the headline that was clicked
                    var $wspans = $(this).closest('.tower-layer').find('span.word');
                    for ( var i = 0; i < $wspans.length; ++i )
                    {
                        (function(j){
                            timeouts.push(setTimeout(function(){
                                $wspans.eq(j).addClass('shown');
                            },j*100));
                        })(i);
                    }
                }.bind(this));

                this.away = function () {
                    clearInterval(this.loop);
                    this.$layer.find('span.word').removeClass('shown');
                    $layer.hide();
                    that.videlem.currentTime = 31;//go to end of loop
                };

                // set action of "Next" button
                this.$layer.find('.next-btn').click(function () {
                    this.away();
                    that.videlem.play();
                }.bind(this));

                return this;

            })(this)
        },
        {
           sec: 38,
           name: "Point number 3",
           passed: false,
           func: (function(that) {

               this.$layer = that.GetLayerElement(38);
               this.$layer.hide();

               this.to = function ( ) {
                   // loop video between 0:38-0:43
                   this.loop = setInterval(function () {
                       that.videlem.currentTime = 38;
                       that.videlem.play();
                   }, 5000);

                   this.$layer.show();
               }

               this.away = function(){
                   clearInterval(this.loop);
                   this.$layer.hide();
               };

               this.$layer.find('.next-btn').click(function(){
                   that.videlem.currentTime = 43;
                   this.away();
                   that.videlem.play();
               }.bind(this));

               return this;

           })(this)
        },
        {
            sec: 47,
            name: "Point number 4",
            passed: false,
            func: (function(that){

                this.$layer = that.GetLayerElement(47);
                this.$layer.hide();

                this.to = function ()
                {
                    // loop video between 0:47-0:52
                    this.loop = setInterval(function() {
                        that.videlem.currentTime = 47;
                        that.videlem.play();
                    }, 5000);
                    // show layer
                    this.$layer.show();
                }

                this.away = function () {
                    clearInterval(this.loop);
                    this.$layer.hide();
                };

                this.$layer.find('.next-btn').click(function () {
                    that.videlem.currentTime = 52;
                    this.away();
                    that.videlem.play();
                }.bind(this));

                return this;

            })(this)
        },
        {
            sec: 57,
            name: "Point number 5",
            passed: false,
            func: (function(that){

                this.$layer = that.GetLayerElement(57);
                // hide initially
                this.$layer.hide();

                this.to = function ()
                {
                    // loop video between 0:57-1:02
                    this.loop = setInterval(function () {
                        that.videlem.currentTime = 57;
                        that.videlem.play();
                    }, 5000);

                    this.$layer.show();
                }

                this.away = function(){
                    clearInterval(this.loop);
                    $layer.hide();
                };

                this.$layer.find('.next-btn').click(function () {
                    that.videlem.currentTime = 62;
                    this.away();
                    that.videlem.play();
                }.bind(this));

                return this;

            })(this)
        }
    ];

and what I'm noticing is that when I try to call any of the to functions it always calls the one in the last element of the array.
For example,
VidHandler.PausePoints[0].func.to()

calls
                this.to = function ()
                {
                    // loop video between 0:57-1:02
                    this.loop = setInterval(function () {
                        that.videlem.currentTime = 57;
                        that.videlem.play();
                    }, 5000);

                    this.$layer.show();
                }

instead of the expected
                this.to = function () {
                    that.videlem.pause(); // pause video
                    $(window).resize(); // re-proportion stuff
                    // point the 3 mouse pointers
                    var $mptrs = this.$layer.find('.filmstrip-pointer');
                    for (var i = 0; i < $mptrs.length; ++i) {
                        (function (j) {
                            setTimeout(function () {
                                Point($mptrs.eq(j));
                            }, j * 1000);
                        })(i);
                    }
                };

Why is this happening and how can I fix it?

A: The problem is you're trying to assign something to func using an immediately invoked function expression (IIFE). Those IIFEs are executed before the object is constructed, meaning this refers to something else. Your code can basically be broken down like this:
this.to = function() {
  // version for "Point number 1"
};
this.to = function() {
  // version for "Point number 2"
  // notice that you're overwriting the previous one
};

// repeat for all points

var self = this;
this.PausePoints = [
  {
    name: "Point number 1",
    func: self
  },
  // repeat for all points
];

So what you're actually doing is assigning a to value to the same object that has the PausePoints property.


text:
Q: Merging in multiple XML sources in XSLT by calling java methods I know it's possible to create java objects and call methods from XSLT.  If the method I'm calling returns a DOM document is it possible to merge that into the XML document being processed?

A: The way external calls from XSLT to Java behave depends entirely on the XSLT processor you are using - it's not defined in the standard. I would expect the answer is yes - the DOM document will be made visible as a node and can be processed like any other node (for exmaple, it can be copied to the result tree using xsl:copy-of) - but you can only ask the question in relation to a specific XSLT processor.


text:
Q: Laravel / Validation does not work with my file input? Can't figure out why.... Validator either rejects all my files as not being images or lets them all go through...
Here is the form:

<form action="{{ URL::route('photographer-gallery-upload-post') }}" method="POST" enctype="multipart/form-data">

                Add files...
                <input type="file" name="file[]" multiple>

            @if ($errors->has('file'))

                    {{ $errors->first('file') }}

            @endif

And my verification:
    public function postPhotographerGalleryUpload() {

    // Validation of the files to upload
    $input      = Input::all();
    $rules      = array( 'file' => 'image|max:15000');
    $validator  = Validator::make($input, $rules);
    if ($validator->fails()) {
        return  Redirect::route('photographer-gallery-upload')
                ->withErrors($validator)
                ->withInput();
    } else {
      echo '
';
      print_r(Input::all());
      echo'
';
      die ();}

Any idea why??

A: http://laravel.com/docs/requests#files
Use Laravel to open and close the form, like so:
// 'files' => true is necessary
{{ Form::open(array('url' => 'foo/bar', 'files' => true)) }}
{{ Form::close() }}

And in your controller, use the Input::hasFile() and Input::file() methods.


text:
Q: How to get the value of the static properties of a child class in the parent class? I have several models with this structure:
class Test extends \yii\db\ActiveRecord
{
    public static string $defaultDateRange = 'month'; // This property is the same in all classes
    public static array $fields = ['name', 'price']; // This property is unique for each class

    // This function is the same in all classes
    public static function batchUpdate(array $preparedData): int
    {
        // A class variable is used here - self::$fields
    }

    // This function is different in all classes
    public static function prepareData(array $data): array
    {
        // ...
    }
}

Models have both common properties and functions, and their own unique ones. I want to optimize the code to remove duplicate code sections, but I don't know how to do it.
I tried to create a base class and define all the duplicate properties and methods in it. But I can't get the value of the property of the child element Test::$fields in any way.
class BaseMarketplaceMetric extends \yii\db\ActiveRecord
{
    public static string $defaultDateRange = 'month';

    public static function batchUpdate(array $preparedData): int
    {
        // Need access to a property of a child class - Test::$fields
    }
}

class Test extends BaseMarketplaceMetric
{
    public static array $fields = ['name', 'price'];

    public static function prepareData(array $data): array
    {
        // ...
    }
}

How do I get the value of the static properties of a child class in the parent class? Or does it all need to be done in a completely different way?

A: Solution:
I just used static::$fields in parent class to get static properties of child classes.


text:
Q: What are the differences between the modules unicode and unicodedata? I have a large dataset with over 2 million rows of textual data. Now I want to remove the accents from the strings.
In the link below, two different modules are described to remove the accents:
What is the best way to remove accents in a Python unicode string?
The modules described are unicode and unicodedata. To me it's not clear what the differences are between the two and a comparison is hard, because I don't have many rows with accents and I don't know what accents might be replaced and which ones are not.
Therefore, I would like to know what the differences are between the two and which one is recommended to use.

A: There is only one module: unicodedata, which includes the unicode database, so the names and properties of unicode code points.
unicode was a built-in function in Python 2. This function just convert strings to unicode strings, so it was just the encoding, no need to store all the data. On python3 all strings are unicode (with some particularities). Just the encoding now should be defined explicitly.
On that answer, you see only import unicodedata, so only one module. To remove accents, you do no need just unicode code point, but also information about the type of a unicode code point (combining character), so you need unicodedata.
Maybe you mean unidecode. This is a special module, but outside standard library. It could be useful for some uses. The modules is simple and give only results in ASCII domain.  This could be ok on some cases, but it could cause problems outside Latin writing system.
On the other hand, unicodedata do nothing for you. You should understand unicode and apply the right filter function (and maybe knowing how other languages works).
So it depends on the case, and maybe you need just other slug functions (to create non escaped string).  When workign with languages, you should care not to overdo things (you may built an offensive word).


text:
Q: Undefined reference within static library, although the function is there I try to compile QDP++ C++ library using the Intel 17 compiler and Intel MPI on an Intel Xeon supercomputer. The dependency QMP C library has already been compiled with that compiler (mpiicc), there were no compilation errors.
When trying to configure QDP++, I get this error from the Intel compiler:
~/local-jureca/lib/libqmp.a(QMP_init.o): In function `QMP_comm_get_allocated':
QMP_init.c:(.text+0x55): undefined reference to `QMP_abort_mpi(int)'

And this from GCC 5.4:
~/local-jureca/lib/libqmp.a(QMP_init.o):QMP_init.c:function QMP_comm_get_allocated: error: undefined reference to 'QMP_abort_mpi(int)'

So it is an actual problem and not just something that the Intel C++ with MPI compiler cannot do.
The output of nm ~/local-jureca/lib/libqmp.a contains this stanza where QMP_comm_get_allocated resides in.
QMP_init.o:
                 U atol
                 U __ctype_b_loc
                 U exit
                 U __gcc_personality_v0
                 U __gxx_personality_v0
                 U malloc
00000000000015f0 T QMP_abort
00000000000015c0 T QMP_abort_string
0000000000000010 D QMP_allocated_comm
0000000000000018 d QMP_allocated_comm_s
0000000000000000 D QMP_args
0000000000000000 b QMP_args_s
                 U QMP_barrier
                 U QMP_comm_declare_logical_topology_map
0000000000000000 T QMP_comm_get_allocated
0000000000001760 T QMP_comm_get_default
00000000000000e0 T QMP_comm_get_job
                 U QMP_comm_get_logical_coordinates
                 U QMP_comm_logical_topology_is_declared
0000000000000070 T QMP_comm_set_allocated
00000000000016f0 T QMP_comm_set_default
0000000000000150 T QMP_comm_set_job
                 U QMP_comm_split
0000000000000048 D QMP_default_comm
                 U QMP_error
00000000000001c0 T QMP_finalize_msg_passing
                 U QMP_get_allocated_dimensions
                 U QMP_get_allocated_number_of_dimensions
                 U QMP_get_msg_passing_type
0000000000001620 T QMP_init_msg_passing
0000000000000040 D QMP_job_comm
0000000000000008 D QMP_machine
0000000000000048 b QMP_machine_s
0000000000000080 B QMP_stack_level
                 U __svml_idiv4
0000000000000000 r __$U0
0000000000000017 r __$U1
000000000000002e r __$U2
000000000000003f r __$U3
0000000000000091 r __$U4
000000000000007c r __$U5
0000000000000050 r __$U6
000000000000005a r __$U7
0000000000000067 r __$U8
                 U _Unwind_Resume
0000000000000500 t _Z12process_argsPiPPPc
000000000000002c r _Z12process_argsPiPPPc$$LSDA
                 U _Z13QMP_abort_mpii
                 U _Z20QMP_init_machine_mpiPiPPPc16QMP_thread_levelPS3_
                 U _Z28QMP_finalize_msg_passing_mpiv
00000000000001e0 t _Z9get_colorv
0000000000000000 r _Z9get_colorv$$LSDA

Another stanza contains the function QMP_abort_mpi which supposedly cannot be found:
QMP_init_mpi.o:
                 U malloc
                 U MPI_Abort
                 U MPI_Comm_dup
                 U MPI_Comm_rank
                 U MPI_Comm_size
                 U MPI_Finalize
                 U MPI_Get_processor_name
                 U MPI_Init_thread
0000000000000010 T QMP_abort_mpi
                 U QMP_abort_string
                 U QMP_allocated_comm
0000000000000000 T QMP_finalize_msg_passing_mpi
0000000000000020 T QMP_init_machine_mpi
                 U QMP_machine

The relevant output of `configure is:
configure:  Parscalar build! Checking for QMP
checking for qmp-config... ~/local-jureca/bin/qmp-config
configure: Found QMP configuration program ~/local-jureca/bin/qmp-config
configure: QMP compile flags: -I~/local-jureca/include
configure: QMP linking flags: -L~/local-jureca/lib
configure: QMP libraries flags: -lqmp
checking if we can compile/link of a simple QMP C++ program... no
configure: error: Cannot compile/link a basic QMP C++ program!
        Check QMP_CFLAGS, QMP_LDFLAGS, QMP_LIBS.

So it seems to find the library just fine.
In the config.log a little larger chunk is this:
configure:4227: /usr/local/software/jureca/Stages/2016b/software/impi/2017.0.098-iccifort-2017.0.098-GCC-5.4.0/bin64/mpiicpc -o conftest -O2 -Wall -fopenmp --std=c++11 -I~/local-jureca/include   -L~/local-jureca/lib conftest.cpp  -lqmp >&5
~/local-jureca/lib/libqmp.a(QMP_init.o): In function `QMP_comm_get_allocated':
QMP_init.c:(.text+0x55): undefined reference to `QMP_abort_mpi(int)'
~/local-jureca/lib/libqmp.a(QMP_init.o): In function `QMP_comm_set_allocated':
QMP_init.c:(.text+0xc7): undefined reference to `QMP_abort_mpi(int)'
~/local-jureca/lib/libqmp.a(QMP_init.o): In function `QMP_comm_get_job':
QMP_init.c:(.text+0x135): undefined reference to `QMP_abort_mpi(int)'
~/local-jureca/lib/libqmp.a(QMP_init.o): In function `QMP_comm_set_job':
QMP_init.c:(.text+0x1a7): undefined reference to `QMP_abort_mpi(int)'
~/local-jureca/lib/libqmp.a(QMP_init.o): In function `QMP_finalize_msg_passing':
QMP_init.c:(.text+0x1cf): undefined reference to `QMP_finalize_msg_passing_mpi()'
~/local-jureca/lib/libqmp.a(QMP_init.o): In function `get_color()':
QMP_init.c:(.text+0x29b): undefined reference to `QMP_abort_mpi(int)'
QMP_init.c:(.text+0x45c): undefined reference to `QMP_abort_mpi(int)'
QMP_init.c:(.text+0x4be): undefined reference to `QMP_abort_mpi(int)'
configure:4227: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "qdp++"
| #define PACKAGE_TARNAME "qdp--"
| #define PACKAGE_VERSION "1.44.0"
| #define PACKAGE_STRING "qdp++ 1.44.0"
| #define PACKAGE_BUGREPORT "edwards@jlab.org"
| #define PACKAGE_URL ""
| #define PACKAGE "qdp--"
| #define VERSION "1.44.0"
| #define QDP_ND 4
| #define QDP_NC 3
| #define QDP_NS 4
| #define QDP_AC_ALIGNMENT_SIZE 16
| #define QDP_USE_GENERIC_OPTS 1
| #define QDP_USE_BLUEGENEL 1
| #define BASE_PRECISION 64
| #define QDP_USE_CB2_LAYOUT 1
| #define ARCH_PARSCALAR 1
| /* end confdefs.h.  */
| #include "qmp.h"
| int
| main ()
| {
|
|         int argc ; char **argv ;
|         QMP_thread_level_t prv;
|          ;
|         QMP_init_msg_passing(&argc, &argv, QMP_THREAD_SINGLE, &prv) ;
|          ;
|         QMP_finalize_msg_passing() ;
|
|   ;
|   return 0;
| }
configure:4253: checking if we can compile/link of a simple QMP C++ program
configure:4261: result: no
configure:4263: error: Cannot compile/link a basic QMP C++ program!
        Check QMP_CFLAGS, QMP_LDFLAGS, QMP_LIBS.

I have replaced the absolute path to my home directory with ~ because the actual path is not interesting.
What happens here? And how can I go about fixing it?
Update 1
This is part of the make output for QMP. It seems to be compiled with mpiicc which is a C (not C++) compiler:
depbase=`echo mpi/QMP_topology_mpi.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
/usr/local/software/jureca/Stages/2016b/software/impi/2017.0.098-iccifort-2017.0.098-GCC-5.4.0/bin64/mpiicc -DHAVE_CONFIG_H -I. -I../include    -I../include  -O2 -Wall -fopenmp -MT mpi/QMP_topology_mpi.o -MD -MP -MF $depbase.Tpo -c -o mpi/QMP_topology_mpi.o mpi/QMP_topology_mpi.c &&\
mv -f $depbase.Tpo $depbase.Po

And then the static library is linked together from the various units:
rm -f libqmp.a
ar cru libqmp.a QMP_comm.o QMP_error.o QMP_grid.o QMP_init.o QMP_machine.o QMP_mem.o QMP_split.o QMP_topology.o QMP_util.o mpi/QMP_comm_mpi.o mpi/QMP_error_mpi.o mpi/QMP_init_mpi.o mpi/QMP_mem_mpi.o mpi/QMP_split_mpi.o mpi/QMP_topology_mpi.o


text:
Q: How to handle Floating Menu Action in landscape mode I tried to make FlaationActionButton using floating action button
Then I came across three scenarios:

*

*Need to handle landscape and portrait mode for Phones
Working fine for Portrait mode but some Floating actions not visible when changing the configuration to landscape mode.

*Tablet --- should expand upwards both in landscape and portrait mode:
Working fine.

*Phone--- In Portrait: should expand upwards
        In Landscape: nexpand left if floating action button is in right bottom corner.
I am facing the problem when Floating buttons are more than 5.
Below are the images:
Working fine in Portrait mode:

Need like this in landscape mode:

A:
I am facing the problem when Floating buttons are more than 5.

You need to create different layout for landscape mode as per documentation:
http://developer.android.com/training/basics/supporting-devices/screens.html
For implementing same design for different screen sizes and different orientation you need to implement xml files. You can see the structure as below:


text:
Q: Compilation failed after R update: stdio.h "Nonnull" I recently upgraded my R version to 4.1.1 using HomeBrew. After straightening out some path problems in R, I tried re-installing my old packages, but I get a very long series of errors which seem to have to do with C compilation. Here's what happens when I try to install a package:
> install.packages("utf8")
trying URL 'http://cran.r-project.org/src/contrib/utf8_1.2.2.tar.gz'
Content type 'application/x-gzip' length 240327 bytes (234 KB)
==================================================
downloaded 234 KB

* installing *source* package 'utf8' ...
** package 'utf8' successfully unpacked and MD5 sums checked
** using staged installation
** libs
/usr/local/opt/llvm/bin/clang -fopenmp -I"/usr/local/Cellar/r/4.1.1/lib/R/include" -DNDEBUG
  -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include -I/Library/Developer
/CommandLineTools/SDKs/MacOSX.sdk/usr/include
 -Iutf8lite/src -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c as_utf8.c -o as_utf8.o
In file included from as_utf8.c:21:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:64:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:137:9: warning:
      type nullability specifier '_Nullable' is a Clang
      extension [-Wnullability-extension]
        int     (* _Nullable _close)(void *);
                   ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:93:16: warning:
      pointer is missing a nullability type specifier
      (_Nonnull, _Nullable, or _Null_unspecified)
      [-Wnullability-completeness]
        unsigned char   *_base;
                        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:93:16: note:
      insert '_Nullable' if the pointer may be null
        unsigned char   *_base;
                        ^
                          _Nullable

[many similar errors omitted here]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:220:5: error:
      'TARGET_OS_IPHONE' is not defined, evaluates to 0
      [-Werror,-Wundef-prefix=TARGET_OS_]
#if TARGET_OS_IPHONE
    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:385:25: warning:
      type nullability specifier '_Nullable' is a Clang
      extension [-Wnullability-extension]
                 int (* _Nullable)(void *, cha...
                        ^

[Many similar messages omitted here]
21 warnings and 1 error generated.
make: *** [as_utf8.o] Error 1
ERROR: compilation failed for package 'utf8'
* removing '/usr/local/Cellar/r/4.1.1/lib/R/library/utf8'

The downloaded source packages are in
    '/private/var/folders/9n/dw965k251pv8jzk_n62djdl80000gn/T/RtmpoZ1OqU/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("utf8") :
  installation of package 'utf8' had non-zero exit status

The most I can figure out is that this has something to do with a failure to compile and link C code.
I'm running Mac OS 10.15.7 Catalina (the latest that my Mid-2012 MacBook Pro can run). However, I somehow seem to have the SDK for a newer version of Mac OS:
/Library/Developer/CommandLineTools/SDKs % ls
MacOSX.sdk  MacOSX10.15.sdk MacOSX11.1.sdk

and the default SDK (MacOSX.sdk) seems to link to the newer version (newer than my OS):
/Library/Developer/CommandLineTools/SDKs % ls -ltr .
total 0
lrwxr-xr-x  1 root  wheel   14 Oct  2 17:32 MacOSX.sdk -> MacOSX11.1.sdk
drwxr-xr-x  7 root  wheel  224 Oct  2 17:33 MacOSX11.1.sdk
drwxr-xr-x  8 root  wheel  256 Oct  2 17:34 MacOSX10.15.sdk

My R paths are the standard ones for Homebrew:
.libPaths()
[1] "/usr/local/Cellar/r/4.1.1/lib/R/library"
R.home()
[1] "/usr/local/Cellar/r/4.1.1/lib/R"

and I don't see anything obviously wrong with my path, which seems to contain gcc
echo $PATH
/usr/local/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:
/sbin:/Applications/VMware Fusion.app/Contents/Public:
/Library/TeX/texbin:/usr/local/share/dotnet:/opt/X11/bin:
~/.dotnet/tools:/Library/Apple/usr/bin

ls /usr/local/bin/gcc*
/usr/local/bin/gcc-11       /usr/local/bin/gcc-nm-11
/usr/local/bin/gcc-ar-11    /usr/local/bin/gcc-ranlib-11

Oddly, gcc seems to be set to compile using the 10.15 version of SDK, not the current 11.1 version:
gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr
 --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

For what it's worth, I also have this going on:
xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

So I'm a bit confused about which version of the SDK is actually being used, etc.
My plan at the moment is to uninstall Xcode and reinstall version 12.4, which is the latest version you can run on 10.15 Catalina. I'm not sure if this will help.
Does anyone have any idea what the problem might be or how I might fix it? As of right now I basically can't use R, which is preventing me from doing virtually all of my work! Any help would be greatly appreciated.


text:
Q: How to capture images continuously and control a time based bot at the same time? This post is not exactly a  coding problem , but it is more of a code structuring and synchronizing problem . So I have created a bot using Raspberry Pi, which moves in a predefined path as shown in the attached picture . It moves from start->A for 10 seconds , then takes a left and moves for 5 seconds and continues till it reaches the end (Please see the picture for clarity ) . So , I have the code structure for the bot movement in the following way -
for directions,time in database:
    while time!=0:
       continue movement in the specified direction .
       time--

So , basically it runs a for  loop in Python that finds the direction and Time from a list variable called "database" and moves ahead accordingly .
The second part of the problem is , I have a camera mounted on the bot that captures image continuously and  does a certain task , if an object is detected in front of it . The code structure for the following bot is something like this -
for frame in camera.continuous_capture():
   capture image()
   do some calculation()
   if object in frame()==True:
      do something()

The above code is actually a continuous capture method employed in Picamera (Raspberry Pi) . The documentation is - https://picamera.readthedocs.io/en/release-1.10/recipes1.html#capturing-timelapse-sequences
Now , the problem is - I want to integrate this continuous camera capture algorithm with the bot motion . Something like , say , the bot moves from Start-> A , the camera should be active and capture frames continuously , and the bot should move as well . Upon detection of an object (if present) , it should stop the timer for the present path , carry out the necessary action according to the Image processing algorithm and return back to continue its motion in the path it was earlier on .
I have got the Image processing algo working fine , if run separately . And the same goes for Bot movement  . But I am not able to figure out how will I integrate both these functions running side by side , as both of them are utilizing "While" loops , and nesting one inside the other will not give me the desired solution .
So, I wanted to know If "Threading" is what I should do ? Say for ex , the Image processing algo changes a global variable on detecting any change and the Bot movement algo keeps track of the global variable at the same time . On detecting any change to the global variable , the bot algorithm stops and lets the Image processing algo carry out the necessary function . Is this current way to go about it or there is  a better solution to this ?
Pleas help . Please do not downvote this question . I am not trolling and I am also not looking for code help as I can figure that out myself . I just need to know , how to integrate/structure my code .
Thanks !
Bot path.


text:
Q: VBA take row number of active cell and place it in column A of a table on another sheet New to VBA here. Almost done with this project I am working on and missing one piece I cant figure out with VBA.
I am using a user form to input data into a sheet. I have a condition that if a column range (I named it) is > 0, take value from another column and use that value to add that many rows to another table on another sheet.
I got all that working great. The roadblock I am having is I also need the row number of the activecell from the source sheet (the one I use the user form with) to also be inserted into column A of all the new rows inserted when the code executes.
I need this done because I have formulas in cells B through E that calculate based on the value in row A; and i need the value in row a to be the row number from the row I just inserted into my source sheet (hens the "active cell" mentality).
Clear as Mud? I hope I explained this all correctly and would really appreciate any help I can get on this. I have provided the code. Its the last part I need help with. I think its a loop I have to use but I haven't used loops in vba yet.
 Sub AddRowsToTable()

 Dim targetTable As ListObject
 Dim valueLastRowLastCol As Long

 Set targetTable = Range("TblDateRng").ListObject

' Get last row, last column value
valueLastRowLastCol = Intersect(Rows(ActiveCell.Row), Range("Duration")).Value

'Add as many rows as the number in last column, last row of source table to target table
targetTable.Resize targetTable.HeaderRowRange.Resize(targetTable.ListRows.Count + valueLastRowLastCol
+ 1)

'Execute the column number of the active cell from the source sheet, and places it in column (A) of
new rows added from code above
For Each cell In targetTable.Range("A:A")
If targetTable.Range("A:A") = "" Then
Range("A:A").Value = ActiveCell.Row

MsgBox "Success"
End If
Next
End Sub


text:
Q: Reshaping a numpy vector I am really new to numpy. I have a numpy vector that when I run y.shape returns (4000,). Is there a way, I can have it return (4000, 1)?

A: np.reshape(y,(4000,1))

Reshape function can be used to do this


text:
Q: Can markdown mini replace an en dash with a normal hyphen in URLs? Further to Tim Stone's response to my bug report regarding what turned out to be an en dash in an URL: Would it be reasonable for markdown mini to replace en dashes with normal hyphens? Or is that Wikipedia article's URL just a fluke?

A: No, that would be just wrong. We have, however, changed the handling of not-whitelisted characters in those URLs from "just remove" to "percent-encode", which obviously solves your original problem as well (and others), while not changing the URL – on Wikipedia, different dash kinds may be equivalent, but this probably is not the case everywhere.


text:
Q: Python decorator class to transform methods to dictionary items I wonder if there is a reasonable easy way to allow for this code (with minor modifications) to work.
class Info(object):
    @attr("Version")
    def version(self):
        return 3

info = Info()
assert info.version == 3
assert info["Version"] == 3

Ideally, the code would do some caching/memoising as well, e.g. employ lazy attributes, but I hope to figure that out myself.
Additional information:
The reason why I want provide two interfaces for accessing the same information is as follows.
I'd like to have a dict-like class which uses lazy keys. E.g. info["Version"] should call and cache another method and transparently return the result.
I don't think that works with dicts alone, therefore I need to create new methods.
Methods alone won't do either, because there are some attributes which are easier to define with pure dictionary syntax.
It probably is not the best idea anyway…

A: If the attribute name (version) is always a lowercase version of the dict key ("Version"), then you could set it up this way:
class Info(object):
    @property
    def version(self):
        return 3
    def __getitem__(self,key):
        if hasattr(self,key.lower()):
            return getattr(self,key.lower())

If you wish the dict key to be arbitrary, then its still possible, though more complicated:
def attrcls(cls):
    cls._attrdict={}
    for methodname in cls.__dict__:
        method=cls.__dict__[methodname]
        if hasattr(method,'_attr'):
            cls._attrdict[getattr(method,'_attr')]=methodname
    return cls

def attr(key):
    def wrapper(func):
        class Property(object):
            def __get__(self,inst,instcls):
                return func(inst)
            def __init__(self):
                self._attr=key
        return Property()
    return wrapper

@attrcls
class Info(object):
    @attr("Version")
    def version(self):
        return 3
    def __getitem__(self,key):
        if key in self._attrdict:
            return getattr(self,self._attrdict[key])

I guess the larger question is, Is it a good interface? Why provide two syntaxes (with two different names) for the same thing?

A: Not trivially. You could use a metaclass to detect decorated methods and wrap __*attr__() and __*item__() appropriately.


text:
Q: Sweet Alerts is display UTF-8 Chars wrong I don't know what is wrong, I have this JavaScript function:
<script charset="utf-8" type="text/javascript">
$(document).ready(function(){
    //initialize the javascript
    App.init();
    @if(Session::has('message'))
    var msg = '{{ Session::get('message') }}';
    console.log(msg);
    swal({
        title: "",
        text: 'compañia',
        type: "warning",
        confirmButtonText: "Ok!",
        closeOnConfirm: false
    });
    $(window).bind("load", function() {
        $.gritter.add({
            title: 'Atencion',
            text: 'compañia',
            image: '{{ asset('images/clipboard_icon.png') }}',
            class_name: 'danger',
            time: ''
        });
        return false;
    });
    @endif
});
</script>

The problem is that sweet alerts doesn't display: 'compañia' it displays 'compañia' but the gritter message is correctly displaying the word. (See picture)

As you can see the red gritter correctly displays the word, but the sweet alert doesn't,
The file is UTF-8 encoded, so is the meta and the script also just in case, and before you ask why I put 'compañia' its part of a larger message that is send by Laravel on the session and retrieved by the view in that format.
Anyway my real question is why does the gritted display the word fine and how can I fix it so it works also on sweet alert.

A: I just fixed it by adding html: true to the function:
swal({
        title: "",
        text: 'compañia',
        type: "warning",
        confirmButtonText: "Ok!",
        closeOnConfirm: false,
        html: true
    });

A: I fixed it by setting html to the text.
swal({
        title: "",
        text: 'compañia',
        type: "warning",
        confirmButtonText: "Ok!",
        closeOnConfirm: false,
        html: 'compañia'
    });


text:
Q: Sharepoint Online REST: API not returning correct info if site collection created before certain time On older websites (ex: 2018/10), the GET https://msdn.microsoft.com/en-us/library/office/dn499819.aspx#bk_WebEndpoint and GET https://msdn.microsoft.com/en-us/library/office/dn531433.aspx#bk_ListEndpoint endpoints always return the Title and Descriptions used to create them, not their current values displayed in the Sharepoint Online UI.
For example, if I create a list called "abcdef" and change its title to "123456", its title is clearly changed in the UI but if I GET it, the returned title is still "abcdef".
However, if I create a few new site collection (2018/12) and try the same thing (change Title -> GET List) on all of them, all of them have the correct
(new) titles.
I'm guessing Sharepoint Online updated something that affects sites created after that, but did not push the updates to sites created previously. Can anyone confirm if there was indeed a patch between this October and December that only affects newly created site collections' REST API's behaviors?

A: Check default language of old and new sites, maybe they are created in different languages.
Lets say that you create site in German language but your PC language is English. When you create list the name is set for all languages. When you change the name afterwards, the name is changed only in English (because of your locale).

A: We need get the updated list data after change it using REST API, the following example about change list Title and get the new list Title using jQuery with REST API for your reference.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
function changeListTitle(){
    var listId="e891adf7-d48a-4940-a545-727fc43f7e61";
    var title="123456";
    var properties = {
        "__metadata": { "type": "SP.List"},
        "Title": title
    };
    $.ajax({
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists(guid'"+listId+"')",
        type: "POST",
        contentType: "application/json;odata=verbose",
        data: JSON.stringify(properties),
        headers: {
            "Accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "X-HTTP-Method": "MERGE",
            "If-Match": "*"
        },
        success: function (data) {
            alert("The new list Title: "+getListTitle(listId));
        },
        error: function (data) {
            console.log("Error");
        }
    });
}
function getListTitle(listId){
    var title="";
      $.ajax({
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists(guid'"+listId+"')?$select=Title",
        type: "GET",
        async:false,
        headers: {
            "Accept": "application/json;odata=verbose",
        },
        success: function (data) {
            title=data.d.Title;
        },
        error: function (data) {
            console.log("Error");
        }
    });
    return title;
}
</script>
<input type="button" value="ChangeListTitle" onclick="changeListTitle()"/>


text:
Q: Running two PHP versions (5.3 & 5.2) at the same time I have read this topic: Running php4 and php5 along side each other
There, the issue is handling two different generations of PHP (PHP 4 vs PHP 5), but what I need is to make all but one of my server accounts work under 5.3 and just a single domain under 5.2.
I cannot make this through Apache models, and the answer from https://stackoverflow.com/questions/524508/how-can-one-run-multiple-versions-of-php-5-x-on-a-development-lamp-server does not apply since in my case I can't use a different port - this is a regular website  on the same server.

A: You can still use the answer in https://stackoverflow.com/questions/524508/how-can-one-run-multiple-versions-of-php-5-x-on-a-development-lamp-server; you just need to add a way to redirect that traffic to the other port. Here's how:
You set up a separate apache instance with PHP 5.2, and you set it to listen to port 8080.
On your regular apache, you change the VirtualHost for that one domain so that it now contains a reverse proxy to the 5.2 apache. Example:
<VirtualHost *:80>
   Servername php52.example.com
   ProxyPass / http://yourservername.example.com:8080/
   ProxyPassReverse / http://yourservername.example.com/
</VirtualHost>

That way, your original apache instance will accept all traffic to all websites on your server. But requests to this one particular domain will be transparently forwarded to the other instance without the user on the other side of the browser knowing it.

A: There is a way to achieve this on a per-directory basis. You do find contradicting opinions on the web, but I have been able to make it work.
First, you must organize to have your different versions of PHP ready to run as CGI or fastCGI extentions. I use fastCGI in the example below
You will need to set up two separate php.ini files (and yes, maintaining them in sync where it matters can be a pain, but the alternative is to have only one php.ini file for 2 different versions of PHP & that's either impossible or full of loopholes)
Place those php.ini files in the directory of your PHP code, modules, etc. one for each version. This is where PHP will go look for them first, absent the PHPRC environment variable. You should not set the PHPRC variable, unless you discover how to make it different for 2 different fastCGI stubs, I have not been able to:  the Apache FcgidInitialEnv directive works only globally, not on a per-directory basis, and the FcgidCmdOptions which is supposed to does not work at all.
Then, all you have to do is to add the following code in you httpd.conf file:
#
# start PHP as FastCGId
#

LoadModule fcgid_module modules/mod_fcgid.so

#
# PHP 7.0 is the default
# PHP 5.2 is the legacy
#

<Files ~ "\.php$>"
  AddHandler fcgid-script .php
  FcgidWrapper "c:/WebServers/PHP-7.0.5/php-cgi.exe" .php
</Files>

#
# Keep PHP 5.2 for legacy Drupal sites
#
<DirectoryMatch "Puitscarre|Royale$">

  <Files ~ "\.php$>"
    AddHandler fcgid-script .php
    FcgidWrapper "c:/WebServers/PHP-5.2.39/php-cgi.exe" .php
  </Files>

</DirectoryMatch>

It works perfectly on my environment: Windows 7, Apache 2.2. And, by the way, the code that is in the Directory environment above also works if you put it in the .htaccess file of the directories which need a specific or legacy version of PHP
Enjoy !

A: I just used cgi for such case
<VirtualHost *:80>
    Servername site.example.net
    ScriptAlias /php-fastcgi/ /usr/local/php-5.2.17/bin/

    AddHandler php-fastcgi .php
    AddType application/x-httpd-php .php
    Action php-fastcgi /php-fastcgi/php-cgi
...
</VirtualHost>