text:
Q: Angular Optimization: How APP_INITIALIZER can read response from HTTP Request made outside of it I am trying to do performance optimization in Angular site and making a call HTTP Request as part of Index.html to fetch data in parallel to Angular Javascript application being loaded.
I am setting the value 'window.appData' once the HTTP Request is completed.
I would like to make APP_INITIALIZER to wait until window.appData is set before returning the promise. Ideally, I would like to keep polling every 100 millisecond to test for window.appData != null and once it is set return true for remaining application to be loaded.
Sometimes this works; if HTTP Request is complete; but in case http request is not complete. I would like APP_Initializer to keep polling til it's  completed.
Any help or recommendations would be helpful.
// Code in Index.html

fetch(window.config.apiUrl + '/api/v1/resource/GetData')
           .then(function(response) {
             return response.json();
           })
           .then(function(myJson) {
             window.myData = myJson;
}

A: You can use some shared storage like local storage and wait to be filled with data.
However, it is very risky what you want to do and you should consider it twice before implementation. This kind of architecture leads to many bizarre errors in future. Those can be difficult to find and fix.
Some possible problems:

*

*What if your data request fails? Angular cannot start?

*Synchronization (Angular / none-Angular part)

*In the future your Angular app can do many more things. You will prevent entire app working by one data request (by waiting in app initializer)

*What user can think looking in blank page? Is something happen or page is broken? How much it takes to load?

The key questions you should consider are:

*

*How big / long is the request? Is it worth to optimize in this manner? How it takes? 100 ms, 200? How much data weight?

*Do you need data in APP_INITIALIZER or want to use it only in synchronization purposes?

*All the app needs those data or some component only?

I encourage you back to the drawing board.
As far as you don't have exceptional situation, you should load the Angular application and then get data displaying a spinner or splash screen for the user.
In this case you have full controll for i.e. request fails and loader is friendly for the user.
If you have some exceptional situation, please describe it.

A: Thank you Walter for your response. I do know the implications of it; but I would expect the API to complete the request before the Angular Application is loaded in 90% of the cases; I went with below implementation.
initializeApp(): Promise<any> {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        const siteSettings = window.siteSettings;
        if (siteSettings !== null) {
          resolve();
        } else {
          const subscription = interval(25).subscribe(() => {
            const siteSettings2 = window.siteSettings;
            if (siteSettings2 !== null) {
              subscription.unsubscribe();
              resolve();
            } else {
              // If wait exceeds threshold; fall back to the default flow and load
              // using angular ajax call
            }
          });
        }
      }, 0);
    });
  }


text:
Q: SSRS dynamic - parent parameter not passing to the child parameter if parent parameter is hidden I want to do as cascade parameter on my dates parameter - startdate, Enddate to be Set on Default values when I select some other Parameter1. I have function on sql side based on lets say "Parameter1" it returns startdate, enddate. But when I'm selecting other values for the parameter1 then startdate, enddate not gets updates dynamically.
So I did some code change on the dataset with + row_number as extension. Now I have updates dynamically on my dates with extension. I want to hide parameters startdate, enddate and I created startdateNew, enddateNew (date format calendar) by removing on expression that row_number extension.
After all that now I'm facing the issue that is parameter startdate, enddate are hidden it's not working dynamically. When they are visible it works fine.
Basicly hiding parameter prevents other dependent parameters from refreshing... how to handle it?

A: I was able to duplicate your issue. While I can't find a reference to support my supposition, I believe that hidden parameters (even those with a default value) are not evaluated until rendering, which would explain this behavior. Data sets that drive parameter values are run prior to the report being rendered.
As you're talking about having trouble with dependencies between the parameter values, I assume you're using queries to drive your available values for parameters three and four. If this is the case, then simply embed the logic that relates the value(s) of parameter 1 to the value(s) of parameter 3 into the query that drives parameter 3's available values. By cutting out Parameter 2 and incorporating it into the query logic for parameter 3, you will work around this issue.
If you're having trouble accomplishing this, reply in a comment and I'll see if I can help. As it stands, I don't know enough about what you're trying to do to help any more.

redpajama_set_name: RedPajamaStackExchange


text:
Q: git updates rejected error on brand-new clone I cloned a brand-new repo from our server. I then pulled a new branch from origin. I made a few changes and committed, but when I try to push, I get the "updates were rejected because the tip of your current branch is behind" error. But it's not - it's a brand-new clone, and there have not been any commits made by other devs in the interim. I've tried doing git pull --rebase as suggested here, but it just tells me my branch is already up-to-date.
How can I resolve this issue?
estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (master)
$ git fetch origin

estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (master)
$ git checkout -b estrom/PH-19312 origin/release-18.9.0
Branch estrom/PH-19312 set up to track remote branch release-18.9.0 from origin.
Switched to a new branch 'estrom/PH-19312'

estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (estrom/PH-19312)
$ gitk

estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (estrom/PH-19312)
$ git commit -am "PH-19312 hide calories for literacy item in order history"
[estrom/PH-19312 5ace4de] PH-19312 hide calories for literacy item in order history
 1 file changed, 2 insertions(+)

estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (estrom/PH-19312)
$ git push
To ssh://stash.mycompany.com:7999/phi/qo6.git
 ! [rejected]        estrom/PH-19312 -> estrom/PH-19312 (non-fast-forward)
error: failed to push some refs to 'ssh://git@stash.mycompany.com:7999/phi/qo6.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (estrom/PH-19312)
$ git pull --rebase
Current branch estrom/PH-19312 is up to date.

estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (estrom/PH-19312)
$ git pull --ff-only
remote: Counting objects: 28, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 16 (delta 11), reused 0 (delta 0)
Unpacking objects: 100% (16/16), done.
From ssh://stash.mycompany.com:7999/phi/qo6
   34e51c0..6a7696a  PH-18381-18.10         -> origin/PH-18381-18.10
   fa0520a..6665db3  develop                -> origin/develop
 * [new branch]      PH-19548               -> origin/PH-19548
Already up-to-date.

estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (estrom/PH-19312)
$ git push
To ssh://stash.mycompany.com:7999/phi/qo6.git
 ! [rejected]        estrom/PH-19312 -> estrom/PH-19312 (non-fast-forward)
error: failed to push some refs to 'ssh://git@stash.mycompany.com:7999/phi/qo6.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (estrom/PH-19312)
$

ETA: result of `git branch -v -v --list estrom/PH-19312
estrom@T460-ESTROM MINGW64 /c/gitRepo/qo6 (estrom/PH-19312)
$ git branch -v -v --list estrom/PH-19312
* estrom/PH-19312 5ace4de [origin/release-18.9.0: ahead 1] PH-19312 hide calories for literacy item in order history

A: The output of git branch -v -v --list estrom/PH-19312 reveals the truth: the local branch estrom/PH-19312 is tracking the remote branch release-18.9.0 from origin which is, indeed, one commit ahead the local branch. This is why git push refuses to work.
On the other hand, you probably don't want to push to release-18.9.0 but to a remote branch named estrom/PH-19312. Then you make a pull request, it is reviewed and, if approved, it is merged into release-18.9.0.
The solution to the problem is simple: add --set-upstream to the git push command line to tell Git to use a branch with the same name on the remote repository:
git push --set-upstream origin estrom/PH-19314

The problem started when you created the local branch from a remote branch with a different name. To avoid this problem in the future add --no-track to the command line when you create branches using git checkout or git branch:
git checkout -b --no-track estrom/PH-19312 origin/release-18.9.0

A: TL;DR
You probably want to change the upstream setting of your branch and rebase:
git branch --set-upstream-to origin/PH-19312
git rebase

Note that if your Git is very ancient, you won't have --set-upstream-to.  You can use git branch --set-upstream but you have to be more verbose and use what looks like the wrong order of arguments (this is why modern Git has --set-upstream-to instead of --set-upstream):
git branch --set-upstream estrom/PH-19312 origin/estrom/PH-19312

Long
There are two problems interacting here, both stemming from the initial git checkout command.
The setup
Let's look first at this command:

$ git checkout -b estrom/PH-19312 origin/release-18.9.0
Branch estrom/PH-19312 set up to track remote branch release-18.9.0 from origin.
Switched to a new branch 'estrom/PH-19312'

The -b flag tells git checkout to create a new branch.  The next word, estrom/PH-19312, supplies the name for the new branch.  The subsequent origin/release-18.9.0 word specifies which commit to check out, and does one more thing when used with -b: it tells Git that, by default, the new branch name should have this name set as its upstream.
It's time to pause a bit and discuss what we mean by "branch" here (see also What exactly do we mean by "branch"?).  In this case, the phrase branch estrom/PH-19312 means the name estrom/PH-19312 in the refs/heads name-space of references, and the "upstream" is an entry in .git/config concerning the name estrom/PH-19312.  The branch name itself simply acts as a pointer to some existing commit, somewhere in the graph of "all commits ever made" that resides in your own Git repository.  Only those who actually have a clone of the repository can enumerate all the commits, but just making some guesses from the output above, I will draw it like this, which is probably a little off but at least has something right :-) :
             o--o--o   <-- origin/develop
            /
...--o--o--o--o   <-- master (HEAD), origin/master
         \     \
          \     E   <-- origin/estrom/PH-19312
           \
            o--*   <-- origin/release-18.9.0

The round o nodes represent commits.  I picked out a few particularly interesting commits and gave them a different symbol so that we can talk about them later.
You then ask Git (via git checkout -b ...) to:

*

*Locate the commit to which origin/release-18.9.0 points: I've labeled that commit * here.

*Extract that commit into the index (also known as the staging area and the cache; see other StackOverflow postings or Git documentation) and the work-tree.

*Make a new label, estrom/PH-19312, pointing to this commit.

The result is that the graph itself is unchanged, but there is a new branch label, and your HEAD is now attached to that new branch label:
             o--o--o   <-- origin/develop
            /
...--o--o--o--o   <-- master, origin/master
         \     \
          \     E   <-- origin/estrom/PH-19312
           \
            o--*   <-- estrom/PH-19312 (HEAD), origin/release-18.9.0

At this point you do some work, successfully
You modified some files, git added them to the index, and git commited:

$ git commit -am "PH-19312 hide calories for literacy item in order history"
[estrom/PH-19312 5ace4de] PH-19312 hide calories for literacy item in order history
 1 file changed, 2 insertions(+)

This created a new commit in the commit graph, so let's update the drawing (I'm going to drop the top row entirely since I'm not using it):
...--o--o--o--o   <-- master, origin/master
         \     \
          \     E   <-- origin/estrom/PH-19312
           \
            o--*   <-- origin/release-18.9.0
                \
                 N   <-- estrom/PH-19312 (HEAD)

Note that the parent of new commit N is existing commit *.  This is probably wrong: you started from release-18.9.0 as seen on origin (which your Git remembers as origin/release-18.9.0), rather than starting from estrom/PH-19312 as seen on origin.
The first failing Git command
At this point you ran:

$ git push
To ssh://stash.mycompany.com:7999/phi/qo6.git
 ! [rejected]        estrom/PH-19312 -> estrom/PH-19312 (non-fast-forward)

By default, git push tries to push based on the push.default setting.  In this case, whatever you have set instructed your Git to push estrom/PH-19312.  However, your push setting is neither simple nor upstream.  It might be matching (especially if your Git is quite ancient, e.g., Git 1.7 to 1.9 instead of 2.0+).  So your Git thought it should ask the other Git at ssh://stash.mycompany.com:7999/phi/qo6.git to have that other Git set its estrom/PH-19312 to point to commit N.
But their estrom/PH-19312 points to commit E.  If they set their estrom/PH-19312 to point to commit N, they will lose commit E.  Therefore they say: No, I will not do that: rejected: non-fast-forward.  That's what non-fast-forward means: the label they have now points to some commit, and you're proposing that they remove some commit(s) from their branch while setting their branch to point to your new commit N.
Note that if you used simple as your push.default, your own Git would refuse to do the push, because the upstream name is release-18.9.0 (your origin/release-18.9.0).  If you used upstream as your push.default setting, your Git would ask their Git to set their release-18.9.0—it's possible, but I think unlikely, that this is actually what you want.
Rebase does nothing because of the upstream setting
When you use git rebase or git pull --rebase, your Git tries to copy your commit N atop your origin/release-18.9.0.  As you can see from the graph, your commit N already sits atop the commit to which origin/release-18.9.0 points, so rebase does nothing.
If you change the upstream setting for your estrom/PH-19312 branch to origin/estrom/PH-19312, git rebase will copy N to a new commit N' that sits atop origin/estrom/PH-19312:
...--o--o--o--o   <-- master, origin/master
         \     \
          \     E   <-- origin/estrom/PH-19312
           \     \
            \     N'  <-- estrom/PH-19312 (HEAD)
             \
              o--*   <-- origin/release-18.9.0
                  \
                   N   [abandoned]

This commit is now suitable to send to that other Git for it to add it its to estrom/PH-19312.  I suspect this is what you want.

A: First, try git pull --ff-only
Then push your changes
This will fast-forward your local copy of the branch so it's the same as the remote.


text:
Q: setOnItemClickListener on Android App with custom Adapter not triggering I am trying to get a code segment to trigger when the user clicks on an item. It is triggering on the custom adapter but not on the main segment.
This is the code segment for the adapter and what I am trying to trigger but its not being triggered.
public class Program_Lure_list_Adapter extends BaseAdapter implements View.OnClickListener {

private static ArrayList<Program_Lure_Sound> programLureList;

private LayoutInflater l_inflater;

private int mPosition;

private int[] Image = {R.drawable.blacksound};
ViewHolder viewHolder;
ViewHolder selectedHolder;

private Activity activity;
public Program_Lure_list_Adapter(Activity a, ArrayList<Program_Lure_Sound> result) {
    activity = a;
    programLureList = result;
    l_inflater = (LayoutInflater)activity.
            getSystemService(Context.LAYOUT_INFLATER_SERVICE);

}

/*public Program_Lure_list_Adapter(Context context, ArrayList<Program_Lure_Sound> result) {
    programLureList = result;
    l_inflater = LayoutInflater.from(context);

}*/

@Override
public int getCount() {
    return programLureList.size();
}

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

public Object getItem(int position) {
    return position;
}

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

public long getItemId(int position) {
    return position;
}

@Override
public View getView(final int i, View view, ViewGroup viewGroup) {
    if (view == null) {
        view = l_inflater.inflate(R.layout.layout_programlure_listitem, viewGroup, false);
        viewHolder = new ViewHolder();
        viewHolder.iv_Image_souund = (ImageView) view.findViewById(R.id.imageView29);
        viewHolder.tv_soundName = (TextView) view.findViewById(R.id.textView92);
        viewHolder.tv_selected = (TextView) view.findViewById(R.id.textView_selected);
        view.setTag(viewHolder);

    } else
        viewHolder = (ViewHolder) view.getTag();

    viewHolder.iv_Image_souund.setImageResource(Image[programLureList.get(i).getSoundImage()]);
    viewHolder.tv_soundName.setText(programLureList.get(i).getSoundName());
    viewHolder.tv_selected.setVisibility(View.GONE);
    view.setTag(viewHolder);
    view.setOnClickListener(this);
    return view;

}

@Override
public void onClick(final View v) {
    v.post(new Runnable() {
        @Override
        public void run() {
            ViewHolder holder = ((ViewHolder) v.getTag());
            holder.tv_selected.setVisibility(View.VISIBLE);
            if (selectedHolder != null)
                selectedHolder.tv_selected.setVisibility(View.INVISIBLE);
            selectedHolder = holder;
        }
    });

}
public class ViewHolder{
    TextView tv_soundName;
    ImageView iv_Image_souund;
    TextView tv_selected;
}

private class OnItemClickListener  implements OnClickListener{
    private int mPosition;

    OnItemClickListener(int position){
        mPosition = position;
    }

    @Override
    public void onClick(View arg0) {
        Activity_program_lure sct = (Activity_program_lure)activity;
        sct.onItemClick(mPosition);

    }
}

}
This is the custom adapter, the onClick is triggering properly but I need the other segment to trigger as well.
        if(getSoundList()!=null) {
        final ArrayList<Program_Lure_Sound> plsList = getSoundList();
        //mAdapter = new Program_Lure_list_Adapter(this, plsList);
        mAdapter = new Program_Lure_list_Adapter(Activity_program_lure.this, plsList);
        activeSoundList.setAdapter(mAdapter);

        setListViewHeightBasedOnChildren(activeSoundList);

        // activeSoundList.setAdapter();
        //  activeSoundList
        activeSoundList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Log.v("BLEApp", "HEREHERE2");
                String name = plsList.get(i).getSoundName();

                String[] arr = name.split(" ");

                String ID = arr[0].split("#")[1];
                // soundCode = ID;
                //showToast("Sound code: "+soundCode);
                String sd = plsList.get(i).getSoundName();
                if (sd.length() > 10)
                    sd = sd.substring(0, Math.min(sd.length(), 10));
                tv_ActiveSound.setText(sd);
                if (mBluetoothLeService != null) {
                    // playSound(ID);
                    try {
                        changeToSound(ID);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    showToast("Please, click on power button and then click to" +
                            "play sound...!");
                }
            }
        });

        // endregion

        dbHelper = new DataBaseHelper(this);
        String lureUsed = dbHelper.LureUsed(lureName);
        dbHelper.closeDB();
        tv_LureUsed.setText(lureUsed);

    }

    float  opacity = 0.4f;
    ll.setAlpha(opacity);
    tv_power.setText("ON");
    playSoundButton.setAlpha(opacity);
    playSoundButton.setEnabled(false);

}

public void onItemClick(int mPosition) {
    Log.v("BLEApp", "HEREHERE");
    final ArrayList<Program_Lure_Sound> plsList = getSoundList();

    int i=mPosition; String name = plsList.get(i).getSoundName();

    String[] arr = name.split(" ");

    String ID = arr[0].split("#")[1];
    // soundCode = ID;
    //showToast("Sound code: "+soundCode);
    String sd = plsList.get(i).getSoundName();
    if(sd.length()>10)
        sd = sd.substring(0, Math.min(sd.length(),10));
    tv_ActiveSound.setText(sd);
    if(mBluetoothLeService!=null){
        // playSound(ID);
        try {
            changeToSound(ID);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else{
        showToast("Please, click on power button and then click to" +
                "play sound...!");
    }
}

Any ideas? I'm guessing it's something simple I'm missing.

A: the click event is consumption by view,so has no click event to trigger itemclick .
you can move itemclick code  inside of onclicklistener

A: change this in your main activity
mAdapter = new Program_Lure_list_Adapter(MainActivity.this, plsList);

then in your custom adapter class
private Activity activity;
    public Program_Lure_list_Adapter(Activity a, ArrayList<Program_Lure_Sound> result) {
    activity = a;
            programLureList = result;
            l_inflater = (LayoutInflater)activity.
                    getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        }

Implement this method in your custom adapter class which will tell your main activity or in your case your other segment activity to click which item.
private class OnItemClickListener  implements OnClickListener{
        private int mPosition;

        OnItemClickListener(int position){
            mPosition = position;
        }

        @Override
        public void onClick(View arg0) {
            MainActivity sct = (MainActivity)activity;
            sct.onItemClick(mPosition);

        }
    }

And modify these two methods too like following.
public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

After that put your other segment code in the main activity in the following method like this
public void onItemClick(int mPosition) {
int i=mPosition;
String name = plsList.get(i).getSoundName();
            String[] arr = name.split(" ");

            String ID = arr[0].split("#")[1];
           // soundCode = ID;
            //showToast("Sound code: "+soundCode);
            String sd = plsList.get(i).getSoundName();
            if(sd.length()>10)
            sd = sd.substring(0, Math.min(sd.length(),10));
            tv_ActiveSound.setText(sd);
            if(mBluetoothLeService!=null){
               // playSound(ID);
                try {
                    changeToSound(ID);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else{
                showToast("Please, click on power button and then click to" +
                        "play sound...!");
            }

}

Hope this will help you.


text:
Q: Gnome control center (system settings) after upgrade missing After yesterdays upgrade to Ubuntu 20.04 I am missing my system settings in main menu (gnome-control-center?). When upgrading I had few errors and had to remove 2 packages: xserver-xorg-video and colord. When I try to install gnome-control-center I get error:
The following packages have unmet dependencies:
libsane : Depends: libsnmp35 (>= 5.8+dfsg) but it is not going to be installed
       Recommends: sane-utils (>= 1.0.29-0ubuntu5.2)
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

I have tried installing sane-utils, but I get this error:
The following packages have unmet dependencies:
sane-utils : Depends: libsane (>= 1.0.27)
E: Unable to correct problems, you have held broken packages.

When I try this:
sudo apt-get -o Debug::pkgProblemResolver=yes install gnome-control-center
I get this:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Starting pkgProblemResolver with broken count: 2
Starting 2 pkgProblemResolver with broken count: 2
Investigating (0) libgl1-mesa-dri:amd64 < 20.3~git2010050730.961a8d~oibaf~b @ii mK Ib >
Broken libgl1-mesa-dri:amd64 Depends on libsensors4:amd64 < 1:3.4.0-4 @ii mR > (>= 1:3.0.0)
  Considering libsensors4:amd64 -1 as a solution to libgl1-mesa-dri:amd64 24
  Added libsensors4:amd64 to the remove list
  Fixing libgl1-mesa-dri:amd64 via keep of libsensors4:amd64
Investigating (0) libsensors-config:amd64 < none -> 1:3.6.0-2ubuntu1 @un uN Ib >
Broken libsensors-config:amd64 Conflicts on libsensors4:amd64 < 1:3.4.0-4 @ii mK >
  Considering libsensors4:amd64 -1 as a solution to libsensors-config:amd64 0
  Added libsensors4:amd64 to the remove list
  Fixing libsensors-config:amd64 via remove of libsensors4:amd64
Investigating (1) libgl1-mesa-dri:amd64 < 20.3~git2010050730.961a8d~oibaf~b @ii mK Ib >
Broken libgl1-mesa-dri:amd64 Depends on libsensors4:amd64 < 1:3.4.0-4 @ii mR > (>= 1:3.0.0)
  Considering libsensors4:amd64 -1 as a solution to libgl1-mesa-dri:amd64 24
  Added libsensors4:amd64 to the remove list
  Fixing libgl1-mesa-dri:amd64 via keep of libsensors4:amd64
Investigating (1) libsensors-config:amd64 < none -> 1:3.6.0-2ubuntu1 @un uN Ib >
Broken libsensors-config:amd64 Conflicts on libsensors4:amd64 < 1:3.4.0-4 @ii mK >
  Considering libsensors4:amd64 -1 as a solution to libsensors-config:amd64 0
  Added libsensors4:amd64 to the remove list
  Fixing libsensors-config:amd64 via remove of libsensors4:amd64
Investigating (2) libgl1-mesa-dri:amd64 < 20.3~git2010050730.961a8d~oibaf~b @ii mK Ib >
Broken libgl1-mesa-dri:amd64 Depends on libsensors4:amd64 < 1:3.4.0-4 @ii mR > (>= 1:3.0.0)
  Considering libsensors4:amd64 -1 as a solution to libgl1-mesa-dri:amd64 24
  Added libsensors4:amd64 to the remove list
  Fixing libgl1-mesa-dri:amd64 via keep of libsensors4:amd64
Investigating (2) libsensors-config:amd64 < none -> 1:3.6.0-2ubuntu1 @un uN Ib >
Broken libsensors-config:amd64 Conflicts on libsensors4:amd64 < 1:3.4.0-4 @ii mK >
  Considering libsensors4:amd64 24 as a solution to libsensors-config:amd64 0
  Holding Back libsensors-config:amd64 rather than change libsensors4:amd64
Investigating (3) libsensors5:amd64 < none -> 1:3.6.0-2ubuntu1 @un uN Ib >
Broken libsensors5:amd64 Depends on libsensors-config:amd64 < none | 1:3.6.0-2ubuntu1 @un uH >
  Considering libsensors-config:amd64 0 as a solution to libsensors5:amd64 0
  Holding Back libsensors5:amd64 rather than change libsensors-config:amd64
Investigating (4) libsnmp35:amd64 < none -> 5.8+dfsg-2ubuntu2.3 @un uN Ib >
Broken libsnmp35:amd64 Depends on libsensors5:amd64 < none | 1:3.6.0-2ubuntu1 @un uH > (>= 1:3.5.0)
  Considering libsensors5:amd64 0 as a solution to libsnmp35:amd64 2
  Holding Back libsnmp35:amd64 rather than change libsensors5:amd64
Investigating (5) libsane:amd64 < none -> 1.0.29-0ubuntu5.2 @un uN Ib >
Broken libsane:amd64 Depends on libsnmp35:amd64 < none | 5.8+dfsg-2ubuntu2.3 @un uH > (>= 5.8+dfsg)
  Considering libsnmp35:amd64 2 as a solution to libsane:amd64 8
  Holding Back libsane:amd64 rather than change libsnmp35:amd64
Investigating (5) sane-utils:amd64 < none -> 1.0.29-0ubuntu5.2 @rc uN Ib >
Broken sane-utils:amd64 Depends on libsane:amd64 < none | 1.0.29-0ubuntu5.2 @un uH > (>= 1.0.27)
  Considering libsane:amd64 8 as a solution to sane-utils:amd64 3
  Holding Back sane-utils:amd64 rather than change libsane:amd64
Investigating (6) colord:amd64 < none -> 1.4.4-2 @rc uN Ib >
Broken colord:amd64 Depends on libsane:amd64 < none | 1.0.29-0ubuntu5.2 @un uH > (>= 1.0.24)
  Considering libsane:amd64 8 as a solution to colord:amd64 35
  Holding Back colord:amd64 rather than change libsane:amd64
Investigating (7) gnome-control-center:amd64 < none -> 1:3.36.4-0ubuntu1 @un puN Ib >
Broken gnome-control-center:amd64 Depends on colord:amd64 < none | 1.4.4-2 @rc uH > (>= 0.1.30)
  Considering colord:amd64 35 as a solution to gnome-control-center:amd64 10034
  Re-Instated libsensors-config:amd64
  Re-Instated libsensors5:amd64
  Re-Instated libsnmp35:amd64
  Re-Instated libsane:amd64
  Re-Instated colord:amd64
Investigating (7) libsensors-config:amd64 < none -> 1:3.6.0-2ubuntu1 @un uN Ib >
Broken libsensors-config:amd64 Conflicts on libsensors4:amd64 < 1:3.4.0-4 @ii mK >
  Considering libsensors4:amd64 24 as a solution to libsensors-config:amd64 0
  Holding Back libsensors-config:amd64 rather than change libsensors4:amd64
Investigating (8) libsensors5:amd64 < none -> 1:3.6.0-2ubuntu1 @un uN Ib >
Broken libsensors5:amd64 Depends on libsensors-config:amd64 < none | 1:3.6.0-2ubuntu1 @un uH >
  Considering libsensors-config:amd64 0 as a solution to libsensors5:amd64 0
  Holding Back libsensors5:amd64 rather than change libsensors-config:amd64
Investigating (9) libsnmp35:amd64 < none -> 5.8+dfsg-2ubuntu2.3 @un uN Ib >
Broken libsnmp35:amd64 Depends on libsensors5:amd64 < none | 1:3.6.0-2ubuntu1 @un uH > (>= 1:3.5.0)
  Considering libsensors5:amd64 0 as a solution to libsnmp35:amd64 2
  Holding Back libsnmp35:amd64 rather than change libsensors5:amd64
Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libsane : Depends: libsnmp35 (>= 5.8+dfsg) but it is not going to be installed
           Recommends: sane-utils (>= 1.0.29-0ubuntu5.2)
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.


text:
Q: removed php extension and $SESSION variables do not work Hi everyone I found this code here somewhere
RewriteEngine On

# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]

# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]

This removes the .php file extension but my $_GET paramaters do not work anymore how can I go about to solve this thanks in advance. I have read other posts but didn't get what I wanted.
After further examination the problem is that when I log in
$_SESSION[profileId] // doesn't set anymore

When I clear .htaccess everything goes back to normal. My code reads
$sql = "SELECT * FROM mytable WHERE userName='$_GET['profile']' LIMIT 1";
$user_query = mysqli_query($db_conx, $sql);
$row = mysqli_fetch_array($user_query,MYSQL_ASSOC);

$profileId = $row['profileId'];

if($_SESSION['profileId'] === $profileId){
    if(isset($_GET['profile']) && !isset($_GET['edit'])){

    echo 'Edit Profile';
    }

    if(isset($_GET['profile']) && isset($_GET['edit'])){

    echo 'Done editing';
    }
}

This is the code where I set the sessions
session_start();

$username = mysqli_real_escape_string($db_conx, $_POST['u']);
$password = $_POST['p'];
$ip = preg_replace('#[^0-9.]#', '', getenv('REMOTE_ADDR'));

if($username == "" || $password == ""){
    echo "login_failed";
}else{
    $sql = "SELECT * FROM myTable WHERE username='$username' AND activated='yes' LIMIT 1";
    $query = mysqli_query($db_conx, $sql);
    $row = mysqli_fetch_array($query);
    $profileId = $row['profileId'];
    $compName = $row['compName'];
    $db_username = $row['username'];
    $db_email = $row['email'];
    $db_pass_str = $row['password'];

    if(password_verify($password,$db_pass_str)){

        $_SESSION['profileId'] = $profileId;
        $_SESSION['username'] = $db_username;
        $_SESSION['password'] = $db_pass_str;
        setcookie("id", $profileId, strtotime( '+30 days' ), "/", "", "", TRUE);
        setcookie("user", $db_username, strtotime( '+30 days' ), "/", "", "", TRUE);
        setcookie("pass", $db_pass_str, strtotime( '+30 days' ), "/", "", "", TRUE);
        // UPDATE THEIR "IP" AND "LASTLOGIN" FIELDS
        $sql = "UPDATE myTable SET ip='$ip', lastlogin=now() WHERE profileId='$profileId' LIMIT 1";
        $query = mysqli_query($db_conx, $sql);

        if($query){
            echo $compName;
        }

    } else {
        echo 'login_failed';

    }
}

A:     You are redirect any url to .php page without passing argument.

    So passed argument also using htaccess.

    Please try these.

    For example :-

    you want to call test page with your id as parameter then
    make request like these /test/12 then it will redirect to test.php?id=12

    RewriteRule ^/?(.*)/(.*)$ /$1.php?id=$2 [L]

Please change htaccess like these


text:
Q: How to solve this integral with sigma notation? Let $$f(x) = \sum_{n=1}^{N}a_{n}sin(nx)$$.
For a positive integer m, show the following:

I've never even had a first step for this one even after hours of trying to understand it. I asked my professor and she told me it involves solving integrals involving integrals. Tried another day trying to solve it, but ended up with nothing. Any help out there would be deeply appreciated
Edit:
I tried to solve it, but still couldn't figure out an answer for a and not sure about the answer of b
(a)
$$\frac{1}{\pi}\int^{\pi}_{-\pi}\sum_{n=1}^{N}a_{a}sin(nx)sin(mx)dx\\
\frac{1}{\pi}\sum_{n=1}^{N}a_{n}\int^{\pi}_{-\pi}\sin(nx)sin(mx)dx\\
\frac{1}{\pi}\sum_{n=1}^{N}a_{n}\int^{\pi}_{-\pi}\frac{1}{2} \cos(nx-mx)-\cos(nx+mx)dx\\
\frac{1}{2\pi}\sum_{n=1}^{N}a_{n}\int^{\pi}_{-\pi} \cos(nx-mx)-\cos(nx+mx)dx\\
\int^{\pi}_{-\pi} \cos(nx-mx)dx-\int^{\pi}_{-\pi}\cos(nx+mx)dx\\
\frac{1}{2\pi}\sum_{n=1}^{N}a_{n}[\frac{\sin((n-m)\pi)}{n-m}-\frac{\sin((n-m)(-\pi))}{n-m}-\frac{\sin((n+m)\pi)}{n+m}+\frac{\sin((n+m)(-\pi))}{n+m}+C]
\frac{1}{2\pi}\sum_{n=1}^{N}a_{n}[0-0-0+0+C]\\0$$
When I solve it like this, all of the cases result to 0. Which is not similar to the equality stated in the given
(b)
$$\frac{1}{\pi}\int^{\pi}_{-\pi}\sum^{N}_{n=1}a^2_n\sin^2(nx)dx\\
\frac{1}{\pi}\sum^{N}_{n=1}a^2_n\int^{\pi}_{-\pi}\sin^2(nx)dx\\
\int^{\pi}_{-\pi}\sin^2(nx)dx\\
\frac{1}{2}(\pi-\frac{\sin(2\pi x)}{2n})-\frac{1}{2}(-\pi-\frac{\sin(-2\pi x)}{2n})\\
(\frac{\pi}{2}-0)-(\frac{-\pi}{2}-0)\\
\frac{1}{\pi}\sum^{N}_{n=1}a^2_n\pi\\
\sum^{N}_{n=1}a^2_n$$

A: Hint
Regarding (a), as the integral is linear, it is sufficient to compute
$$\int_{-\pi}^\pi \sin nx \sin mx \ dx$$ for $m,n \in \mathbb Z$. Which can easily be done using the trigonometric formula
$$\sin a \sin b = \frac{1}{2}\left(\cos \frac{a-b}{2} - \cos \frac{a+b}{2}\right)$$
For part (b), use part (a) expanding $f^2(x) = f(x) \cdot f(x)$.


text:
Q: Regular expression to separate words using capital letter I have the following text

Location:HyderabadProduct Development, Design His Own Designs And Developed The Websites. Framework: Magento: Drupal, Joomla, Ruby On Rails , Codeigniter (Any One Or A Combination). Good In Sql Database. Looking.

I need to capture just the location name - Hyderabad.
I have used (?<=Location:).* to remove the location tag tried with lot of other options to separate from Hyderabad but could not get an apt one.
Kindly suggest a regular expression to retrieve the location name

A: Try the below regex to capture only the string Hyderabad which is follwed by the string Product,
(?<=Location:)(.*?)(?=Product)

DEMO
OR
(?<=Location:)(.*?)(?=[A-Z])

This would capture all the characters after the string Location upto the next Uppercase letter.
DEMO
Have added this picture just for ref -
Data captured after the regular expression


text:
Q: Let $X'$ and $X$ be metric spaces with measures $d$ and $d'$. Show that $m((p,p'), (q,q')) = \sqrt{d(p, q)^2 + d'(p,q)^2}$ is a metric. For the given metric  $m((p,p'), (q,q')) = \sqrt{d(p, q)^2 + d'(p,q)^2}$. I have proven the first two properties for a metric hold (this is rather trivial). I am unable to prove the triangle inequality. My work so far is as follows:
$$m((p,p'), (q,q')) = \sqrt{d(p, q)^2 + d'(p',q')^2} \le \sqrt{(d(p,r) + d(r, q))^2 + (d'(p',r') + d'(r', q'))^2} \\ \le \sqrt{(d(p,r) + d(r, q))^2} + \sqrt{(d'(p',r') + d'(r', q'))^2}$$
How can I continue from here? Was invoking $\sqrt{x+y} \le \sqrt x + \sqrt y$ helpful?

A: Hint:
Fixing notation, I assume you mean
$$m((p,p'), (q,q')) = \sqrt{ d(p,q)^2 + d'(p',q')^2}$$
This is a generalization of a Euclidean norm on $\mathbb R^2$. You can prove the triangle inequality the same way as we do there. Namely, write
$$m((p,p'), (q,q'))^2 = \langle (d(p,q),d'(p',q')), (d(p,q),d'(p',q')) \rangle_{\mathbb R^2}^2$$
Your proof will require the Cauchy-Schwarz inequality.
Try writing out the proof for $\mathbb R^2$. Then write it out for your metric $m$.


text:
Q: Display WooCommerce My account Orders only when items belong to specific category So I am building a custom section on the WooCoommerce's my account/my-orders.php template file to only show order history of any products that are under the category "courses".
I currently have this:
<?php
$my_orders_columns = apply_filters(
    'woocommerce_my_account_my_orders_columns',
    array(
        'order-number'  => esc_html__( 'Order', 'woocommerce' ),
        'order-date'    => esc_html__( 'Date', 'woocommerce' ),
        'order-status'  => esc_html__( 'Status', 'woocommerce' ),
        'order-total'   => esc_html__( 'Total', 'woocommerce' ),
        'order-actions' => ' ',
    )
);

$customer_orders = get_posts(
    apply_filters(
        'woocommerce_my_account_my_orders_query',
        array(
            'numberposts' => $order_count,
            'meta_key'    => '_customer_user',
            'meta_value'  => get_current_user_id(),
            'post_type'   => wc_get_order_types( 'view-orders' ),
            'post_status' => array_keys( wc_get_order_statuses() ),
        )
    )
);

if ( $customer_orders ) : ?>

    <?php if(is_product_category('course')) { ?>

                     <?php
                        foreach ( $customer_orders as $customer_order ) :
                            $order      = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
                            $item_count = $order->get_item_count();
                        ?>

                                <?php foreach ( $my_orders_columns as $column_id => $column_name ) : ?>

                                    <img src="<?php echo get_template_directory_uri(); ?>/assets/images/course.png"/>

Course name:

<?php echo the_dramatist_get_order_prod_name( $order ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>

Date of course:

21.01.21

Paid on:

<time datetime="<?php echo esc_attr( $order->get_date_created()->date( 'c' ) ); ?>"><?php echo esc_html( wc_format_datetime( $order->get_date_created() ) ); ?></time>

Status:

<?php echo esc_html( wc_get_order_status_name( $order->get_status() ) ); ?>

                                        <a class='orangeB' href="<?php echo the_permalink(); ?>">View course overview

                                                                        <a class='blackB marT20' href="<?php echo the_permalink(); ?>">Get PPE for this course

                    <?php endforeach; ?>

                        <?php endforeach; ?>

    <?php } else { ?>
dsfdsf
    <?php } ?>

<?php endif; ?>

This is pulling through the order history in a loop how I want it, but I've gone to add a conditional if is_product_category('course') around it and it's not pulling anything through.
Feel I'm close but missing something?

A: There are some little mistakes in your code… To check for a product category, you need to check in order items (for each order) using has_terms() Wordpress conditional function as follow:
<?php
$my_orders_columns = apply_filters(
    'woocommerce_my_account_my_orders_columns',
    array(
        'order-number'  => esc_html__( 'Order', 'woocommerce' ),
        'order-date'    => esc_html__( 'Date', 'woocommerce' ),
        'order-status'  => esc_html__( 'Status', 'woocommerce' ),
        'order-total'   => esc_html__( 'Total', 'woocommerce' ),
        'order-actions' => ' ',
    )
);

$customer_orders = get_posts(
    apply_filters(
        'woocommerce_my_account_my_orders_query',
        array(
            'numberposts' => $order_count,
            'meta_key'    => '_customer_user',
            'meta_value'  => get_current_user_id(),
            'post_type'   => wc_get_order_types( 'view-orders' ),
            'post_status' => array_keys( wc_get_order_statuses() ),
        )
    )
);

$product_category_terms = array('course'); // <== Here the defined product category term(s)

if ( $customer_orders ) : ?>

            <?php foreach ( $customer_orders as $customer_order ) :
                $order      = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
                $item_count = $order->get_item_count();

                $category_found = false; // Initializing

                // Loop through order items
                foreach ( $order->get_items() as $item ) {
                    if ( has_term( $product_category_terms, 'product_cat', $item->get_product_id() ) ) {
                        $category_found = true;
                        break;
                    }
                }

                // If the product category is not found in order items we jump to next order
                if ( ! $category_found ) continue;
            ?>

            <?php foreach ( $my_orders_columns as $column_id => $column_name ) : ?>

                            <img src="<?php echo get_template_directory_uri(); ?>/assets/images/course.png"/>

Course name:

<?php echo the_dramatist_get_order_prod_name( $order ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>

<?php esc_html_e("Date of course:", "woocommerce"); ?>

<?php _e("21.01.21", "woocommerce"); ?>

<?php esc_html_e("Paid on:", "woocommerce"); ?>

<time datetime="<?php esc_attr_e( $order->get_date_created()->date( 'c' ) ); ?>"><?php  esc_html_e( wc_format_datetime( $order->get_date_created() ) ); ?></time>

<?php esc_html_e("Status:", "woocommerce"); ?>

<?php esc_html_e( wc_get_order_status_name( $order->get_status() ) ); ?>

                                    <a class='orangeB' href="<?php the_permalink(); ?>"><?php esc_html_e("View course overview", "woocommerce"); ?>

                                    <a class='blackB marT20' href="<?php the_permalink(); ?>"><?php esc_html_e("Get PPE for this course", "woocommerce"); ?>

                <?php endforeach; ?>

            <?php endforeach; ?>

<?php endif; ?>

It should work.


text:
Q: Strassen Multiplication Algorithm StackOverFlow Error I am working on implementing Straussen's Multiplication. Below is my method for multiplying them in a Divide and Conquer Approach.
public static double[][] multiply(double[][] A, double[][] B)

    {

        int n = A.length;

        double[][] R = new double[n][n];

        /** base case **/

        //if (n == 1){

          //  R[0][0] = A[0][0] * B[0][0];
       // }

        //else{

            double[][] A11 = new double [n/2][n/2];

            double[][] A12 = new double [n/2][n/2];

            double[][] A21 = new double [n/2][n/2];

            double[][] A22 = new double [n/2][n/2];

            double[][] B11 = new double [n/2][n/2];

            double[][] B12 = new double [n/2][n/2];

            double[][] B21 = new double [n/2][n/2];

            double[][] B22 = new double [n/2][n/2];

            /** Dividing matrix A into 4 halves **/

            split(A, A11, 0 , 0);

            split(A, A12, 0 , n/2);

            split(A, A21, n/2, 0);

            split(A, A22, n/2, n/2);

            /** Dividing matrix B into 4 halves **/

            split(B, B11, 0 , 0);

            split(B, B12, 0 , n/2);

            split(B, B21, n/2, 0);

            split(B, B22, n/2, n/2);

            /**

              M1 = (A11 + A22)(B11 + B22)

              M2 = (A21 + A22) B11

              M3 = A11 (B12 - B22)

              M4 = A22 (B21 - B11)

              M5 = (A11 + A12) B22

              M6 = (A21 - A11) (B11 + B12)

              M7 = (A12 - A22) (B21 + B22)

            **/

            double [][] M1 = multiply(add(A11, A22), add(B11, B22));

            double [][] M2 = multiply(add(A21, A22), B11);

            double [][] M3 = multiply(A11, sub(B12, B22));

            double [][] M4 = multiply(A22, sub(B21, B11));

            double [][] M5 = multiply(add(A11, A12), B22);

            double [][] M6 = multiply(sub(A21, A11), add(B11, B12));

            double [][] M7 = multiply(sub(A12, A22), add(B21, B22));

            /**

              C11 = M1 + M4 - M5 + M7

              C12 = M3 + M5

              C21 = M2 + M4

              C22 = M1 - M2 + M3 + M6

            **/

            double [][] C11 = add(sub(add(M1, M4), M5), M7);

            double [][] C12 = add(M3, M5);

            double [][] C21 = add(M2, M4);

            double [][] C22 = add(sub(add(M1, M3), M2), M6);

            /** join 4 halves into one result matrix **/

            join(C11, R, 0 , 0);

            join(C12, R, 0 , n/2);

            join(C21, R, n/2, 0);

            join(C22, R, n/2, n/2);

        /** return result **/

        return R;

    }

In order to implement this code, I am reading in 2 txt files, one for matrix A and one for matrix B. For terms of testing I have the two matrices being the exact same:

5
3.250 6.130 3.180 7.680 9.060
5.450 1.660 6.790 6.650 4.250
4.460 8.260 7.870 7.880 1.890
1.460 8.510 8.510 3.510 1.440
1.590 7.160 4.400 3.310 1.970

Where the first line is n, and the following lines are the matrix.
My problem is that I am getting a stack overflow error on the line
int n = A.length;

Which I can't seem to figure out why or where to look. So my question is, does the problem lie in this algorithm? Or would the problem be in my main method?


text:
Q: Absolute value of all values in a matrix How do I express the matlab function abs(M), on a matrix $M$, in mathematical terms?
I thought about norms or just $|M|$, but these return scalars, not another matrix of the same size as $M$.
Sorry for the rough explanation, english isn't my primary language.

A: I think you can also denote the matrix M by giving its generic (i, j)-entry with parenthesis around:
M = (mij).
So Matlab's "abs(M)" would simply be: (|mij|).

A: 'help abs' returns ABS(X) is the absolute value of the elements of X.
If $ M = [a _{ij}] $ where $a _{ij} \in R$, $i=1...m$ , $j=1..n$ Then $ABS(M) =  [ABS(a _{ij})]$
Note: it's not a must for $a _{ij} \in R$ and can be also complex.


text:
Q: rails controller not saving value to boolen field in database I have a model store with a controller. This controller has an action "publish" which sets the store :publish field true or false.
def publish
    @store=Store.find_by(params[:store_id])
    if params[:publish_value]=="1"
        if @store.update_attribute :publish, true
            @message_type="success"
            @message="Your store has been published succesfully."
            respond_to do |format|
                format.js
            end
        else
            @message_type = "error"
            @message = @store.errors.full_messages.join(', ')
            respond_to do |format|
                format.js { render :template => "layouts/messages.js.erb",
                             :layout => false }
            end
        end
    else
        if @store.update_attribute :publish, false
            @message_type="warning"
            @message="Your store has been unpublished."
            respond_to do |format|
                format.js
            end
        else
            @message_type = "error"
            @message = @store.errors.full_messages.join(', ')
            respond_to do |format|
                format.js { render :template => "layouts/messages.js.erb",
                             :layout => false }
            end
        end
    end
end

When I publish the store params[:store_id] and params[:publish_value] are successfully passed to the controller. And I receive "Success" message. But for some reason when I check the rails console or refresh the page there is no change in :publish value. It still shows as nil.
Here is the log after clicking publish button.
Started POST "/stores/publish" for 39.32.68.180 at 2016-06-09 23:08:28 +0000
Processing by StoresController#publish as JS
Parameters: {"utf8"=>"✓", "store_id"=>"35", "publish_value"=>"1", "commit"=>"submit"}
Customer Load (0.2ms)  SELECT  "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT 1  [["id", 44]]
Store Load (0.1ms)  SELECT  "stores".* FROM "stores" WHERE "stores"."customer_id" = ? LIMIT 1  [["customer_id", 44]]
Store Load (0.3ms)  SELECT  "stores".* FROM "stores" WHERE (35) LIMIT 1
(0.1ms)  begin transaction
(0.1ms)  commit transaction
Rendered stores/_publish.html.erb (0.6ms)
Rendered layouts/_messages.js.erb (0.1ms)
Rendered stores/publish.js.erb (4.5ms)
Completed 200 OK in 14ms (Views: 8.9ms | ActiveRecord: 0.7ms)

Help will be appreciated. Thanks.
Also here is the schema
create_table "stores", force: :cascade do |t|
t.string   "store_name"
t.integer  "customer_id"
t.text     "store_description"
t.datetime "created_at",        null: false
t.datetime "updated_at",        null: false
t.string   "picture"
t.boolean  "publish"
t.boolean  "approved"
end

add_index "stores", ["customer_id"], name: "index_stores_on_customer_id"

and the store.rb file
class Store < ActiveRecord::Base
belongs_to :customer
has_many :products
mount_uploader :picture, PictureUploader
validates :customer_id, presence: true
validates :store_name, presence: true, length: {maximum:20}
#validates :store_description, presence: true, length: {minimum:100 , maximum:1000}, :on => :update
end

A: The Rails log should show your SQL generated by ActiveRecord.  That doesn't seem to be happening.
What happens when you try to update this model directly in Rails console?
$ rails c
$ store = Store.first()
$ store.update_attribute :publish, true

You should see something like:
SQL (0.3ms)  UPDATE "store" SET "publish" = ?, "updated_at" = ? WHERE "store"."id" = ?
[["publish", "t"], ["updated_at", "2016-06-10 00:21:34.754662"], ["id", 1]]
(5.5ms)  commit transaction

You can also simplify this action and add some inline debugging that might help, like so:
    def publish
        @store = Store.find(params[:store_id])
        publish_value = params[:publish_value]=="1"

        if @store.update_attribute :publish, publish_value
            publish_value ? @message_type="success" : @message_type="warning"
            publish_value ? @message="Your store has been published successfully." : @message="Your store has been unpublished."
            puts "*** update_attribute succeeded.  @store is:"
            puts @store.inspect
            respond_to do |format|
                format.js
            end
        else
            @message_type = "error"
            @message = @store.errors.full_messages.join(', ')
            puts "*** update_attribute failed.  @store is:"
            puts @store.inspect
            respond_to do |format|
                format.js { render :template => "layouts/messages.js.erb", :layout => false }
        end
    end


text:
Q: Remotely shutdown a Windows machine How can I shutdown or restart a Windows machine over remotely?

*

*It should handle many computer(thread)

*Ability to shutdown all computer or only one

*Work client/server...

A: Use the shutdown command:
shutdown /s /m \\computername
shutdown /r /m \\computername

The /s switch is used for shutdown, /r for restart.
The full usage for shutdown on my Windows 7 box:
>shutdown /?
Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f]
    [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]

    No args    Display help. This is the same as typing /?.
    /?         Display help. This is the same as not typing any options.
    /i         Display the graphical user interface (GUI).
               This must be the first option.
    /l         Log off. This cannot be used with /m or /d options.
    /s         Shutdown the computer.
    /r         Shutdown and restart the computer.
    /g         Shutdown and restart the computer. After the system is
               rebooted, restart any registered applications.
    /a         Abort a system shutdown.
               This can only be used during the time-out period.
    /p         Turn off the local computer with no time-out or warning.
               Can be used with /d and /f options.
    /h         Hibernate the local computer.
               Can be used with the /f option.
    /e         Document the reason for an unexpected shutdown of a computer.
    /m \\computer Specify the target computer.
    /t xxx     Set the time-out period before shutdown to xxx seconds.
               The valid range is 0-315360000 (10 years), with a default of 30.
               If the timeout period is greater than 0, the /f parameter is
               implied.
    /c "comment" Comment on the reason for the restart or shutdown.
               Maximum of 512 characters allowed.
    /f         Force running applications to close without forewarning users.
               The /f parameter is implied when a value greater than 0 is
               specified for the /t parameter.
    /d [p|u:]xx:yy  Provide the reason for the restart or shutdown.
               p indicates that the restart or shutdown is planned.
               u indicates that the reason is user defined.
               If neither p nor u is specified the restart or shutdown is
               unplanned.
               xx is the major reason number (positive integer less than 256).
               yy is the minor reason number (positive integer less than 65536).

A: For Remote PC with in network run cmd is
shutdown -m \192...** -r -f -t 0
Where -m denotes for remote
 1. "-r" denotes restart the remote computer.
 2. "-f" flags tell the remote computer to restart and safely close all open programs.
 3. "-t" flag denote time after -t i.e here 0 sec.


text:
Q: $scope value not changing from the modalInstance.result.then() of the directive controller HTML:
<teacher-modal modal-type="edit" file-name="teacherModal"
    button-title="DerecEdit" modal-value="teacher"
    button-class="" message="teacherCtrl.message">
</teacher-modal>|
 {{teacherCtrl.message}}

Directive:
(
function(){
    angular.module('MockApp')
        .directive('teacherModal',teacherModal);

    function teacherModal(){
        var directive = {
            restrict: 'EA',
            scope:{
                'type': '@modalType',
                'title': '@buttonTitle',
                'class': '@buttonClass',
                'fileName': '@fileName',
                modalValue: '=',
                message: '=',
            },
            template:'{{title}}',
            controller:'modalDirectiveController as modalDCtrl'
        }
        return directive;
    }

    angular.module('MockApp')
        .controller('modalDirectiveController', modalDirectiveController);

    modalDirectiveController.$inject = ['$uibModal','TeacherService','$scope', '$rootScope'];

    function modalDirectiveController($uibModal , TeacherService , $scope, $rootScope){

        var vm = this;

        vm.open = function(teacher,fileName){
            var msg;

            console.log('open function of teacher modal ctrl' + fileName);
            var modalInstance = $uibModal.open({
                ariaLabelledBy: 'modal-title',
                ariaDescribedBy: 'modal-body',
                templateUrl: 'components/modalComponent/teacher/'+fileName+'.html',
                controller: 'TeacherModalController as teacherModalCtrl',
                size: 'md',
                resolve:{
                    newTeacher:function(){
                        return teacher;
                    }
                }
            });

            modalInstance.result.then(function (result) {
                console.log('result of directive controller');

                if(result.actionType == 'Add Teacher')
                    $scope.message = result.teacherName + " has been added";
                else
                    $scope.message = result.teacherName + " has been edited";
//
                $rootScope.$broadcast("updateMessage", msg);
            }, function () {
                console.info('Modal dismissed at: ' + new Date());
            });
 //
            //$scope.message = 'hello from teacher-modalnn.js';
        }
    }

}
)();

$scope.message inside the modalInstance.result.then() function is not previewing whereas the $scope.message outside the function is being viewed.
When we use the $rootScope.broadcast() the message is being previewed, but I would not like to use the $broadcast service.
Github URL: https://github.com/coderabin01/ngStudentApp
Can anyone answer me why and how?

A: You are applying a value outside out of the angular context (XHR call), so you need to use $apply().

$apply() is used to execute an expression in AngularJS from outside of
  the AngularJS framework. (For example from browser DOM events,
  setTimeout, XHR or third party libraries). Because we are calling into
  the AngularJS framework we need to perform proper scope life cycle

So try this:
...
$scope.$apply(function() {
        $scope.message = result.teacherName + " has been added";
});
...


text:
Q: Taylor series representation
I don't understand how the taylor series representation follows the derivative requirements for $f(x)$. If I plug in $n=2$ into the taylor polynomial, I don't get $0$ for this term but I should because $f^n(2)$ is zero for all even $n$'s so the whole expression should be zero.

A: They've used the fact that it's 0 for even n to just remove those from the sum so they sum over n in the format 2n+1 which gives us only the odd terms


text:
Q: About the set of density points of given sets, for the Lebesgue measure on the line and on the plane Please help me prove the following:

1) Let $A \subseteq \{(x,y)|0< x^2+y^2 < 1 \}$ be a lebesgue measurable set such that every point in $\{(x,y)|0< x^2+y^2 < 1 \}$ is a density point of $A$,
  then (0,0) is a density point of A as well.
2) Find a set $A$ such that for every n:
  $\frac{m \bigl(\bigl[0,\frac{1}{2^n}\bigl] \cap A \bigl)}{m\bigl(\bigl[0,\frac{1}{2^n}\bigl]\bigl)}=\frac{1}{2}$.

Couldn't prove the 1st question. Any help?
And anyone have an example for the second question?
Thanks!

A: For the first problem, define $B= \{0<x^2+y^2<1\}\setminus A.$ Suppose $m(B)>0.$ Then by Lebesgue's differentiation theorem, a.e. $(x,y) \in B$ is a point of density of $B.$ Let $z_0=(x_0,y_0)$ be one of these. Then it is easy to see
$$ \lim_{r\to 0^+} \frac{m(A\cap D(z_0,r))}{m(D(z_0,r))} = 0.$$
Thus $z_0$ is not a point of density of $A,$ contradiction. This shows a.e. point of $\{0<x^2+y^2<1\}$ is in $A.$ The desired conclusion is immediate from this.


text:
Q: Font style is not affected in Mobile view in UWP I am working on windows universal platform app for windows-10.I designed my whole app and use a two font style in whole application.
1)Utsaah
2)Raavi
both font family properly working in desktop and tablate view.But when i run my app in emulator (Mobile view) that time both fonts are not affacted to my textblock means default font of mobile initialize so please suggest me a solution . I just attached screenshot also code.
Code:

    <Grid HorizontalAlignment="Stretch">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel x:Name="topbar" Background="#FFF4F4F4" Grid.Row="0" Grid.ColumnSpan="2">

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Button x:Name="back_deatil_button" Grid.Column="0" Click="back_deatil_button_Click" Background="Transparent" Style="{StaticResource ButtonStyle1}">
                    <Image Source="Images/bback_icon@2x.png"  Height="25"  Stretch="Fill"></Image>
                </Button>
                <TextBlock x:Name="product_details" Grid.Column="1"  FontSize="14"   Text="PRODUCT DETAILS"  Foreground="#FFF05929" FontFamily="Raavi" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" ></TextBlock>
            </Grid>
        </StackPanel>

        <StackPanel x:Name="product_detail" Grid.ColumnSpan="2" Margin="0,10,0,10" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock x:Name="ProductName"  FontSize="16" FontFamily="utsaah" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold"></TextBlock>
        </StackPanel>
        <Image Source="Images/top_large_shhadow.png" Grid.ColumnSpan="2" Grid.Row="2"  VerticalAlignment="Top"></Image>
        <StackPanel x:Name="product_img" Grid.ColumnSpan="2" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top"  Height="137" Margin="40,0,54,20" Width="239">

            <Image  x:Name="ProductImage" Source="{Binding image}"  Height="137" Width="239" Margin="5"></Image>

        </StackPanel>
        <Image Source="Images/Products/top_large_shadow.png" Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="SKU                               :" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold" FontFamily="Utsaah" FontSize="14"></TextBlock>
        <TextBlock x:Name="SKU"   Grid.Row="3" Grid.Column="1"  HorizontalAlignment="Left" FontFamily="Utsaah" FontSize="14"></TextBlock>
        <Image Source="Images/Products/top_large_shadow.png" Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="3" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="Price                              :" Grid.Row="4" Grid.Column="0" HorizontalAlignment="Center" FontFamily="Utsaah" FontSize="14" FontWeight="Bold"></TextBlock>
        <TextBlock x:Name="Price"  Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" FontFamily="Utsaah" FontSize="14"></TextBlock>

        <Image Source="Images/Products/top_large_shadow.png"  Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="4" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="Qty                                :" x:Name="RowTotalQty" FontFamily="Utsaah" FontSize="14" Grid.Row="5" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold"></TextBlock>
        <TextBlock x:Name="TotalQty" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Left" FontFamily="Utsaah" FontSize="14"></TextBlock>

        <Image Source="Images/Products/top_large_shadow.png"   Margin="0,25,0,0"  Grid.ColumnSpan="2" Grid.Row="5" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="Special Price                :" x:Name="RowSpecialPrice" Grid.Row="6" Grid.Column="0" HorizontalAlignment="Center" FontFamily="Utsaah" FontSize="11"></TextBlock>
        <TextBlock x:Name="SpecialPrice" Grid.Row="6" Grid.Column="1"   HorizontalAlignment="Left" FontFamily="Utsaah" FontSize="14"></TextBlock>
        <Image Source="Images/Products/top_large_shadow.png"  Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="6" VerticalAlignment="Bottom" ></Image>

        <TextBlock Text="Status                           :" x:Name="RowStatus" Grid.Row="7" FontFamily="Utsaah" FontSize="14" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold"></TextBlock>
        <TextBlock x:Name="Status" Grid.Row="7" Grid.Column="1" FontFamily="Utsaah" FontSize="14" HorizontalAlignment="Left"></TextBlock>
        <Image Source="Images/ttop_large_shadow.png"  Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="7" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="Type                              :" FontFamily="Utsaah" x:Name="row_type" FontSize="14" Grid.Row="8" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold"></TextBlock>
        <TextBlock x:Name="ProductType" Grid.Row="8" FontFamily="Utsaah" FontSize="14" Grid.Column="1" HorizontalAlignment="Left"></TextBlock>

        <Image Source="Imagesttop_large_shadow.png"  Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="8" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="Associated                   :" Grid.Row="10" FontFamily="Utsaah" FontSize="14" Grid.Column="0" FontWeight="Bold" HorizontalAlignment="Center" x:Name="associated_prpduct" Visibility="Collapsed"></TextBlock>
        <TextBlock x:Name="Associated" Grid.Row="10" FontFamily="Utsaah" FontSize="14" Grid.Column="1" HorizontalAlignment="Left" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.IsVerticalRailEnabled="True"></TextBlock>

        <Image Source="Images/Products/top_large_shadow.png" x:Name="row_total_qty_shadow" Margin="0,25,0,0" Grid.ColumnSpan="2" Grid.Row="9" VerticalAlignment="Bottom"></Image>

        <TextBlock Text="Description                   :" FontFamily="Utsaah" x:Name="row_description" FontSize="14" Grid.Row="9" Grid.Column="0" HorizontalAlignment="Center"   FontWeight="Bold"></TextBlock>
        <StackPanel Grid.Column="1" Grid.Row="9" x:Name="pnl_description" Height="auto">
            <ScrollViewer  HorizontalAlignment="Stretch"  VerticalAlignment="Bottom" Height="50"  VerticalScrollBarVisibility="Auto" Margin="0,0,0,6">
                <TextBlock x:Name="Description"  FontFamily="Utsaah" FontSize="14" Grid.Column="1" TextWrapping="Wrap"   HorizontalAlignment="Stretch" Margin="0,0,10,0"></TextBlock>
            </ScrollViewer>
        </StackPanel>

    </Grid>
    <ProgressBar Name="mobile_back_loader" Visibility="Collapsed" IsIndeterminate="True" Foreground="#FFF05A2A" HorizontalAlignment="Stretch" Height="40" VerticalAlignment="Top"  Margin="0,150,0,0"  Grid.RowSpan="2"/>
</Grid>

Image:

A: Here is a list of 'recommended' fonts for UWP apps.
Guidelines for fonts
https://msdn.microsoft.com/windows/uwp/controls-and-patterns/fonts
These fonts are guaranteed to be available in all Win10 device families - desktop, mobile, iot, etc.
But, Utsaah and Raavi are not listed in the list.
The doc says:

Note If you use a font that's not in this list, your app may trigger
  an automatic download of the font data from a Microsoft service.

and

UWP apps that will available on mobile devices should never use fonts for UI
  content other than fonts in this list.

It's not recommended. :(


text:
Q: Tool to migrate Access database to SQL CE Is there any free tool that can migrate Access Database to SQL CE
I currently have an Access database 2003 and want to import into SQL CE 3.5

A: When you can do is upside your data from access to SQL (you can even use one of the free expression editions).  You then can script out the whole database, or pull the data from sql server into your version of SQL lite.


text:
Q: Profile Picture not consistent across network I was a bit shocked to find out my profile picture got somehow disappeared(?) in the other network. I checked on Stack Overflow, Meta Stack Overflow, Meta Stack Exchange and seems like only in Stack Overflow, it is correct.
This wasn't the case before, how did this happen? As far as I know, I have been using the same SSO login and email for all the sites. So Gravatar should show the same.
Here's a screenshot (with poorly hand-drawn red circles included):

Here are the links for the same:

*

*User Praveen Kumar Purushothaman - Meta Stack Exchange

*User Praveen Kumar Purushothaman - Meta Stack Overflow

*User Praveen Kumar Purushothaman - Stack Overflow
Is this a user error or a system error?


text:
Q: What are these boxes mounted inline on each of the 3 phase wires of a high voltage power line in Miami? They were only on this run and not any of the lines in the area. And what is the function of the flat u-shaped guards in front of each?

A: It's a fault circuit indicator.  Specifically, it's the Sentient MM3 model which monitors the current through the conductor it's attached to.  It also draws its power from the magnetic field resulting from the current passing through the line.  It logs and can wirelessly transmit the data it gathers which helps the local electric utility in quickly pinpointing problems -- ideally in advance of the problem becoming an actual outage.  For example, an intermittent fault could indicate a sagging tree branch hitting the line when the wind blows.
The little metal circle thing is an arc shield from the same company.  It's intended to save the sensor (which is not inexpensive) from a traveling arc, as from a lightning strike down the line.
And no, I have nothing to do with that company but have some experience in the utility industry.


text:
Q: import.meta undefined in components (Vite/Vue3) i am trying to access the import.meta.env Variable 'APP_SOCKET_URL' in my component but it says Uncaught TypeError: import_meta.env is undefined
In my main.js file import.meta.env works fine. In all other files it doesnt work and I dont know why. Maybe someone can help me there.
Here is the code of my data function:
 data(){

  const socket = new Socket(import.meta.env.APP_SOCKET_URL || `ws://${location.href}/ws`);
  return {
     socket
  };
}

In my .env file I added:
APP_SOCKET_URL="ws://localhost:8765"

And in my vite.config I changed the envPreix to "APP_"
Here is my Setup:
Vite Version 3.1.4
Vue 3 Version 3.2.40
Programming in Typescript
Thanks and have a nice day!
EDIT:
I found the error. If I change the script lag from 'ts' to 'js' it works. So the problem is with typescript, but I dont know how to fix that.

A: Your answer should lie here in this documentation
Vite generates the types for you if configurated correctly in the tsconfig.json.


text:
Q: How can I init h2o and train data in java? I saw the examples of how to init h2o and use it in python.
import h2o;
h2o.init();
h2o.train_gbm(**);

But how can I init h2o and use it in java?
Is there any example code or document?


text:
Q: Add svg to an html table (instead of html body) I have an animated svg in the html body but I want to have it in a table cell (4x4 table) instead.
As far as I understand this is what links my svg to html body:
d3.xml("field.svg", function(xml) {
svgdom = document.body.appendChild(xml.documentElement);

How can I link my svg to a table cell (id='c1') instead of html body?

A: Try svgdom = document.getElementById('c1').appendChild(xml.documentElement)
Instead of document.body, this line of code specifically queries the document for the element you'd like to append the child to.


text:
Q: Spin glass observables in Monte Carlo simulations I am currently simulating an Edwards-Anderson spin glass using standard Metropolis Monte Carlo techniques. The spins are placed on a 3D cubic lattice with periodic boundaries and take on Ising values (-1/+1), the couplings between them are drawn from a Gaussian random distribution.
What's now unclear to me is how I technically implement typical spin glass observables, such as the Edwards-Anderson order parameter:
$$q_{EA} = \frac{1}{N}\sum_{i=1}^N \langle\sigma_i\rangle^2 $$
According to this definition, I first do thermal averages for each of the sites independently, and afterwards average over the system. Finally, I might do another average of independent disorder replicas.
So, in practice, how would one implement such an observable? Keeping track of the thermal "history" of every site throughout the entire simulation seems tedious and will be expensive once the lattice becomes larger. And even worse, observables such as the spin glass susceptibility
$$\chi_{SG} = \frac{1}{N}\sum_{i,j}^N \langle\sigma_i\sigma_j\rangle^2 $$
require to record the history of every pair of sites...

*

*Literature: Parisi, Giorgio. "Order parameter for spin-glasses." Physical Review Letters 50.24 (1983): 1946.


text:
Q: Django | Factory boy | faking a boolean field | django.db.utils.DataError: value too long for type character varying(1) I am trying to use factory boy to generate fake entries but I'm stepping on an issue related with the boolean field.
Follows the Model and ModelFactory:
# models.py

class Record(models.Model):
    date_creation = models.DateTimeField()
    rec_type = models.CharField(max_length=1, choices=RECORD_TYPES)
    direction = models.BooleanField()

# factories.py

class RecordFactory(DjangoModelFactory):

    class Meta:
        model = Record

    date_creation = factory.Faker('date_time')
    rec_type = factory.Faker('random_choices', elements=[x[1] for x in Record.RECORD_TYPES])
    direction = factory.Faker('pybool')

How do I fix this issue? Seems to be related with the boolean field.
/usr/local/lib/python3.7/site-packages/django/db/models/fields/__init__.py:1427: RuntimeWarning: DateTimeField Record.date_creation received a naive datetime (1
977-11-24 14:21:26) while time zone support is active.
  RuntimeWarning)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.StringDataRightTruncation: value too long for type character varying(1)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 30, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
File "/app/iur/core/management/commands/seed.py", line 60, in handle
    self.create(options["records"], RecordFactory)
  File "/app/iur/core/management/commands/seed.py", line 47, in create
    factory_class.create()
  File "/usr/local/lib/python3.7/site-packages/factory/base.py", line 564, in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
  File "/usr/local/lib/python3.7/site-packages/factory/django.py", line 141, in _generate
    return super(DjangoModelFactory, cls)._generate(strategy, params)
  File "/usr/local/lib/python3.7/site-packages/factory/base.py", line 501, in _generate
    return step.build()
  File "/usr/local/lib/python3.7/site-packages/factory/builder.py", line 279, in build
    kwargs=kwargs,
  File "/usr/local/lib/python3.7/site-packages/factory/base.py", line 315, in instantiate
    return self.factory._create(model, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/factory/django.py", line 185, in _create
    return manager.create(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 422, in create
    obj.save(force_insert=True, using=self.db)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 741, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 779, in save_base
    force_update, using, update_fields,
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 870, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py", line 908, in _do_insert
    using=using, raw=raw)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1186, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1335, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 99, in execute
    return super().execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.DataError: value too long for type character varying(1)

A: It might not be the boolean field that cause the error but
rec_type = models.CharField(max_length=1, choices=RECORD_TYPES)

As it's max_length is 1. Can you confirm that RECORD_TYPES are max 1 character?

django.db.utils.DataError: value too long for type character varying(1)

This should indicate that it's a VARCHAR of max length 1. And from what I can see from the trace, you're db backend is postgres where there is a native boolean field.

A: The major issue was that I was using the wrong Faker. This one did what I expected:
# factories.py

...

rec_type = factory.Faker('random_element', elements=[x[0] for x in Record.RECORD_TYPES])

...

A: Just set e.g. direction = False in RecordFactory. Or, if you want to use faker, you can do direction = Faker().pybool()
I think the error is telling you that your DB backend uses a one letter varchar for representing booleans (most probably "t" and "f").


text:
Q: How to display form inputs on a web page I'm currently working on my first assignment where I have no idea how to continue in. I need to use PHP and HTML to create a form that will allow the user to enter their name as text and age as a number.
The form will call to a PHP processing page. The PHP processing page will create an HTML page for the user that will display "Hello xxxxxxx" in h1 tags. In paragraph tags, the page will display "In 10 years, you will be xx years old."  This is what i've come up with so far :
<html xmlns="

<meta http-equiv="Content-Type" content="text/html; chartset=iso-8859-1" /

 <?php
     // echo "
";
     // print_r($_POST);
     // echo "
';
 ?>

 Hello <?php echo "$uname"; ?>

 In 10 years, you will be <?php echo "$unumber"; ?> years old.

For my PHP page.
And this for my HTML:
<?php

   $uname = $_POST['username'];
   $unumber = $_POST['number'];

?>
<!DOCTYPE html PUBLIC
<html xmlns=

<meta http-equiv="content-type" content="text/html; chartset=iso-8859-1" />
<title> Lesson 1 </title>

   <form action="lesson-1-process.php" method="post" enctype="multipart/form-data" name="userform" target="_self">
       Name: <input name="username" type="text" />

       Age: <input name="number" type="text" />

       <input name="submit" type="submit" />
   </form>

I have no idea if I am doing this right. Another thing, does anyone know an easy way to get this on to a live  website with a FTP tool?  I can buy a domain but I haven't got a clue on how to set up a website. Link or answers all help. Thank you!!

A: The assignments to $uname and $unumber should be in the PHP script, not the page with the form.
And you need to add 10 to the form value to get the age in 10 years.

<meta http-equiv="Content-Type" content="text/html; chartset=iso-8859-1" /

 <?php
   $uname = $_POST['username'];
   $unumber = $_POST['number'];
 ?>

 Hello <?php echo "$uname"; ?>

 In 10 years, you will be <?php echo $unumber + 10; ?> years old.


text:
Q: Sherlock actionBar.setIcon(android.R.color.transparent) leaves gap to left I have tried searching on Google and stackoverflow but I didn't find the solution.
Problem:

Code:
actionBar = activity.getSupportActionBar();
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
//actionBar.setDisplayUseLogoEnabled(false);
//actionBar.setDisplayHomeAsUpEnabled(false);
//actionBar.setDisplayShowHomeEnabled(false);

actionBar.setIcon(android.R.color.transparent);

LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
    Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);

LayoutInflater inflator = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout v = (LinearLayout) inflator.inflate(R.layout.header, null);
actionBar.setCustomView(v, lp);

actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

header.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/topheaderbackground" >

    <TextView
        android:id="@+id/topcaption"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:gravity="center_vertical|center_horizontal"
        android:text="ABC"
        android:textColor="#ebf5ff"
        android:textSize="9.6pt"
        android:textStyle="bold"
        android:typeface="sans" />

</LinearLayout>

What I have tried:
actionBar.setDisplayShowHomeEnabled(false);

But result is:

Please Help!!!
[Edit]:
I am using Theme.Sherlock.
[Result of Doctoror Drive's suggestion]:
actionBar.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.topheaderbackground));
new header.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/topcaption"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:gravity="center_vertical|center_horizontal"
        android:text="ABC"
        android:textColor="#ebf5ff"
        android:textSize="9.6pt"
        android:textStyle="bold"
        android:typeface="sans" />

</LinearLayout>

As you can see text is not in center, any suggestion???

A: It's not the icon, it's a CustomView that's leaving the gap.
You should change the color of ActionBar in styles.
http://developer.android.com/guide/topics/ui/actionbar.html#AdvancedStyles
And then add custom view with no background, just a TextView in center.
EDIT:
After you've set it to center, the space for your text is space of actionbar content minus the size of icon to the left (which is transparent). Try setting ActionBar display options.
remove
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);

and add instead
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

Tell me if you still have the issue, then I will tell plan B.
EDIT, plan B:
Alright, there is a problem with flipping when above is set so try adding padding to root of your TextView. Set ActionBar mode:
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM |
        ActionBar.DISPLAY_SHOW_HOME);

And in xml, I think the LinearLayout there is useless. Try setting plain and clean TextView
<TextView
    android:id="@+id/topcaption"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingRight="?android:attr/actionBarSize"
    android:gravity="center"
    android:text="ABC"
    android:textColor="#ebf5ff"
    android:textSize="9.6pt"
    android:textStyle="bold"
    android:typeface="sans" />

If that will not work, try
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingRight="?android:attr/actionBarSize"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/topcaption"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:gravity="center"
        android:text="ABC"
        android:textColor="#ebf5ff"
        android:textSize="9.6pt"
        android:textStyle="bold"
        android:typeface="sans" />

</LinearLayout>


text:
Q: Update/Insert records into different snapshot tables based on snapshot_date and id from a staging table I have a huge snapshot table (example user_snapshot_all) broken into the different smaller table on Redshift (i.e. Postgres) to get the performance gain.
So, the smaller tables are like (suffix has year_month)
user_snapshot_1995_1
user_snapshot_1995_2
user_snapshot_1995_3
user_snapshot_1995_4
....
user_snapshot_2016_11

They hold snapshot record for whatever year and month they have suffix
I use a staging table user_snapshot_staging to load/update data to these tables incrementally, in 99% cases, it is just the latest year_month one.
But there will be some edge cases like 12:00 midnight when staging table will have data which will span to two tables (for example user_snaspshot_2016_10 and user_snapshot_2016_11 on 2016-11-1)
Or another edge case, maybe we need to update few 2 years old snapshot and so staging table will have some 2-year-old records along with a lot of today's snapshot.
The question is how I should design my query or code so that it can update or insert data into right month_year snapshot table?
All the snapshot tables and staging tables have at least these two columns:
id
snapshot_date

To clarify further:
If it was single user_snapshot_all I could easily update the records by joining the staging table with master table based on snapshot_date and id. But with these smaller tables segmented by month_year, there is no guarantee that all records from staging tables can be found in one snapshot table.
Here are use cases
Note: Below queries are part of an ETL process, they are not one-off manual one, that is why I need to be automated solution.
Scenario 1)
Suppose user_snapshot_staging table has
id  snapshot_date user_detail
100  2016-11-3     jskesljd234
101  2016-11-4     jskesljdfg23
102  2016-11-5     jskesljdbd23
103  2016-11-6     jskesljdw23ds

since all the snapshot belongs to November 2016, all this data will be Inserted/Updated into user_snapshot_2016_11 with following two queries:
Insert new:
Insert into user_info_snapshot_2011_11 (id, snapshot_date, user_detail )
from user_info_snapshot_staging source LEFT OUTER JOIN user_info_snapshot_2011_11 target on source.id = target.id where target.id is null
;

Update existing:
update user_info_snapshot_2011_11 set snapshot_date=source.snapshot_date, user_detail=source.user_detail
from user_info_snapshot_staging source INNER JOIN user_info_snapshot_2011_11 target on source.id = target.id where

Scenario 2)
Now suppose user_snapshot_staging table has
id  snapshot_date user_detail
1300  2015-01-3     jskesljd234
1301  2015-10-4     jskesljdfg23
1302  2016-11-1     jskesljdbd23
1303  2016-11-2     jskesljdw23ds

Now staging table has snapshots which will require update and insert to different snapshot tables, we cannot just insert/update into user_snapshot_2016_11, but we need to also insert/update into user_snapshot_2015_01 and user_snapshot_2015_10
How should I design my query or code which generate the dynamic query to handle these cases so that only appropriate table are joined with user_snapshot_staging table based on data in the staging table?
Let me know if you need further clarifications. Sorry, it is little tricky to explain.

A: You can generate queries with the following approach. I'll give examples in pseudo-code based on python syntax.

*

*Get year/month combinations you have in your staging database

SELECT DISTINCT to_char(date, 'YYYY-MM') FROM user_info_snapshot_staging;

*These are your query templates:

-- insert_template.sql
INSERT INTO user_info_snapshot_{{ year }}_{{ month }} (id, snapshot_date, user_detail )
FROM user_info_snapshot_staging source LEFT OUTER JOIN user_info_snapshot_{{ year }}_{{ month }} target on source.id = target.id where target.id is null
WHERE DATE_TRUNC('month', source.date) = {{ month }} AND DATE_TRUNC('year', source.date) = {{ year }};

-- update_template.sql
UPDATE user_info_snapshot_{{ year }}_{{ month }} SET snapshot_date=source.snapshot_date, user_detail=source.user_detail
FROM user_info_snapshot_staging source INNER JOIN user_info_snapshot_{{ year }}_{{ month }} target on source.id = target.id where
DATE_TRUNC('month', source.date) = {{ month }} AND DATE_TRUNC('year', source.date) = {{ year }};

Now loop through year/month pairs and execute those queries:
for year_month, in cursor.execute("SELECT to_char('YYYY-MM', date_columns) FROM user_info_snapshot_staging"):
    year, month = year_month.split('-')
    # this is where you generate sql
    sql = template('insert_template', context={
        'year': year,
        'month': month,
    })
    # here you execute it
    cursor.execute(sql)

I would advise against using update if you need to update a lot of records. Further info in this question.


text:
Q: SQL Return subquery 'Total Records' to outer query This one has me a little stumped, I'm trying to get the total count in my top (root) node XML from this SQL query:
    SELECT COUNT(*) OVER() as '@totalCount', (
        SELECT COUNT(*) OVER() as totalCount, [Title], [Year], [Type], [Poster]
        FROM movies As result where CONTAINS(Title, @Title) Order by [Weight] DESC
        OFFSET ((@PageNumber - 1) * @RowspPage) ROWS
        FETCH NEXT @RowspPage ROWS ONLY
        FOR XML AUTO, type
    )
    FOR XML PATH('root')

Obviously the COUNT(*) OVER() is only returning "1" because it's being executed at the top level and not within the subquery. But I only want to display it once in the root node and not repeat per each result.

Any help would be greatly appreciated.

A: EDIT: Here a working example with common data to walk along:
;with myCTE as
(
    select *
    from sys.objects
)
select (select count(*) from myCTE) as [@Counter]
    ,(
       SELECT myCTE.object_id AS id
             ,mycte.name AS name
       from myCTE
       for xml path('object'),TYPE
      )
for xml path('test')

You might try to shift your query into a CTE and put it to something like this:
;WITH MyQueryAsCTE AS
(
    SELECT [Title], [Year], [Type], [Poster]
    FROM movies As result where CONTAINS(Title, @Title) Order by [Weight] DESC
    OFFSET ((@PageNumber - 1) * @RowspPage) ROWS
    FETCH NEXT @RowspPage ROWS ONLY
)
SELECT  (SELECT Count(*) FROM MyQueryAsCTE) as '@totalFound'
       ,[Title] AS [Movie/Title]
       ,[Year] AS [Movie/Year]
       ,[Type] AS [Movie/Type]
       ,[Poster] AS [Movie/Poster]
FROM MyQueryAsCTE
FOR XML PATH('root')

A: Fun with strings... This is a total hack, but it works:
DECLARE @totalCount AS INT
DECLARE @result varchar(MAX)

SELECT @totalCount = COUNT(*) OVER(), @result = COALESCE(@result + '', '') + '<result title="' + [Title] + '" year="' + [Year] + '" type="' + [Type] + '"/>'
FROM Movies where CONTAINS(Title, '@Title') Order by [Weight] DESC
OFFSET ((@PageNumber - 1) * @RowspPage) ROWS
FETCH NEXT @RowspPage ROWS ONLY
SELECT '<root totalCount="' + CAST(@totalCount AS VARCHAR) + '">' + @result + '</root>'

Output:

Seems to have a faster/more efficient execution plan as the calculation is only made once and no additional queries to any tables are required.


text:
Q: Google PubSub Python multiple subscriber clients receiving duplicate messages I have a pretty straightforward app that starts a PubSub subscriber StreamingPull client. I have this deployed on Kubernetes so I can scale. When I have a single pod deployed, everything works as expected. When I scale to 2 containers, I start getting duplicate messages. I know that some small of duplicate messages is to be expected, but almost half the messages, sometimes more, are received multiple times.
My process takes about 600ms to process a message. The subscription acknowledgement deadline is set to 600s. I published 1000 messages, and the subscription was emptied in less than a minute, but the acknowledge_message_operation metric shows ~1500 calls, with a small amount with response_code expired. There were no failures in my process and all messages were acked upon processing. Logs show that the same message was received by the two containers at the exact same time. The minute to process all the messages was well below the acknowledgement deadline of the subscription, and the Python client is supposed to handle lease management, so I'm not sure why there were any expired messages at all. I also don't understand why the same message is sent to multiple subscriber clients at the same time.
Minimal working example:
import time

from google.cloud import pubsub_v1

PROJECT_ID = 'my-project'
PUBSUB_TOPIC_ID = 'duplicate-test'
PUBSUB_SUBSCRIPTION_ID = 'duplicate-test'

def subscribe(sleep_time=None):
    subscriber = pubsub_v1.SubscriberClient()
    subscription_path = subscriber.subscription_path(
        PROJECT_ID, PUBSUB_SUBSCRIPTION_ID)

    def callback(message):
        print(message.data.decode())
        if sleep_time:
            time.sleep(sleep_time)
        print(f'acking {message.data.decode()}')
        message.ack()

    future = subscriber.subscribe(
        subscription_path, callback=callback)
    print(f'Listening for messages on {subscription_path}')
    future.result()

def publish(num_messages):
    publisher = pubsub_v1.PublisherClient()
    topic_path = publisher.topic_path(PROJECT_ID, PUBSUB_TOPIC_ID)
    for i in range(num_messages):
        publisher.publish(topic_path, str(i).encode())

In two terminals, run subscribe(1). In a third terminal, run publish(200). For me, this will give duplicates in the two subscriber terminals.

A: It is unusual for two subscribers to get the same message at the same time unless:

*

*The message got published twice due to a retry (and therefore as far as Cloud Pub/Sub is concerned, there are two messages). In this case, the content of the two messages would be the same, but their message IDs would be different. Therefore, it might be worth ensuring that you are looking at the service-provided message ID to ensure the messages are indeed duplicates.

*The subscribers are on different subscriptions, which means each of the subscribers would receive all of the messages.

If neither of these is the case, then duplicates should be relatively rare. There is an edge case in dealing with large backlogs of small messages with streaming pull (which is what the Python client library uses). Basically, if messages that are very small are published in a burst and subscribers then consume that burst, it is possible to see the behavior you are seeing. All of the messages would end up being sent to one of the two subscribers and would be buffered behind the flow control limits of the number of outstanding messages. These messages may exceed their ack deadline, resulting in redelivery, likely to the other subscriber. The first subscriber still has these messages in its buffer and will see these messages, too.
However, if you are consistently seeing two subscribers freshly started immediately receive the same messages with the same message IDs, then you should contact Google Cloud support with your project name, subscription name, and a sample of the message IDs. They will better be able to investigate why this immediate duplication is happening.

A: (Edited as I misread the deadlines)
Looking at the Streaming Pull docs, this seems like an expected behavior:
The gRPC StreamingPull stack is optimized for high throughput and therefore
buffers messages. This can have some consequences if you are attempting to
process large backlogs of small messages (rather than a steady stream of new
messages). Under these conditions, you may see messages delivered multiple times
and they may not be load balanced effectively across clients.

From: https://cloud.google.com/pubsub/docs/pull#streamingpull


text:
Q: WP Delete User Button missing We have a Wordpress installation with a lot of users. If we wanted to delete a user so far, it took a long time until the delete button appeared. Then the deletion always worked. But now the button doesn't appear anymore. I have the feeling it's because it always first goes through the 400,000 users and it's because of that. I'm using WP version 4.9.8

A: if there are many users it is loading very long. then you can filter the users to be displayed like this:
add_action( 'load-users.php', function () {
  // Make sure the "action" is "delete".
  if ( 'delete' !== filter_input( INPUT_GET, 'action' ) ) {
    return;
  }

  add_filter( 'wp_dropdown_users_args', function ( $query_args, $args ) {
    if ( 'reassign_user' === $args[ 'name' ] ) {
      $query_args[ 'role' ] = 'administrator';
    }

    return $query_args;
  }, 10, 2 );
} );