text:
Q: How to pass data to openGL functions correctly in Rust I'm trying to abstract openGL in Rust. I use glutin to communicate with openGL (here is the code I started with). I'm having problems abstracting Uniforms in fact they randomly get -1 as location (the same code sometimes works and sometimes doesn't).
I checked if the program was in use and it was so I started wondering if there is a problem in the way I send the data to openGL:
// value is initialised here

let name = name.to_string();
let location;
unsafe {
  location = gl.GetUniformLocation(program.get_id(), name.as_ptr() as *const GLchar);
};

match value {
  UniformType::Float(v) => unsafe {
    gl.Uniform1f(location, v);
  },
  UniformType::Float4(v) => unsafe {
    gl.Uniform4fv(location, 1, &v[0]);
  },
  UniformType::Texture(tex_id) => unsafe {
    gl.Uniform1i(location, tex_id);
  },
  UniformType::Mat4x4(v) => unsafe {
    gl.UniformMatrix4fv(location, 1, gl::FALSE, &v[0]);
  },
  _ => {
   panic!("Uniform::new This uniform type is unknown");
  }
}

// this scope ends and value if freed

Is it a problem the fact that value gets freed right after the call to gl.Uniform? If yes, why? I read online that only the draw calls are asynchronous.

Edited: Debugging
The uniforms are actively used inside the shaders.
Gives the right number of active uniforms counting even those that got -1 as location:
let mut param = 0;
unsafe {
  gl.GetProgramiv(program.get_id(), gl::ACTIVE_UNIFORMS, &mut param);
}
println!("Number of active uniforms: {}", param);

Always gives 'no error':
let err;
unsafe {
  err = gl.GetError();
}
match err {
  gl::NO_ERROR => {
    println!("Uniform '{}': no error", name);
  }
  gl::INVALID_VALUE => {
    println!("Uniform '{}': invalid value", name);
  }
  gl::INVALID_OPERATION => {
    println!("Uniform '{}': invalid operation", name);
  }
  _ => {
    println!("Uniform: '{}' error: {}", name, err);
  }
}

A: According to the documentation for GetUniformLocation:

This function returns -1 if name does not correspond to an active uniform variable in program, if name starts with the reserved prefix "gl_", or if name is associated with an atomic counter or a named uniform block.

So you're not error-checking your gl calls, and it looks like there are cases where you're calling GetUniformLocation incorrectly, which could account for "sometimes it works, sometimes it does not".

A: At the end I found the problem:
// getting a CString from name
let cname = std::ffi::CString::new(name).expect("CString::new failed");

let location;
unsafe {
  location = gl.GetUniformLocation(program.get_id(), cname.as_ptr());
}

(sometimes I tend to forget that I'm working with bindings)


text:
Q: циклический switch java Мне нужно сделать консольное меню, использовал обычный switch, но не знаю как сделать чтобы при выборе кейса, он выполнялся и после этого в консоли снова появлялось то же меню, без потери проделанных операций
Класс Main
public class Main {

public static void main(String[] args) {

    List list = new List();

    int value;
    int color;

    Scanner scan = new Scanner(System.in);

    System.out.println("Menu");
    System.out.println("1 - Make list" + "\n" + "2 - Show massive" + "\n" + "3 - Show number of elements" + "\n" +
            "4 - Show cards by the value" + "\n" + "5 - Show cards by color" + "\n" + "6 - Remove" + "\n" + "7 - Quit" + "\n");

    byte functuion = scan.nextByte();

    switch (functuion){

        case 1 : list.makeList();

        case 2 : list.showList();

        case 3 :
            System.out.println("Number of elements: ");
            list.showNumberOfElements();

        case 4 :
            System.out.println("Enter value for search: ");
            scan.nextLine();
            value = scan.nextInt();
            list.showByValue(value);

        case 5 :
            System.out.println("Enter color for search: ");
            scan.nextLine();
            color = scan.nextInt();
            list.showByColor(color);

        case 6 :
            System.out.println("Enter value of card that you want to remove: ");
            value = scan.nextInt();
            System.out.println("Enter color of card that you want to remove: ");
            color = scan.nextInt();
            list.remove(value, color);

        case 7 : break;

    }

}

}

A: boolean cheaker = true;
while(cheaker){
    switch(...){
        ...
        case(...):
            cheaker = false; // выход из меню
            break;
    }
}

A: Попробуйте так:
package stackoverflow;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        List list = new ArrayList();

        int value;
        int color;

        Scanner scan = new Scanner(System.in);

        String menu = "Menu\n" + "1 - Make list\n" + "2 - Show massive\n" + "3 - Show number of elements\n"
            + "4 - Show cards by the value\n" + "5 - Show cards by color\n" + "6 - Remove\n" + "7 - Quit\n";

        System.out.println(menu);

        boolean isQuit = false;
        while (!isQuit) {
            byte functuion = scan.nextByte();

            switch (functuion) {

                case 1:
                    // list.makeList();
                    System.out.println("list.makeList();");
                    break;

                case 2:
                    // list.showList();
                    System.out.println("list.showList();");
                    break;

                case 3:
                    System.out.println("Number of elements: ");
                    // list.showNumberOfElements();
                    break;

                case 4:
                    System.out.println("Enter value for search: ");
                    scan.nextLine();
                    value = scan.nextInt();
                    // list.showByValue(value);
                    break;

                case 5:
                    System.out.println("Enter color for search: ");
                    scan.nextLine();
                    color = scan.nextInt();
                    // list.showByColor(color);
                    break;

                case 6:
                    System.out.println("Enter value of card that you want to remove: ");
                    value = scan.nextInt();
                    System.out.println("Enter color of card that you want to remove: ");
                    color = scan.nextInt();
                    // list.remove(value, color);
                    break;

                case 7:
                    isQuit = true;
                    break;

                default:
                    System.out.println("No such menu");
                    break;
            }

            System.out.println(menu);
        }

    }

}

redpajama_set_name: RedPajamaStackExchange


text:
Q: How can I avoid Windows 8.1 resetting my font size? I am using Windows 8.1 on my laptop, which has a 15.6" screen with resolution 1366x768. I measured the screen with a ruler and calculated its DPI, which is 101. Therefore, I have set the scaling to 105%. However, when I change to an external monitor, which is a huge one with resolution 1920x1080 and DPI 93, I need to change the scaling to 97% but when I change the DPI back and forth, my font sizes have get resetted.
I prefer using font sizes 14 on my title bars, message boxes and icons and font sizes 13 on my palette titles, menus and tooltips. However, as my laptop screen is too small, in order to make my apps fit on screen, I use font sizes 12 on my title bars, message boxes and icons and font sizes 11 on my palette titles, menus and tooltips. I don't know why I can't resize the window to make it larger than my screen in Windows (but it is possible in Kubuntu), therefore, some parts of my apps cannot be shown with my preferred font size.
I have tried changing both the DPI and the font size by using .reg files. Before switching to my laptop screen, I apply the following:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\Desktop]
"LogPixels"=dword:00000065

[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics]
"CaptionFont"=hex:ef,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,\
  00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"SmCaptionFont"=hex:f0,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,\
  00,00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"MenuFont"=hex:f0,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,\
  00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"StatusFont"=hex:f0,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,\
  00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"MessageFont"=hex:ef,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,\
  00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"IconFont"=hex:ef,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,\
  00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"AppliedDPI"=dword:00000065

Before switching to my external display, I apply this:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\Desktop]
"LogPixels"=dword:0000005d

[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics]
"CaptionFont"=hex:ed,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,\
  00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"SmCaptionFont"=hex:ee,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,\
  00,00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"MenuFont"=hex:ef,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,\
  00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"StatusFont"=hex:ef,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,\
  00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"MessageFont"=hex:ed,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,\
  00,00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"IconFont"=hex:ed,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,\
  00,00,01,00,00,05,00,53,00,65,00,67,00,6f,00,65,00,20,00,55,00,49,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"AppliedDPI"=dword:0000005d

I expect after applying the file, the DPI settings and the font sizes take effect at the next sign in. However, on my laptop screen, after I applied the file, signed out and in, the DPI setting changed, but the font sizes were resetted to tiny, and I had to apply the same file, signed out and in again to get the correct font size. The situation is even worse on my external monitor. After I applied the file, signed out and in, both the DPI setting and the font sizes were resetted to their default values, which were 96 DPI (the physical DPI as measured by dividing the resolution by the physical size is 93) and font size 9, which is totally unacceptable. How can I write the .reg files such that the settings can be correctly applied with a single sign in?

A: If you go to the Control Panel and choose Display. Put a check mark in "let me choose one scaling level for all my displays" this will stop Windows 8 from auto scaling everything. You can then set your font sizes. Set your 1080p monitor resolution via your video card setting. 96 dpi is the correct setting for 1080p. I hope this is what you were looking for. If not I don't think anyone knows the answer. We all got hit with this new auto scaling thing Microsoft has implemented. So there isn't much info for fixing things yet.


text:
Q: Asyntask with fragments, error Shutting down VM I'm trying to use a AsyncTask consulting a parseobject and brings me a picture and text in a list, but when running above shows me the following error:
    10-27 16:29:18.335: D/AndroidRuntime(28453): Shutting down VM
10-27 16:29:18.335: W/dalvikvm(28453): threadid=1: thread exiting with uncaught exception (group=0x40018578)
10-27 16:29:18.343: E/AndroidRuntime(28453): FATAL EXCEPTION: main
10-27 16:29:18.343: E/AndroidRuntime(28453): java.lang.NullPointerException
10-27 16:29:18.343: E/AndroidRuntime(28453):    at com.johanseetlabs.panamaviajero.A_su_alrededor$RemoteDataTask.onPostExecute(A_su_alrededor.java:101)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at com.johanseetlabs.panamaviajero.A_su_alrededor$RemoteDataTask.onPostExecute(A_su_alrededor.java:1)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at android.os.AsyncTask.finish(AsyncTask.java:417)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at android.os.AsyncTask.access$300(AsyncTask.java:127)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at android.os.Looper.loop(Looper.java:130)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at android.app.ActivityThread.main(ActivityThread.java:3687)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at java.lang.reflect.Method.invokeNative(Native Method)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at java.lang.reflect.Method.invoke(Method.java:507)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
10-27 16:29:18.343: E/AndroidRuntime(28453):    at dalvik.system.NativeStart.main(Native Method)

My Fragment:
public class A_su_alrededor extends Fragment {
    ListView listview;
    List<ParseObject> ob;
    ProgressDialog mProgressDialog;
    ListViewAdapter adapter;
    public List<ObtenerData> ObtenerDatalist = null;
    View view;
    private WeakReference<RemoteDataTask> asyncTaskWeakRef;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRetainInstance(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.a_su_alrededor, container, false);
        startNewAsyncTask();
        return view;
    }

    // RemoteDataTask AsyncTask
    private class RemoteDataTask extends AsyncTask<Void, Void, Void> {
        private WeakReference<A_su_alrededor> fragmentWeakRef;

        private RemoteDataTask(
                A_su_alrededor a_su_alrededor) {
            this.fragmentWeakRef = new WeakReference<A_su_alrededor>(
                    a_su_alrededor);
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            // Create a progressdialog
            mProgressDialog = new ProgressDialog(getActivity());
            // Set progressdialog title
            mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            // Set progressdialog message
            mProgressDialog.setMessage("Loading...");
            mProgressDialog.setIndeterminate(true);
            // Show progressdialog
            mProgressDialog.show();
            // lockScreenOrientation();
        }

        @Override
        protected Void doInBackground(Void... params) {
            // Create the array
            ObtenerDatalist = new ArrayList<ObtenerData>();
            try {
                ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(
                        "Hotel");
                query.orderByAscending("hotel");
                ob = query.find();
                for (ParseObject hotel : ob) {
                    // localizar imagenes en la columna
                    ParseFile image = (ParseFile) hotel.get("image");

                    ObtenerData map = new ObtenerData();
                    map.setHotel((String) hotel.get("hotel"));
                    map.setImage(image.getUrl());
                    ObtenerDatalist.add(map);
                }
            } catch (ParseException e) {
                Log.d("TAG", "AsynTask no se ejecuto");
                Log.e("Error", e.getMessage());
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            // Locate the listview in listview_main.xml
            listview = (ListView) view.findViewById(R.id.listview_a_su_alrededor);
            // Pass the results into ListViewAdapter.java
            adapter = new ListViewAdapter(getActivity(), ObtenerDatalist);
            // Binds the Adapter to the ListView
            listview.setAdapter(adapter);
            // Close the progressdialog
            mProgressDialog.dismiss();
            // unlockScreenOrientation();
        }
    }

    private void startNewAsyncTask() {
        RemoteDataTask asyncTask = new RemoteDataTask(this);
        this.asyncTaskWeakRef = new WeakReference<RemoteDataTask>(asyncTask);
        asyncTask.execute();
    }
}

The same code is used on a tab, but I decided to delete the tab. The fragment is placed on a FrameLayout from a drawerlayout.
Finally excuse my English.

A: In the onCreateView method you have this line:
View view = inflater.inflate(R.layout.a_su_alrededor, container, false);

I think you should remove the type name:
view = inflater.inflate(R.layout.a_su_alrededor, container, false);

since at first blush you seem to be using the class-scope reference to the variable named view in the failing onPostExecute method.

A: There is a null pointer acception, can you identify which line it is on from the logcat? it may be line 101


text:
Q: Custom Listview View NullPointerException I have a Custom SimpleCursor listView and Chronometer. I try to do When Chronometer(timer ) is 00:10 Draw color a row  but its throw NullPointerException.
Thank U for Helps
Here is Code:
public class ListViewcursorActivity extends ListActivity {
/** Called when the activity is first created. */
Chronometer timer;
ListView lvItems;
SimpleCursorAdapter colours;
private testDBAdapter thisTestDBAdapter;
LinearLayout[] Row;
View[] v;
@Override
public void onCreate(Bundle savedInstanceState) {

    thisTestDBAdapter = new testDBAdapter(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    lvItems =getListView();fillData();

    timer = (Chronometer)findViewById(R.id.chronometer1);

    timer.setBase(android.os.SystemClock.elapsedRealtime());
    timer.start();

     Row =new LinearLayout[lvItems.getCount()];
     v = new View[lvItems.getCount()];
    for(int i=0;i<lvItems.getChildCount();i++) {
        v[i] =lvItems.getChildAt(i);
        Row[i] = (LinearLayout)v[i].getParent();
    }
    timer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {

        public void onChronometerTick(Chronometer chronometer) {
            // TODO Auto-generated method stub
            for(int i=0;i<lvItems.getChildCount();i++){

            //  TextView child =(TextView)Row[i].getChildAt(0);
                if(  chronometer.getText().toString().equalsIgnoreCase("Timer: 00:10")){

                    try {
                        Row[1].setBackgroundColor(Color.RED);
                    } catch (NullPointerException e) {
                        // TODO Auto-generated catch block
                        Toast.makeText(ListViewcursorActivity.this, e.toString(), Toast.LENGTH_SHORT).show();
                    }
                }

            }
    }
    });
}

Problem is : // TextView child =(TextView)Row[i].getChildAt(0);
and Row[1].setBackgroundColor(Color.RED);
    06-02 17:00:57.263: E/AndroidRuntime(869): Uncaught handler: thread main exiting due to uncaught exception
06-02 17:00:57.263: E/AndroidRuntime(869): java.lang.NullPointerException
06-02 17:00:57.263: E/AndroidRuntime(869):  at net.deneme.cursorlist.ListViewcursorActivity$1.onChronometerTick(ListViewcursorActivity.java:91)
06-02 17:00:57.263: E/AndroidRuntime(869):  at android.widget.Chronometer.dispatchChronometerTick(Chronometer.java:276)
06-02 17:00:57.263: E/AndroidRuntime(869):  at android.widget.Chronometer$1.handleMessage(Chronometer.java:268)
06-02 17:00:57.263: E/AndroidRuntime(869):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 17:00:57.263: E/AndroidRuntime(869):  at android.os.Looper.loop(Looper.java:123)
06-02 17:00:57.263: E/AndroidRuntime(869):  at android.app.ActivityThread.main(ActivityThread.java:4363)
06-02 17:00:57.263: E/AndroidRuntime(869):  at java.lang.reflect.Method.invokeNative(Native Method)
06-02 17:00:57.263: E/AndroidRuntime(869):  at java.lang.reflect.Method.invoke(Method.java:521)
06-02 17:00:57.263: E/AndroidRuntime(869):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-02 17:00:57.263: E/AndroidRuntime(869):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-02 17:00:57.263: E/AndroidRuntime(869):  at dalvik.system.NativeStart.main(Native Method)
06-02 17:00:57.273: I/dalvikvm(869): threadid=7: reacting to signal 3
06-02 17:00:57.273: E/dalvikvm(869): Unable to open stack trace file '/data/anr/traces.txt': Permission denied

A: TextView child =(TextView) Row[i].getChildAt(0);

why not get it by id?
LinearLayout row = (LinearLayout) Row[i];
if(row != null) {
    TextView textView = (TextView) row.findViewBy(R.id.textviewid);
    if(TextView != null)
       //do stuff
}

Does that help?
Also look more into code what is Row? a Linearlayout right? it is kind of unclear code. Maybe organize a bit better.

A: Null Pointer Exception usually means that you are trying to access something which does not exist in the current context.
Verify that your XML is correctly referred in the Java code.

A: I cant see the adapter being set to the listview anywhere in your onCreate. Set the adapter and see if it fixes the problem. Items will be created and they will have parents once you set the adapter.

A: For nullpointer exception you can use the debugging to trace the nullpointer exception it can tell you where the nullpointer exception occur.


text:
Q: How to keep the same fragment when activity restarts due to orientation change in a Navigation Drawer Activity I found many post explaining how get the Fragment from the savedInstanceState Bundle but, because the Activity can swap between 4 Fragments, i need a way to know which Fragment was alive before rotate when the orientation started to change.
The reason i have several Fragments is because i am using Navigation Drawer, so each menu item as a fragment.

A: I had the same issue and I fixed it adding this to the Navigation Drawer activity code:
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if(savedInstanceState==null){
        //Handle the initial fragment transaction
    }
    ...
}

For example, I have a navigation drawer with "Home", "Settings" and "About" as menu items, each with a fragment "home_fragment", "settings_fragment" and "about_fragment".
If I want "home_fragment" to appear when the navigation drawer activity launches, I use this code on the OnCreate function:
FragmentManager fM = getSupportFragmentManager();
fM.beginTransaction().replace(R.id.NavDrawContent,new home_fragment()).commit();

But I want it to execute only when (savedInstanceState == null), so that when we change the phone orientation while in settings_fragment (for example), it doesn't inflate home_fragment.
So the final code (inside the navigation drawer activity OnCreate):
super.onCreate(savedInstanceState);
if(savedInstanceState==null){
    FragmentManager fM = getSupportFragmentManager();
    fM.beginTransaction().replace(R.id.NavDrawContent,new home_fragment()).commit();
}

A: In the activity, you save the fragment's instance in onSaveInstanceState() and restore in onCreate().
@Override
public void onCreate(Bundle savedInstanceState) {
    ...
    if (savedInstanceState != null) {
        fragment = getSupportFragmentManager().getFragment(savedInstanceState, "KEY");
        changeFragment(fragment, "MY TAG")
    } else {
        setupFragment();
    }
    ...
}

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    Fragment fragment = getSupportFragmentManager().findFragmentByTag("MY TAG");
    if (fragment != null) {
        getSupportFragmentManager().putFragment(outState, "KEY", fragment);
    }
}

If you need to know which fragment was saved, you can check with instanceof, for example:
if (fragment instanceof SettingsFragment) {
    // ...
}

A: Found my own answer and it it was a really simple thing after all. I left the solution here for those who are not familiar to android,like me .
//current fragment
int fragment_id;

//make fragment selection available form the menu resource id
private void setFragment(MenuItem item) {

    Fragment fragment = null;
    fragment_id = item.getItemId();

    switch (fragment_id) {
        case R.id.nav_option_1:
            fragment = MyFragment1.newInstance(true);
            break;
        ...
        //Set fragment
        FragmentTransaction t = getSupportFragmentManager().beginTransaction();
        t.replace(R.id.content_navigation, fragment);
        t.commit();
    }

    item.setChecked(true);
}

private class DrawerItemClickListener implements NavigationView.OnNavigationItemSelectedListener {

    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        setFragment(item);
        return false;
    }
}

//save the state
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putInt(SAVE_INSTANCE_FRAGMENT_KEY, fragmentid);
}

//restore the saved fragment on create
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation);
    ///...
    if (savedInstanceState != null) {
        int fragment_id = savedInstanceState.getInt(SAVE_INSTANCE_FRAGMENT_KEY);
        selectItem(mDrawerList.getMenu().findItem(fragment_id));
    } else {
        selectItem(mDrawerList.getMenu().findItem(R.id.home_fragment_id));
    }

}


text:
Q: Haskell data type that represents valid types Is there a library that defines a data type that defines valid Haskell types (presumably this would be a GADT).
To explain, let me suggest what this might look like:
data A
data B

class Free t
instance Free A
instance Free B

x = Forall A (Forall B (Constraint (NumConstraint A)
      (Constructor Function A (Constructor Function B A))))

This would represent:
forall a b. Num a => a -> b -> a

I'm not saying what I've suggested is a good implementation, I'm just trying to show what I mean.
Surely, if you can define the grammar of a type definition, you can create a GADT to represent it. Is there anything that already does this?

A: You are looking for the type-related ADTs in template-haskell. Note that Type is an instance of Ppr, which has the ppr pretty-print function.
ghci> import Language.Haskell.TH
ghci> :{
ghci> x <- runQ $ do
ghci|        a <- newName "a"
ghci|        b <- newName "b"
ghci|        pure $ ForallT [PlainTV a,PlainTV b] [AppT (ConT (mkName "Num")) (VarT a)] (AppT (AppT ArrowT (VarT a)) (AppT (AppT ArrowT (VarT b)) (VarT a)))
ghci| :}
ghci> x
ForallT [PlainTV a_4,PlainTV b_5] [AppT (ConT Num) (VarT a_4)] (AppT (AppT ArrowT (VarT a_4)) (AppT (AppT ArrowT (VarT b_5)) (VarT a_4)))
ghci> ppr x
forall a_0 b_1 . Num a_0 => a_0 -> b_1 -> a_0

In fact, the TemplateHaskell language extension GHC has will make playing with this surprisingly easy. Instead of having to write out the ForallT ... stuff, I can just "quote" the type I am looking for
ghci> :set -XTemplateHaskell -XExplicitForall
ghci> x' <- runQ [t| forall a b. Num a => a -> b -> a |]

And x' is the same as x (well maybe a and b end up being slightly different Names, but still)!


text:
Q: array not pulling all data from rss feed parser I am building an rss feeder and there are so many great resources out there, but literally not one of the pulls the SOURCE instead of AUTHOR. When I try to edit the code to pull the SOURCE, it displays as UNDEFINED. I see the SOURCE in the .rss file, but when I analyze the object in console, it does not actually retrieve the SOURCE data field.
Here is the found code I am trying to edit:
function parseRSS(url, container) {
  $.ajax({
    url: 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&callback=?&q=' + encodeURIComponent(url),
    dataType: 'json',
    success: function(data) {
      console.log(data.responseData.feed);
      $(container).html('
'+capitaliseFirstLetter(data.responseData.feed.title)+'
');

      $.each(data.responseData.feed.entries, function(key, value){
        var thehtml = '
'+value.title+'

' +value.source ;
        $(container).append(thehtml);
      });
    }
  });
}

function capitaliseFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

Here is my .rss xml tree:
RSS XML TREE: See the SOURCE node is there like all the rest
Here is the console object:
console object array showing that SOURCE is not being read by the parser
Any help is most appreciated! thank you!

A: You can get the XML doc and parse it. Then you control what you see and don't see.
I think the problem with using a service is that they choose what is exposed, and it looks like source isn't one of them. I just decided to get the xml doc and parse it myself (example below - requires php). I hope this helps you.
I got the source by curling the xml document then turning it into a xml document using the SimpleXMLElement - then you can traverse it pretty easily:
<?php

function get_data($url) {
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

$sXML = get_data('http://newsdesk-feeds.moreover.com/feed/a60eeb8d9fcdc35b.rss');
//$sXML = get_data('http://alanstorm.com/atom');

echo $sXML;
$oXML = new SimpleXMLElement($sXML);

foreach($oXML->channel->item as $oEntry){
    echo "
". $oEntry->source . "
"; // your source

}

Here is the DOM inspected. You literally can get anything you want. Also there are libraries out there that will probably turn this into JSON for you. It wouldn't be hard to do it yourself though either.

Here is the output of sources:


text:
Q: How can I perform the equivalent of AddHours to a DateTime in Power Query? I've seen PowerQuery expressions that can subtract days from a datetime, like DateTimeZone.UtcNow.AddDays(-1). However, I'd like to subtract hours from a DateTime, not days.
As I don't see a function like AddHours() in the Power Query specification, is there a robust way to go back a number of hours? For instance, would something like DateTimeZone.UtcNow + #duration(0, -1, 0, 0) give me a DateTime that's one hour earlier?
[Note: I'd try this myself but I can't get Power Query installed on my local box and I can't find an independent editor to try it, hence the community ask]

A: Yes, adding #duration(0, -1, 0, 0) would give you a DateTime that is one hour earlier. You could also subtract #duration(0, 1, 0, 0) from the DateTime value. These methods are robust.

A: This link has a good image detailing subtraction of hours.
https://community.powerbi.com/t5/Desktop/How-to-subtract-hours-from-DateTime-data-using-DAX/m-p/137444#M59029
I used it to subtract seven hours from dates ([End] column) when it was entered as midnight. See below:
(if Time.Hour([End]) <> 0 then [End] else [End] - #duration(0,7,0,0))

A: yourtime + 3/24   will add three hours


text:
Q: connect to MySQL data base with QSqlDatabase pyqt4 im new to python code, QT and MySQL, i wanna show a data base in a QtableView but i cant it.
i dont know whats happend, the error is ('QSqlDatabase' object has no attribute 'setHotsName')
the code is:
# -*- coding: utf-8 -*-
import sys
import mysql.connector
from PyQt4 import QtSql, QtCore, QtGui, uic
form_class = uic.loadUiType("dialog.ui")[0]

def crearConexion():
  db = QtSql.QSqlDatabase.addDatabase('QMYSQL')
  db.setHotsName('localhots')
  db.setDatabaseName('Registro')
  db.setUserName('root')
  db.setPassword('xxxx')
  db.open()
  print(db.lastError().text())
  return True

 class MiClase(QtGui.QDialog):
  def __init__(self, parent=None):
   QtGui.QWidget.__init__(self, parent)
   self.setupUi(self)
   self.model=QtSql.QSqlTableModel(self)
   self.model.setTable("RegistroIN")
   self.model.setEditStrategy(QtSql.QSqlTableModel.OnManualSubmit)
   self.model.select()
   self.tableView.setModel(self.model)
  if __name__ == '__main__':
   app = QtGui.QApplication(sys.argv)
   if not crearConexion():
     sys.exit(1)
 MiApp = MiClase()
 MiApp.show()
 sys.exit(app.exec_())

somebody that help me? thank you.


text:
Q: How could I set TimeConstrained globally? I want to set TimeConstrained globally, I tried use $PrePrint as bellowed script:
$PrePrint = TimeConstrained[#,5] &;

But there's no effect, evaluation could not be aborted within given time.
So is there any way to do this? Thanks!

A: I found the solution in another topic here
How to stop the Kernel from running wild?
SetAttributes[timecon, HoldAll]
timecon[new_] := TimeConstrained[new, 5]
$Pre = timecon;


text:
Q: Error: 404 NOT FOUND Services.js:
app.service("CRUDservices", function ($http) {

this.selectEmployees = function () {
    return $http.get("/api/Empdet/SelectEmployees");
};

this.selectEmployee = function (id) {
    return $http.get("/api/Empdet/SelectEmployee/" + id);
};

this.addEmployee = function (Empdet) {
    var request = $http(
    {
        method: "post",
        url: "/api/Empdet/AddEmployee",
        data: Empdet
    });
    return request;
};
this.updateEmployee = function (id, Empdet) {
    var request = $http(
    {
        method: "put",
        url: "/api/Empdet/UpdateEmployee/" + id,
        data: Empdet
    });
    return request;
};
this.deleteEmployee = function (id) {
    var request = $http(
    {
        method: "delete",
        url: "/api/Empdet/DeleteEmployee/" + id,
        data: Empdet
    });
    return request;
};
});

EmpdetController.cs:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using System.Web.Http.Description;
using Task1.Models;

namespace Task1.Api.Controllers
{
public class EmpdetController : ApiController
{
    private EmployeeEntities db = new EmployeeEntities();

   [HttpGet]
    public HttpResponseMessage SelectEmployees(Empdet empdet)
    {
        Collection<Empdet> Empdets =new Collection<Empdet>( db.Empdets.ToList());
        return Request.CreateResponse(HttpStatusCode.OK, Empdets);
    }

   [HttpGet]
   public HttpResponseMessage SelectEmployee(int? id)
   {
       var empdet = db.Empdets.Find(id);
       if (empdet == null)
       {
           return Request.CreateResponse(HttpStatusCode.NotFound);
       }

       return Request.CreateResponse(HttpStatusCode.OK, empdet);
   }

    [HttpPut]
    public HttpResponseMessage UpdateEmployee(int id, Empdet empdet)
    {
        if (ModelState.IsValid && id == empdet.Id)
        {
            db.Entry(empdet).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return Request.CreateResponse(HttpStatusCode.NotFound);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
        else
        {
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        }
    }

    [HttpPost]
    public HttpResponseMessage AddEmployee(Empdet empdet)
    {
        if (ModelState.IsValid)
        {
            db.Empdets.Add(empdet);
            db.SaveChanges();

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, empdet);
            response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = empdet.Id }));
            return response;
        }
        else
        {
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        }
    }

    [HttpDelete]
    public HttpResponseMessage DeleteEmployee(int id)
    {
        Empdet empdet = db.Empdets.Find(id);
        if (empdet == null)
        {
            return Request.CreateResponse(HttpStatusCode.NotFound);
        }

        db.Empdets.Remove(empdet);

        try
        {
            db.SaveChanges();
        }
        catch (DbUpdateConcurrencyException)
        {
            return Request.CreateResponse(HttpStatusCode.NotFound);
        }

        return Request.CreateResponse(HttpStatusCode.OK, empdet);
    }

    protected override void Dispose(bool disposing)
    {
        db.Dispose();
        base.Dispose(disposing);
    }
}
}

ShowempController.js:
app.controller("ShowempController", function ($scope, $location, CRUDservices, SharedData) {

$scope.loadRecords = function () {
    //CRUDservices.selectEmployees().success(function (response) {
    //    $scope.Employees = response;
    //});
    console.log('init');

    var promiseGetEmpdet = CRUDservices.selectEmployees();

    promiseGetEmpdet.then(function (pl) {

        console.log(pl);
        $scope.Employees = pl.data
        console.log($scope.Employees);
    },
        function (errorpl) {
            $scope.error = 'failure loading employee', errorpl;
        });
};

$scope.Addemp = function () {
    $location.path("/Addemp");
};
$scope.Editemp = function (Id) {
    ShareData.value = Id;
    $location.path("/Editemp");
};
$scope.Deleteemp = function (Id) {
    ShareData.value = Id;
    $location.path("/Deleteemp");
};
});

Showemp.cshtml:

List of Employees

Add Employee

            Id
            PhotoFile
            FirstName
            LastName
            Email
            Age
            PhotoText

            {{Empdet.Id}}
            {{Empdet.PhotoFile}}
            {{Empdet.FirstName}}
            {{Empdet.LastName}}
            {{Empdet.Email}}
            {{Empdet.Age}}
            {{Empdet.PhotoText}}
            <input type="button" value="Edit" ng- click="Editemp(Empdet.Id)" />
            <input type="button" value="Delete" ng-click="Deleteemp(Empdet.Id)" />

{{error}}

Whenever i try to execute this program it says error: 404 not found, its not hitting SelectEmployees in the Showempcontroller.js i have cleary mentioned in the Empdetcontroller.cs file for selecting all employees i use "SelectEmployees"  and for a single data retrieve i used "SelectEmployee and referring it by Id". But still its not hitting the file and not executing. Please Help!!!

A: Solution 1
You need to assign the  [ActionName("Name")] attribute for your action
Because Web Api only taking get, post, put,delete method name for the get and post reason

if you change the action name, then you need set the ActionName attribute

Like
[ActionName("SelectEmployees")]
[HttpGet]
    public HttpResponseMessage SelectEmployees(Empdet empdet)
    {
        Collection<Empdet> Empdets =new Collection<Empdet>( db.Empdets.ToList());
        return Request.CreateResponse(HttpStatusCode.OK, Empdets);
    }

Solution 2

*

*And also please check the Parameters. You should be pass the correct parameter object and values to your controller actions .

Solution 3
verify your paths in your WebApi config file
Making your route url look like
 config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

*

*And your url should be look like $http.get("/api/Empdet/SelectEmployees")

I hope you can solve it from my key answer :)

A: If you don't want to give any action name as suggested above
You can also use return $http.get("/api/Empdet")


text:
Q: Authentication issue with mail server I followed the instructions at https://help.ubuntu.com/community/PostfixCompleteVirtualMailSystemHowto to setup a smtp and imap server on my local network.
But when i try to login with thunderbird (after creating mailbox with postfixadmin)
I get a "Password or user name wrong error.
this is the tail of /var/log/mail.err
Jan 26 04:18:15 NightHwack imapd: Connection, ip=[::ffff:192.168.1.4]
Jan 26 04:18:15 NightHwack authdaemond: received auth request, service=imap, authtype=login
Jan 26 04:18:15 NightHwack authdaemond: authmysql: trying this module
Jan 26 04:18:15 NightHwack authdaemond: authmysqllib: connected. Versions: header 50517, client 50529, server 50529
Jan 26 04:18:15 NightHwack authdaemond: SQL query: SELECT username, password, "", '5000', '5000', '/var/mail', "", "", name, "" FROM mailbox WHERE username = 'webmaster@xincoz.com'
Jan 26 04:18:15 NightHwack authdaemond: password matches successfully
Jan 26 04:18:15 NightHwack authdaemond: authmysql: sysusername=<null>, sysuserid=5000, sysgroupid=5000, homedir=/var/mail, address=webmaster@xincoz.com, fullname=Webmaster, maildir=<null>, quota=<null>, options=<null>
Jan 26 04:18:15 NightHwack authdaemond: authmysql: clearpasswd=<null>, passwd=$1$e7d3bbc2$zWm3PmkfdCHAbz.kyRPld/
Jan 26 04:18:15 NightHwack authdaemond: Authenticated: sysusername=<null>, sysuserid=5000, sysgroupid=5000, homedir=/var/mail, address=webmaster@xincoz.com, fullname=Webmaster, maildir=<null>, quota=<null>, options=<null>
Jan 26 04:18:15 NightHwack authdaemond: Authenticated: clearpasswd=webmaster007, passwd=$1$e7d3bbc2$zWm3PmkfdCHAbz.kyRPld/
Jan 26 04:18:15 NightHwack imapd: chdir Maildir: No such file or directory
Jan 26 04:18:15 NightHwack imapd: webmaster@xincoz.com: No such file or directory

Folders in /var/mail/
webmaster
root
agent

please help me resolve this.
Thank you :)

A: You missed the postfix configuration for use with virtual domains and users.
# Virtual Mailbox Domain Settings

virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_limit = 51200000
virtual_minimum_uid = 5000
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_transport = virtual

There are other configurations you must check, as user creation and directory permissions.  These configurations are in the section 12 of the tutorial you are following.


text:
Q: How to read a file from Eclipse's path on a Dynamic Web Project? I'm using Eclipse Kepler with Tomcat 7 (localhost) and my project is a Dynamic Web Project.
I have a class that needs to load some properties files:
File dir = null;
try {
    dir = new File(globalPropertiesFolder);
} catch (NullPointerException e) {
    log.error("Could not open the specified properties folder: "
            + globalPropertiesFolder, e);
}

if (dir == null) {
    log.error("Could not open the specified properties folder: "
            + globalPropertiesFolder);
    return;
}

FilenameFilter filter = new FilenameFilter() {
    public boolean accept(File dir, String name) {
        boolean res = false;
        res = !name.endsWith("dynamic.properties");
        if (!name.endsWith(".properties"))
            res = false;
        return res;
    }
};
String[] children = dir.list(filter);

Where globalPropertiesFolder is a string that is equal to "config/properties".
I have a main in this class for testing some methods, when I run it as Java Application the properties are found, and the children variable is filled with the content of that folder, but, when I ran it the whole project on server (Tomcat) it can't find the properties.
I have noticed that the file has a different absolute path (dir.getAbsolutePath()) when I ran it as Java Application to when I ran it on server so the final question is: how can I list the files on a folder on a dynamic web project using Eclipse and Tomcat as a server?  If I can at least, list all of them, and then I can load all the files I need.

A: A reliable way to locate files both in standalone applications and in web applications, is via the classpath, like so:
    ClassLoader cl = this.getClass().getClassLoader();
    InputStream is = cl.getResourceAsStream("resources/foo.properties");

The specified file name will be searched via the class loader, i.e. relative to any of your application's class path entries. In this example you could create resources/foo.properties inside your src folder, for instance, and it would be found both in standalone and in web mode.
Unfortunately this requires you to know the relative file names in advance, i.e. you can't list them prior to loading.


text:
Q: How to get the parent folder of a folder Let's say we have:
String path = "D:\aaa\bbb\ccc"

I wonder if there is a function to modify quickly path to:
D:\aaa\bbb\ or D:\aaa\
I tried to use Paths with no luck:
path = "D:\\aaa\\bbb\\ccc";
pathNew = java.nio.file.Paths.get(path).subpath(0,2).toString();
println "${pathNew}"

Gives the next console result:
aaa\bbb

A: You can do:
String path = "D:\\aaa\\bbb\\ccc";
File parent = new File(path).getParentFile();
System.out.println(parent);

String parentStr = new File(path).getParent();
System.out.println(parentStr);

Prints:
D:\aaa\bbb
D:\aaa\bbb

A: You can do like this:
Path p1 = Paths.get("D:\\aaa\\bbb\\ccc");
Path p2 = p1.getParent();
....

A: try this
  Path path = Paths.get("your path");
  Path parentPath = path.getParent();

A: File path = new File("D:\aaa\bbb\ccc");
path.getParentFile();  // Returns "D:\aaa\bbb\"
path.getParentFile().getParentFile();  // Returns D:\aaa\"

A: File parent = new File("D:\\aaa\\bbb\\ccc").getParent();
System.out.println(parent);


text:
Q: Apply ng-blur functions return to ng-modal i have 2 input fields named data1 and data2. I have assigned a ng-blur function to it. ITs a common function for both input fields. Now i need to use this function and use it for the 2 input fields.
<input ng-model="data1" ng-blur="checkAndApplySign(data1, false);">
<input ng-model="data2" ng-blur"checkAndApplySign(data2, true);">

I am using the below function. if toNegative is set to false at the HTML, we should get all positve values returned. if it is set to true, all negative values
$scope.checkAndApplySign = function (value, toNegative) {
    return (toNegative ? -1 : 1) * Math.abs(value);
};

The problem with this is that the return function doesnot assign the values back to the input field. how do i assign it back to input field ? any ideas ?

A: I haven't tested this, but my best guess is that, assuming your models are objects, they will be passed to the function as references. Knowing this, you should just be able to assign the value directly to the input value and its relationship with the input via ng-model should update the input value.
$scope.checkAndApplySign = function (value, toNegative) {
    value = (toNegative ? -1 : 1) * Math.abs(value);
};


text:
Q: minifab floating action button in fragment not clickable I have a floating action button inside a fragment with 3 other minifabs that animate out of it in an arc.  The main FAB is working just fine and calls the animation on the miniFabs, but the miniFabs are not clickable for some reason.  I can easily access all the Fab's, but cannot access the setOnClickListener() of the minifabs.  Here's the layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:fitsSystemWindows="true">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_vertical|center_horizontal"
        android:text="@string/chatter"
        android:textColor="@color/black" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_chatter_video"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/fab_first_menu_item_margin_bottom"
        android:layout_marginEnd="@dimen/right_margin"
        android:clickable="true"
        android:focusable="true"
        android:visibility="visible"
        app:backgroundTint="@color/white"
        app:fabSize="mini"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:srcCompat="@drawable/ic_chatter_new_video"
        android:fitsSystemWindows="true" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_chatter_open"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/fab_bottom_margin"
        android:layout_marginEnd="@dimen/fab_main_right_margin"
        android:clickable="true"
        android:focusable="true"
        android:visibility="visible"
        app:backgroundTint="@color/colorPrimary"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:fabSize="normal"
        app:srcCompat="@drawable/ic_chatter_new" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_chatter_photo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/fab_first_menu_item_margin_bottom"
        android:layout_marginEnd="@dimen/right_margin"
        android:clickable="true"
        android:focusable="true"
        android:visibility="visible"
        app:backgroundTint="@color/white"
        app:fabSize="mini"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:srcCompat="@drawable/ic_chatter_new_photo" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_chatter_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/fab_first_menu_item_margin_bottom"
        android:layout_marginEnd="@dimen/right_margin"
        android:clickable="true"
        android:focusable="true"
        android:visibility="visible"
        app:backgroundTint="@color/white"
        app:fabSize="mini"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:srcCompat="@drawable/ic_chatter_new_text" />

    <LinearLayout
        android:id="@+id/main_chatter_overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha="0.45"
        android:orientation="vertical"
        android:visibility="invisible"
        android:background="@color/mainColor"
        />

</android.support.constraint.ConstraintLayout>

I am animating fab_chatter_open with this code which works just fine.  Clicking animation and all:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true" >
    <rotate android:fromDegrees="45"
        android:toDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="300"
        android:interpolator="@android:anim/linear_interpolator"/>
</set>

and reversing this animation on clicking the FAB a second time.
Then I am animating the miniFabs with this code.  The animation on the miniFabs works just fine, but the FABs are not clickable in any way:
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true" >

    <translate android:fromXDelta="82%p" android:toXDelta="65%p"
        android:fromYDelta="7%p" android:toYDelta="7%p"
        android:duration = "100"/>
    <alpha android:fromAlpha="0"
        android:toAlpha="1"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:duration="100"/>
</set>

You'll also notice a Linearlayout at the bottom.  This is to cover the recyclerView with an alpha of 50% to keep the focus on the fabs and dim the content.  Unfortunately, it doesn't cover the actionbar or the bottom navigation like I'd prefer.  If you have suggestions for accomplishing that as well, please let me know.

A: Apparently in a constrained layout when you animate a floating action button with translate, the click of the button stays where the FAB was originally drawn when the view was created and inflated.  I decided instead to use the margin bottom and margin end on my miniFabs floating action buttons:
android:layout_marginBottom=""
android:layout_marginEnd=""

to place the floating action buttons on the screen where I wanted when the view is originally drawn and inflated in relation to the main FAB.  Also, since this is a constrained layout, I used:
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
to put the buttons in the bottom right corner where the main FAB is located otherwise the margin-bottom and margin-top of these miniFabs would be much harder to calculate.
Then I am using the animate alpha and animate scale on the miniFabs.  This keeps the miniFabs in the same place for the click events but gives them some animation so they have a little flair.
I also made sure to set the isEnabled() property of each FAB to false once I set their visibility to gone otherwise the click event will still be there.


text:
Q: Printing an array I have an array of 28 characters. I'm trying to use a for loop to print the string and its length so that the next line removes the last character from the previous line. For example:
7 Example
6 Exampl
5 Examp
4 Exam
3 Exa
2 Ex
1 E

I have this so far, but it's not printing. What am I doing wrong?
for(int index=28; index <= nameArray.length; index--)
            {
                System.out.print(nameArray[index]);
            }

A: It is as simple as that ..
class A {
    public static void main(String [] args) {
        String array = "Example";

    for(int i=7;i>0;i--) {
          System.out.print(i+" ");
          System.out.println(array.substring(0, i));
        }
      }
   }

// Output :
7 Example
6 Exampl
5 Examp
4 Exam
3 Exa
2 Ex
1 E

A: If the length is 28 characters, you cannot start the index at 28.  Arrays in Java are zero-based, so that means that the index can range from 0 to 27 (length - 1).

A: Firstly, you probably want your middle condition to be index > 0, not index <= nameArray.length (which should always be true, even as you enter the negative numbers).
Secondly, is it an array of characters you're accessing? If so, then as I'm sure you know, nameArray[index] refers to a character, not a string.
(Also, as bobbymcr points out, the top index in an array of 28 elements is 27, not 28.)
To print substrings, you should first initialize a String using your character array, then print increasingly smaller substrings using substring.
For example:
private static void printSubstrings(String input) {
    for (int length = input.length(); length > 0; length--) {
        System.out.printf("%d %s\n", length, input.substring(0, length));
    }
}

Then, if nameArray is a char[], you could use the String(char[]) constructor to pass to this method:
printSubstrings(new String(nameArray));

Example input:
char[] nameArray = new char[] { 'E', 'x', 'a', 'm', 'p', 'l', 'e' };
printSubstrings(new String(nameArray));

Output:
7 Example
6 Exampl
5 Examp
4 Exam
3 Exa
2 Ex
1 E

A: Always remeber that the array indexes start from 0
[E][x][a][m][p][l][e]
 0  1  2  3  4  5  6

I don't understand why you break your head with char arrays, when you have String.
Here i propose you a solution where:
1-transform the char[] to String
2-Iterate the String object and use the some methods from the String class to get the desired result:
public class Example
{
   public static void main(String[] args) {

       //Here an array with 28 characters
       char[] array = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'
           ,'q','r','s','t','u','v','w','x','y','z','!','@'};

      //For easier manipulation i will just transform that array to String
      //Why not, String was invented so we dont have to use char[].
      String arrayAsString = new String(array);

    //Use the methods that String class provides, to make the solution easier
    for(int i=0;i < array.length;i++) {
      System.out.println((i+1) + " " +  arrayAsString.substring(0,(arrayAsString.length()-i)));
    }
    }
}

A: for(int index=28; index <= nameArray.length; index--)

First off, you're trying to start at index 28 - that doesn't exist. Arrays are 0 based which means they go from 0 to length - 1
Second, you're saying that the index has to be less than or equal to the length. Since you're going from the end to the start, that would always be true.
for (int index = nameArray.length - 1; index >= 0; index--)

That's what you're looking for.


text:
Q: SEO: Duplicated URLs with and without dash "/" and ASP.NET MVC after reading this article "Slash or not to slash" (link: http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html) on Google Webmaster Central Blog (the oficial one) I decided to test my ASP.NET MVC app.
For example:
http://domain.com/products and http://domain.com/products/ (with "/" in the end), return the code 200, which means: Google understands it as two different links and likely to be a "duplicated content". They suggest to choose the way you want... with or without dash and create a 301 permanent redirect to the preferred way.
So if I choose without dash, when I try to access http://domain.com/products/ it will return a 301 to the link without dash: http://domain.com/products.
The question is, how can I do that with ASP.NET MVC?
Thanks,
Gui

A: If your using IIS 7 you could use the URL Rewrite Extension ScottGu has a blog post about it here.
Alternatively if you want to do it in code you could inherit from PerRequestTask. Here some sample code the removes the www from an address - this is from Shrinkr:
public class RemoveWww : PerRequestTask
{
    protected override TaskContinuation ExecuteCore(PerRequestExecutionContext executionContext)
    {
        const string Prefix = "http://www.";

        Check.Argument.IsNotNull(executionContext, "executionContext");

        HttpContextBase httpContext = executionContext.HttpContext;

        string url = httpContext.Request.Url.ToString();

        bool startsWith3W = url.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase);
        bool shouldContinue = true;

        if (startsWith3W)
        {
            string newUrl = "http://" + url.Substring(Prefix.Length);

            HttpResponseBase response = httpContext.Response;

            response.StatusCode = (int) HttpStatusCode.MovedPermanently;
            response.Status = "301 Moved Permanently";
            response.RedirectLocation = newUrl;
            response.SuppressContent = true;
            response.End();
            shouldContinue = false;
        }

        return shouldContinue ? TaskContinuation.Continue : TaskContinuation.Break;
    }
}

You would just need to check for the url ending with a / in your code.
** Note this does use a 3rd party dll - System.Web.MVC.Extensibility namespace. **

A: It dosnt matter really for Google, but what does matter is if both urls'
http://domain.com/products and http://domain.com/products/ show the same page, you also need to watch with windows servers that links to your site like from external pages where the user has typed http://domain.com/PRODUCTS/ will aloso be seen as a diffrent page as the web is case sensitive.
There is away round this with the use of canonical url meta tag, it tell s google what the page name is really, so will avoid duplicate pages which ant really diuplicate
http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html

A: you need to check the URI in the INIT event and check the URI to see if it coming in with the slash, if it is, simply do a redirect and add the 301 header to the output response.


text:
Q: Display info bottom margin of visual studio how can i display information in red frame like below of visual studio?

https://i.stack.imgur.com/1mL2d.png

A: Tools > Options > Text Editor

A: I found the reason:
https://i.stack.imgur.com/Yefy6.png
sorry, i can't post the image


text:
Q: How to access a site blocked by OpenDNS I'm using OpenDNS to filter some of the content my kids can get to on our home network. Is there any way to access a site that's being blocked without whitelisting it? For example, there are some humor sites I don't want my kids to go to but I enjoy - but with OpenDNS it seems to be all or nothing. Is there any way around this, like a password to access the site or something?

A: I don't think you can do it using strictly OpenDNS.  Others have requested a similar feature, e.g. http://ideabank.opendns.com/story.php?title=Password_Overwride.
But if you are using OpenDNS on your router and you use a separate computer from your kids, you can circumvent OpenDNS by setting your computer's DNS server to the one given by your ISP or 4.2.2.2.
Oh, and restrict access to the DNS settings on your kids computers in case they read SuperUser.

A: Extending on YHVH's answer, you can get the site's IP address (using something like NetworkTools for example), then put it in your "hosts file".
On Windows, this should be something like C:\WINDOWS\system32\drivers\etc\hosts (may be different on 64bit), and on Linux its in /etc/hosts
Both files have the same format:
IPAddress www.example.com example.com
Where "IP Address" is the IP, and the variations of "example.com" are the domain name. With that in mind, YHVH's example would be:
69.59.196.219 superuser.com

A: Hmm, you could try adding .nyud.net to the domain you want to visit, for example:

www.superuser.com.nyud.net

Perhaps this trick can circumvent the OpenDNS blocking system...?

A: If you and your kids are using different computers, you can use your ISP's DNS server on your PC and OpenDNS on the PCs which are used by your kids.
@YHVH: The »solution« you posted won't work. ping will use the default system's DNS server to resolve the ip address. You will have to use nslookup and tell the program to use another DNS server.

A: DNS and therefore OpenDNS simply resolves the name of the site to an IP address e.g., superuser.com resolves to 69.59.196.219
Simply find out the IP address of the sites you want to visit and keep a record of them.
You can do this from another computer or change your OpenDNS settings until you're finished.

*

*Open command prompt/terminal

*Type ping sitename.com

*Record the IP address

Now when you want to visit the site type in the IP address instead of the site name.

A: Simply typing in the IP address won't work very well for two reasons.
First, the reason mentioned already - many hosts send back the web page you are requesting based on the domain name you requested, not just because you happened upon the server by IP address.
Second, even if you do get the site to respond, chances are that the links inside the site (pictures, buttons, page links, etc) will request using the domain name, and not the IP address.  So even if you get the page framework, you might only see the text, with pictures, script, and other elements missing or malfunctioning.


text:
Q: Relational Sets for Reflexive, Symmetric, Anti-Symmetric and Transitive I just want to brush up on my understanding of Relations with Sets. Specifically with this set:
$\{ 1, 2, 3 \}$
I understand Reflexive, Symmetric, Anti-Symmetric and Transitive in theory. But if it's not too much trouble, I'd like some help producing the appropriate R (relation) sets with the set above. So in a nutshell:
Question: What's the Relation sets for Reflexive, Symmetric, Anti-Symmetric and Transitive on the following set?:
$\{ 1, 2, 3 \}$
Answer:
I've got some of them solved, but will complete my answer when I've figured out the rest.
Reflexive: $\{(1,1),(2,2),(3,3)\}$
Symmetric: $\{?\}$
Anti-Symmetric: $\{?\}$
Transitive: $\{(2,2),(2,3),(3,2),(3,3)\}$

A: First of all find $A\times A$ wherein $A=\{1,2,3\}$. So, we have $$A\times A=\{(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3)\}$$ Now try to choose some subset of above set as relations on $A$, since we know that every relation on $A$ has the form $R\subseteq A\times A$. For example $R_1=\{(1,1),(2,2),(3,3)\}$ is reflexive. $R_2=\{(1,1),(1,2),(2,1),(2,2)\}$ is reflexive, transitive and symmetric. Now try to find other relations according to what you have learnt about them.


text:
Q: Get XML attribute name (not value) using PHP      <Parent>
  <Children idontknowthis='thisisnotmyquestion'>
   <x>1</x>
   <x>2</x>
   <x>3</x>
   <x>4</x>
  </Children>
 </Parent>

Example an .xml file I'm working with below. My script would need to establish "id" by itself (to be clear I can already get bk109)...
   <book id="bk109">
      <author>Kress, Peter</author>
      <title>Paradox Lost</title>
      <genre>Science Fiction</genre>
      <price>6.95</price>
      <publish_date>2000-11-02</publish_date>
      <description>After an inadvertant trip through a Heisenberg
      Uncertainty Device, James Salway discovers the problems
      of being quantum.</description>
   </book>

For the purpose of an XML import script in PHP which will import many different XML files. How do I obtain the attribute names? (i.e. "id")

A: Use SimpleXML's attributes property.
See http://php.net/manual/en/simplexmlelement.attributes.php


text:
Q: How do I Uninstall SQL Server 2016 (64-bit) in Windows 10 Apps & Features How do I Uninstall SQL Server 2016 (64-bit) in Windows 10 Apps & Features when Modify and Uninstall button is displayed but faded out and not accessible.
I have managed to uninstall all related SQL programs, but I am stuck with SQL Server 2016 (64-bit).
I have deleted the all Microsoft SQL servers folders in C:\Program Files and C:\Program Files (x86), I have deleted all SQL files related to SQL in the Registry. I have deleted all related SQL service files, but still SQL Server 2016 (64-bit) shows up in Apps & features. I assume there are some SQL files I did not have the guts to delete.
And I am not able to see any SQL files in Programs and Features.
From where does the SQL Server 2016 (64-bit) in Apps & features comes from? I like to delete SQL Server 2016 (64-bit) from Apps & features, before I do a new SQL installation.
Thanks,


text:
Q: frame doesnt changes while orientation in ipad In my root view controller's viewDidLoad, i added an observer for orientation detection:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willRotateToInterfaceOrientation:duration:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];

Added the method like:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                duration:(NSTimeInterval)duration {
    NSLog(@"%f,%f",self.view.frame.size.width,self.view.frame.size.height);
}

I was expecting the result 768,1004 for the portrait and 1004,768 for the landscape. But my result is 768,1004 for the both. sometimes it will be 748,1024 for the portrait. I dont know why this strange behaviour. If you know the solution please help me.
EDIT
This same code works in my another project and i couldnt find any difference between them

A: Add these two methods:
- (BOOL)shouldAutorotate
{
      return TRUE;
}

- (NSUInteger)supportedInterfaceOrientations
{
     return UIInterfaceOrientationMaskAll;
}

And do all modifications here:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)  interfaceOrientation duration:(NSTimeInterval)duration
{
     NSLog(@"%f,%f",self.view.frame.size.width,self.view.frame.size.height);
}

A: [If you look at Apple's documentation for willRotateToInterfaceOrientation, it says]:

Sent to the view controller just before the user interface begins
  rotating.

This means the frame width & height should be for the orientation before rotating.
Perhaps if you try to get the frame coordinates after the rotation is done, say, during didRotateFromInterfaceOrientation, you might see something more like what you were hoping to accomplish.

A: First off, you don't need to add an observer for that notification, view controllers are sent this notification by default. So, remove those first two lines, and it should work properly. And since this is the "will" method, properly means you get the size of the view before the rotation.
However, the method, willAnimateRotationToInterfaceOrientation:duration:, does give you the dimensions of the view after the rotation if that's what you want (even though it's a "will" method).
After Edit
For some reason these methods work correctly for a controller embedded in a navigation controller, but not for a single controller, or a modal controller. For those situations, switching from bounds from frame, fixed the problem.


text:
Q: NumPy: Iterating over items to right, bottom of given element w/ its index Suppose I have a NumPy array like the following:
a b c d
e f g h
i j k l
m n o p

How could I iterate over it in the specific way below, given by the following pseudocode:
upperdiag = {a, b, c, e, f, i}
for each element i in upperdiag:
    for each element j below i, while j is in upperdiag:
        for each element k right of i, while k in is upperdiag:
            function(element j, element k) # do something

I.e. "below" the element a includes {e, i, m}, and "right of" a includes {b, c, d}.
I'm having trouble with the indices, and was also wondering whether there was a built-in NumPy function for the iteration.

A: Assuming a square matrix:
mat = array([['a', 'b', 'c', 'd'],
             ['e', 'f', 'g', 'h'],
             ['i', 'j', 'k', 'l'],
             ['m', 'n', 'o', 'p']],
             dtype='|S1')

def enum_upperdiag(mat):
   n = len(mat) - 1
   for row in range(n):
      for col in range(n):
         if row + col >= n: break
         for j in range(row+1,n):
            for k in range(col+1, n):
               if j + k > n: continue
               indexOf_j = (j, col)
               indexOf_k = (row, k)
               yield indexOf_j, indexOf_k

running
[(mat[j], mat[k]) for j, k in enum_upperdiag(mat)]

yields
[('e', 'b'), ('e', 'c'), ('i', 'b'), ('f', 'c'), ('i', 'f')]

if this is acceptable, then you can run it as follows:
for j,k in enum_upperdiag(mat):
   function(mat[j],mat[k])

this can also be tightened into a single list comprehension:
enum_upperdiag = lambda mat: (((j,c),(r,k)) for n in [len(mat)-1]
                                 for r in range(n) for c in range(n-r)
                                 for j in range(r+1,n) for k in range(c+1,n-j+1))


text:
Q: Extracting themes to different css using webpack 5 I am trying to extract different scss entries to separate css bundle files
My folder structure goes something like:

*

*src

*

*themes

*

*red.scss

*blue.scss

*index.js

red.scss and blue.scss are importing other (same) .scss files
index.js doesnt import any .scss
i want my output to be:

*

*index.js or bundle.js

*blue.css

*red.css

i used minicssextractplugin, to do the job, but all i got was:

*

*index.js

*blue.js

*red.js

Used many tutorials but most of them are compatible with webpack 4.
Used optimization, splitChunks, cacheGroups etc
All kind of different entry cases
My dependencies are:
  "devDependencies": {
    "@babel/core": "^7.12.10",
    "@babel/plugin-proposal-object-rest-spread": "^7.12.1",
    "@babel/preset-env": "^7.12.11",
    "babel-loader": "^8.2.2",
    "babel-polyfill": "^6.26.0",
    "clean-webpack-plugin": "^3.0.0",
    "css-loader": "^5.0.1",
    "file-loader": "^6.2.0",
    "mini-css-extract-plugin": "^1.3.3",
    "node-sass": "^5.0.0",
    "sass-loader": "^10.1.0",
    "style-loader": "^2.0.0",
    "url-loader": "^4.1.1",
    "webpack": "^5.11.0",
    "webpack-cli": "^4.2.0"
  },

I cant copy my webpack.config.js in here, getting error about format
Here are some parts:
  entry: {
            red: path.resolve(__dirname, 'src/themes/red/'),
            blue: path.resolve(__dirname, 'src/themes/blue/'),
        },
        //devtool: 'source-map',
        //entry: './src/index.js',
        //entry: ['./src/index.js', './src/css/index.scss'],
        //entry: {
        //    //default: './src/default.js',
        //    blue: './src/themes/blue',
        //    red: './src/themes/red'
        //},
        //entry: {
        //    //index: './src/index.js',
        //    //main: './src/index.js',
        //    //styles: ['./src/themes/red.scss', './src/themes/default.scss', './src/themes/blue.scss']

        //    default: ['./src/default.js', './src/themes/default.scss'],
        //    red: ['./src/red.js', './src/themes/red.scss'],
        //    blue: ['./src/blue.js', './src/themes/blue.scss'],
        //},

  output: {
            path: path.resolve(__dirname, 'wwwroot/dist'),
            filename: '[name].js'
            //sourceMapFilename: '[name].js.map'
          },

 optimization: {
            splitChunks: {
                cacheGroups: {
                    redStyles: {
                        name: 'styles_red',
                        test: (m, c, entry = 'red') =>
                            m.constructor.name === 'CssModule' &&
                            recursiveIssuer(m, c) === entry,
                        chunks: 'all',
                        enforce: true,
                    },
                    blueStyles: {
                        name: 'styles_blue',
                        test: (m, c, entry = 'blue') =>
                            m.constructor.name === 'CssModule' &&
                            recursiveIssuer(m, c) === entry,
                        chunks: 'all',
                        enforce: true,
                    },
                },
            },
        },

module: {
            rules: [

                {
                    test: /\.s[c|a]ss$/,
                    include: path.resolve(__dirname, 'src'),
                    use: [
                        devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
                        'css-loader',
                        'sass-loader',
                    ]
                },
                //{
                //    test: /\.js$/,
                //    include: path.resolve(__dirname, 'src'),
                //    loader: 'babel-loader',
                //    options: {
                //        presets: ["@babel/preset-env"],
                //        plugins: ['@babel/plugin-proposal-object-rest-spread']
                //    }
                //},
                {
                    test: /\.(png|jpg)$/,
                    include: path.resolve(__dirname, 'src'),
                    use: {
                        loader: "file-loader"
                    }
                }
            ]
        }

 plugins: [
            new webpack.ProvidePlugin({
                $: 'jquery',
                jQuery: 'jquery'
            }),
            //new FixStyleOnlyEntriesPlugin(),
            new MiniCssExtractPlugin({
                filename: "[name].css",
            }),
            //new MiniCssExtractPlugin({
            //    filename: "[name].css",
            //    //chunkFilename: "[name].css"
            //})
            //new MiniCssExtractPlugin({
            //    filename: '[name].css'
            //}),
            //defaultTheme,
            //redTheme,
            //blueTheme
        ]

A: (copy of my answer)
my case: webpack 5 + multipage application + themes.css via entry points
solution: https://github.com/webdiscus/webpack-remove-empty-scripts
this plugins don't work with webpack 5 entry points or with MiniCssExtractPlugin:
webpack-fix-style-only-entries,
webpack-extraneous-file-cleanup-plugin,
webpack-remove-empty-js-chunks-plugin,
webpack-delete-no-js-entries-plugin.
my webpack.config.js:
const fs = require('fs');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');

const isProd = process.env.NODE_ENV === 'production';
const isDev = !isProd;

const PAGES = ['app', 'help'];

const getThemes = (themePath, alias) => {
  let themes = {};
  const longPath = './' + alias + '/' + themePath;
  fs.readdirSync(longPath).forEach(function(fileName) {
    const fileNameWithPath = path.join(themePath, fileName);
    const fileNameWithLongPath = path.join(longPath, fileName);

    const stat = fs.lstatSync(fileNameWithLongPath);
    if (stat.isDirectory()) return;
    if (!/\.scss$/.test(fileName)) return;

    const nameWithoutExt = path.basename(fileName, '.scss');
    themes[nameWithoutExt] = ['./' + fileNameWithPath];
  });
  console.log(themes);
  return themes;
};

const themes = getThemes('scss/themes', 'src');

const getFilename = (filename, ext) => {
  let name = filename == 'index' ? 'bundle' : filename;
  const isTheme = (ext == 'css' && name.startsWith('theme')) ? true : false;
  const needHash = (isDev || isTheme) ? false : true;
  return needHash ? name +`.[fullhash].` + ext : name+'.'+ext;
};

const getCSSDirname = filename => {
  const isTheme = filename.startsWith('theme');
  return !isTheme? '/css/' : '/css/theme/';
};

const getHTMLWebpackPlugins = arr => {
  // this function config multipages names and add to html-pages
  // inside <head> tag our themes via tag <link rel="stylesheet" href="....css" ...>
  // and return array of HTMLWebpackPlugins
};

module.exports = {
// ... //
  entry: {
    // mutipage:
    app:  ['./index.js', './scss/app.scss'],
    help: ['./help.js', './scss/help.scss'],
    // multitheme:
    ...themes,
  },
  optimization: {
    removeEmptyChunks: true, // not work!!!
  },
  // ... //
  plugins: [
    // ... //
    ...getHTMLWebpackPlugins(PAGES),
    new RemoveEmptyScriptsPlugin({
      ignore:  PAGES,
      enabled: isDev === false,
    }),
    new MiniCssExtractPlugin({
      filename: pathdata => {
        return getCSSDirname(pathdata.chunk.name) + getFilename(pathdata.chunk.name, 'css');
      },
      chunkFilename: isDev ? '[id].css' : '[id].[contenthash].css',
    }),
  ],
};

my src files:
[src]:
 - index.js
 - index.html
 - help.js
 - help.html
 - [scss]:
 - - app.scss
 - - help.scss
 - - [themes]:
 - - - light.scss
 - - - dark.scss
 - - - blue.scss

after build:
[dist]:
 - app.js
 - index.html
 - help$hash.js
 - help$hash.html
 - [css]:
 - - app$hash.css
 - - help$.css
 - - [themes]:
 - - - light.css
 - - - dark.css
 - - - blue.css


text:
Q: build static tablename with part of another cell and use in a formula I need in a cell the year for select the right table:
I have this formula in a cell:
='August 2014'!D$37

And I need somethink like that:
='August $B$2'!D$37

But i dont know how i can connect the tablename from a static value and a variable part from another cell.

A: Try to use this formula:
=INDIRECT("'August " & $B$2 &"'!" & CELL("address",D$37))


text:
Q: Why http1.1 still has multiple tcp connections http1.1 used a permanent connection to process client request, why it still established multiple tcp connections. for example, I use open the site "www.baidu.com" in google chrome, and I found the tcp connections on my computer as following:
tcp        0      0 192.168.1.123:45939     115.239.210.26:80       ESTABLISHED 2801/chrome
tcp        0      0 192.168.1.123:45955     115.239.210.26:80       ESTABLISHED 2801/chrome
tcp        0      0 192.168.1.123:45938     115.239.210.26:80       ESTABLISHED 2801/chrome
tcp        0      0 192.168.1.123:45937     115.239.210.26:80       ESTABLISHED 2801/chrome
"115.239.210.26" is the site's IP address.
Somebody help me ! Thank you very much!

A: This is for displaying the web page faster by downloading the various assets ( (java)scripts, images etc ) in parallel. In addition to it, the client side javascript may also decide to open multiple connections to the server.
There are setting to reduce/increase the number of simultaneous open connections in various browsers. 4 is the default in almost all the browsers.


text:
Q: External page load issue in Windows 8 App I'm directly showing some external web page in my Windows 8 app, and this external page loads too much delayed at times and some times it does not load all. Someone please help me to overcome this problem. I'm using XAML/C# for the app.
following is my code to load the external page, how can I check weather the page is loaded properly in the app?
this.InitializeComponent();
textboxUri.Text = "http://www.google.com/";
WebView1.Navigate(new Uri(textboxUri.Text));

A: The Webview class has a LoadCompleted event, I would imagine you want something like this (pseudo code):
{
    textboxUri.Text = "http://www.google.com/";
    WebView1.Navigate(new Uri(textboxUri.Text));

    WebView1.LoadCompleted += LoadCompletedEvent;
}

void LoadCompletedEvent(object sender, eventargs e)
{
    //Now the website has loaded, do what you want here
}

A: I suggest you have a look here to the MSDN sample code:
http://code.msdn.microsoft.com/windowsapps/XAML-WebView-control-sample-58ad63f7/sourcecode?fileId=57963&pathId=298223712
Hope this will help you :)


text:
Q: Surjective function has a right inverse We claim that if a function $f\colon A\to B$ is surjective, then it has a right inverse. We assume the Axiom of Choice, which states that given a family of nonempty subsets of a set, there is a way to choose one element in each member of the family.
Assume $f\colon A\to B$ is surjective. We will show that there exists $g\colon B\to A$ such that
$$f\circ g = id_B.$$
Consider first the family defined by
$$S = \{f^{-1}(q) \mid q\in B\}.$$
We will show that this is a family of nonempty, disjoint subsets of $A$.
Let $b \in B$ be arbitrary so $f^{-1}(b) \in S$. As $f\colon A \to B$, it follows that $f^{-1}(b)\subseteq A$.
As $f$ is surjective, there exists some $a\in A$ such that $f(a) = b$ so $a \in f^{-1}(b)$ hence $f^{-1}(b)$ is nonempty.
Finally, suppose there exist distinct $b_1,b_2 \in B$ such that
$$ f^{-1}(b_1)\cap f^{-1}(b_2) \not = \emptyset.$$
Then let $a\in f^{-1}(b_1)\cap f^{-1}(b_2) $ which leads to $b_1 = f(a) = b_2$, which contradicts the fact that $b_1$ and $b_2$ are distinct.
Consequently, $S$ is a family of nonempty, disjoint subsets of $A$.
Let $b \in B$. Then $f^{-1}(b) \in S$ so by the Axiom of Choice, there is a way to choose an element of $f^{-1}(b)$.
Call such a choice $a$. As $f^{-1}(b)\subseteq A, a\in A.$
Define $g\colon B\to A$ as $g(b) = a$ where $a$ is chosen as above. We will show that $g$ is a right inverse of $f.$ First, we will show that $g$ is a function.
Let $b\in B. $ Then such a choice exists thus every $b\in B$ has an image in $A$ under $g$. Since we choose exactly one element $a \in f^{-1}(b), $ it follows that this image is unique.
Finally, we have
$$f\circ g (b) = f(g(b)) = f(a) = b $$
as $a \in f^{-1}(b)$ and we are done.
This is the first time I have written a proof using the Axiom of Choice and while I think that my argument is correct, I am not very sure whether it is precisely written. Please see if my proof is correct and suggest ways to improve the clarity of the same.


text:
Q: Why thin behind nginx? Deploying my first web app. I have been using thin, it's simple and easy. All I need is a config file.
But a lot of people use nginx and place a couple thin instance behind that. Why? Why not just use thin alone? And why use nginx rather than placing 3 thin instances behind a single thin instance?
Thanks

A: Scalability is the main reason.  While Thin can do SSL, serve static files, and handle large responses to slow clients, Nginx is better at all of them for any given CPU and memory footprint.  Even better, Nginx can do all that transparently so that the app doesn't have implement anything to benefit.  It's also a decent load balancer.
Once your app scales beyond one machine, you will need something like Nginx anyway, and there is no harm in implementing it from the start.  Even if your app doesn't need to scale, there are other reasons for using Nginx --- especially if you're running more than one web app on the same machine, or if the app is modular.


text:
Q: Python creates %USERPROFILE% folder I am following this link to create a cookie-cutter projet on Windows 10.
During the process at this step;

python3 -m pipx ensurepath

I used python instead of python3, but I am using python 3.7.
The folder %USERPROFILE% gets created, with that name. (Not the windows shortcut).
How to explain this folder creation? How to prevent it from being created?


text:
Q: Upload file using arrow mark in webdriver I have to upload an excel file in the application.For that, I need to click on one arrow mark (i.e;browse button)which will open up the popup for the user to choose the file from local drives.Below is the code displayed when I did inspect element on the arrow mark.
 "  ".
Also, the path which will display after choosing the file will be greyed out before user selects the file. This will be enabled only when the user chooses some file from the  local.
I was trying below code but it did not work. I think send keys is wrong option as the text path is greyed out.
Help me on this.
WebElement El = driver.findElement(By.id("'uploadInp'"));
    driver.findElement(By.id("uploadInp")).click();
    El.sendKeys("D:\\NTN 4\\Demo\\BulkCart_Template.xlsx");

Arrow HTML code:-
<input id="file1" type="file" value="" style="background-color: red;opacity:0;filter:alpha(opacity=0);cursor: pointer; padding-top:3px;width:25px;" name="file">

A: You do not need to click on browser button or open any pop-up. sendkeys will going to dump your path in HTML DOM for you
So don't click on browser button while use the same button element to perform sendkeys like below:-
WebElement El = driver.findElement(By.id("'uploadInp'"));
El.sendKeys("D:\\NTN 4\\Demo\\BulkCart_Template.xlsx");

Now you need to click on element which is going to start your upload. As you didn't mention and it's unclear according to your question that which element going to upload your file. Just find that element and click on it normally.
Hope it will help you :)


text:
Q: Trouble using C file IO with lex I'm implementing a lex version of a simple scanner I've coded in standard C. What I'm having trouble with is that I/O isn't behaving the way I expect in the lex file. fscanf will not store strings and will store integers as 0 in the variables I indicate. fgetc returns characters that are not present in my test file. Is there anything (or something lacking) in my code below that jumps out as to why this is happening? Is how I'm using lex totally wrong?
scanner-lf.l:
%{
#include <stdio.h>
#include <stdlib.h>
extern int lineno;
extern int number;
extern char string[];
extern FILE *yyin;
#define INTEGER 1
#define FLOAT 2
#define READ 3
#define WRITE 4
#define ID 5
#define LPAREN 6
#define RPAREN 7
#define PLUS 8
#define MINUS 9
#define MULT 10
#define ASSIGN 11
#define DIV 12
#define COMMENT 13
#define ERROR 14
%}

%%
[ \t] {
    printf("whitespace\n");
}
[0-9]* {
    fscanf(yyin, "%d", &number);
    printf("%d\n", number);
    int c = fgetc(yyin);
    printf("%c", c);
    /*return INTEGER;*/
}
[a-zA-Z][a-zA-Z0-9]* {
    fscanf(yyin, "%s", string);
    printf("%s\n", string);
    /*return ID;*/
}

scanner-lex.c:
#include <stdio.h>
#include <stdlib.h>
/* A couple of globals */
int lineno = 0;
int number;
char string[100];
FILE *yyin;
char charSet[] = { '(', ')', '+', '-', '*' };
#define INTEGER 1
#define FLOAT 2
#define READ 3
#define WRITE 4
#define ID 5
#define LPAREN 6
#define RPAREN 7
#define PLUS 8
#define MINUS 9
#define MULT 10
#define ASSIGN 11
#define DIV 12
#define COMMENT 13
#define ERROR 14

int yywrap(){
}

int main(int argc, char **argv){
    int rc;
    if (argc > 1){
        yyin = fopen(argv[1], "r");
        while ((rc=yylex())){
            switch (rc){
                case READ:
                printf("found a read\n");
                break;
                case WRITE:
                printf("found a write\n");
                break;
                case ID:
                printf("found an id\n");
                break;
                case LPAREN:
                printf("found an (\n");
                break;
                case RPAREN:
                printf("found an )\n");
                break;
                case PLUS:
                printf("found an +\n");
                break;
                case MINUS:
                printf("found an -\n");
                break;
                case MULT:
                printf("found an *\n");
                break;
                case ASSIGN:
                printf("found an assign\n");
                break;
                case DIV:
                printf("found a /\n");
                break;
                case INTEGER:
                printf("found an integer\n");
                break;
                case FLOAT:
                printf("found a float\n");
                break;
                case COMMENT:
                printf("found a comment\n");
                break;
                case ERROR:
                printf("Error\n");
                break;
            }
        }
    }
    return 0;
}

A: This is wrong.
[0-9]* {
    fscanf(yyin, "%d", &number);
    printf("%d\n", number);
    int c = fgetc(yyin);
    printf("%c", c);
    /*return INTEGER;*/
}

Lex reads from a file into its internal buffer, and then runs the specified action when the given pattern is maximally matched.
Let's look at an example from the Flex manual:
{DIGIT}+    {
            printf( "An integer: %s (%d)\n", yytext,
                    atoi( yytext ) );
            }

As you can see,

*

*The example pattern uses + instead of *.  You don't want to try to match the empty string, so you should use + too.

*The contents of the matched pattern are stored in yytext.  You should not try to read the pattern from the file using fscanf(), because the matched text has already been read by lex.  So, simply use number = strtol(yytext, NULL, 10); in your action.  (DO NOT use atoi(yytext) or sscanf(yytext, "%i", &number) -- these will give bad output if your number has a leading zero.)


text:
Q: ElasticSearch: Show partial match for multi search even if one field does not match I am currently trying to do a multi search query on first name, last name, and date of birth. I want the results to show a complete match for first, last, and dob but also show results if the first name and last name match but a different date of birth exists then what was queried on.
As of right now my code only returns a result if all three fields have exact matches
GET /account/data/_search
{
  "query": {
    "match": {
      "first": {
        "query": "Chris"
      }
    }
  },
  "query": {
    "match": {
      "last": {
        "query": "Johnson"
      }
    }
  },
  "query": {
    "match": {
      "dob": {
        "query": "10-10-1990"
      }
    }
  }
}

A: This can be solved with simple bool query
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "first": "TEXT"
          }
        },
        {
          "match": {
            "last": "TEXT"
          }
        }
      ],
      "should": [
        {
          "match": {
            "dob": "TEXT"
          }
        }
      ]
    }
  }
}