text:
Q: Switch button, disable change state onClick I want to use a switch button but I want to disable the change status on click, let this change only to the drag option. I try to set onclick listener to do nothing but when I click on the button always change the state.
Some one know to disable the change status onClick?

A: If you want to only change the state of the switch with swipe do the following:
 switchbutton = view.findViewById(R.id.switch2);
    switchbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switchbutton.setChecked(!switchbutton.isChecked());
        }
    });

A: Using a switch widget you will have to create your customSwitch class and override the onTouchEvent method to return true when you detect a click:
public boolean onTouchEvent(MotionEvent ev) {
    boolean response;
    switch (ev.getAction()){
        case MotionEvent.ACTION_DOWN:
            x = ev.getX();
            response = super.onTouchEvent(ev);
            break;
        case MotionEvent.ACTION_UP:
            response = Math.abs(x - ev.getX()) <= 10 || super.onTouchEvent(ev);
            break;
        default:
            response = super.onTouchEvent(ev);
            break;
    }
    return response;
}

The number 10 is a tolerance value as some devices report a movement event of 3 or 6 pixels or so instead of a click, so with this you control: 10 pixels or less is click (and ignore it) or more distance is considered movement and let this movement pass trought normal switch behaivor.
Declare x as a class level variable, default value is 0.
MotionEvent.ACTION_DOWN is allways called first so you will have x with the starting value on the X axis of the MotionEvent.

A: use Toggle Button instead of Button
xml for toggle button
<ToggleButton
    android:id="@+id/togglebutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

in java class
ToggleButton toggle = (ToggleButton) findViewById(R.id.togglebutton);
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            // The toggle is enabled
        } else {
            // The toggle is disabled
        }
    }
});

A: //onClickListener
public void tglOnClick(View v) {
    ToggleButton tgl = (ToggleButton) v;

    //do something based on toggle status after clicking
    if (tgl.isChecked())
        //do something
    else
        //do something else

    //revert button state so that it can be controlled by some external logic
    tgl.setChecked(!tgl.isChecked());

}
This worked for me. In my case, the clicking the toggle button sent a request to a service, and if the service replied "OK", the message handler set the correct state of the toggle button.

A: 4 years later found a solution pretty clean and easy for this usecase :
Create your custom switch and override performClick(), that part allows to avoid CompoundButton to react at click :
class CustomSwitch @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : SwitchMaterial(context, attrs, defStyleAttr) {

    override fun performClick(): Boolean {
        return false
    }
}

Second part is to forbid TextView inheritance to react at click and for that just add this to your XML :
android:textIsSelectable="false"


text:
Q: How do I know which clothes are going to be popular? In the game, it sometimes warns you that one of the companies you have clothing from is going to be the next big thing. It tells you to stock up ahead of time so that when they can't keep up with demand, you have enough clothes to last so that your customers leave happy.
Problem is, I can't figure out how to predict this, whatsoever.
How do I know what clothes are going to be popular?

A: I've found that once you have enough rapport with a company (usually 2 stars), they'll talk to you about their new product before they actually release it.  They give you just enough lead time to order more and get it delivered before the factory stoppage happens.
For those companies where you don't have enough rapport, and therefore no advance warning, you can check the Trends report (Store --> Trends), to see which company is trending upwards.  The ones to especially look out for are those that previously weren't on the top 5 list.  You can make an educated guess from here.
eg. I get a message saying an unknown company is going to be releasing something new.  I check the trends screen, and T.G. Trousers was not on the top 5 previously, and I don't have enough rapport for them to warn me.  Grade One Garments is also trending upwards, but I do have enough rapport with them, and I didn't get any warning from them.  So I can eliminate them, and make a guess that T.G. Trousers is the one I want.

redpajama_set_name: RedPajamaStackExchange


text:
Q: how to override a shared component in spartacus storefront I am trying to add more information to the price section in the cx-cart-item component:
cart entries
However, I don't see an outlet so that I can just attach the component "after" or "before" the price
How do I extend the render functionality? I am thinking:

*

*copying and pasting the html and ts to just "append" the functionality - when I tried this I get errors indicating that tags such as cx-media does not exist

*find a way to override the component, however, I think this is not possible since I was not able based on the documentation here https://sap.github.io/cloud-commerce-spartacus-storefront-docs/customizing-cms-components/#custom-angular-cms-components

A: The simplest answer, for now, would be overriding the component, as in the docs you've specified.
You can check the working example here:
https://github.com/tobi-or-not-tobi/spartacus-bootcamp/tree/master/src/app/features/components/banner
In the future, it should be possible to easily replace not only cms components, but also lower-level components.


text:
Q: Why is "git format-patch" between two commits different from "git diff"? Suppose there are 2 branches x1 and x2 both based on master. git diff x1..x2 shows the diff between x1 and x2, but git format-patch x1..x2 -1 --stdout shows the diff between master and x2. Is there a way to let format-patch to show the diff between x1 and x2?
For example:
git branch x1 master
git branch x2 master
git switch x1
echo a >> README
git commit -a -m x1 # one extra line at x1
git switch x2
echo a >> README
echo a >> README
git commit -a -m x2 # 2 extra lines at x2

git diff x1..x2 # show one line betwen x1 and x2
git format-patch -1 --stdout x1..x2 # show 2 lines between master and x2

If I understand correctly, it seems git format-patch only emits real commits (could be stashed) but it will not try to calculate interdiff.

A: TL;DR: if you're looking for something like an interdiff, consider git range-diff.
Long

If I understand correctly, it seems git format-patch only emits real commits (could be stashed) but it will not try to calculate interdiff.

This is correct, but may be coming from some wrong assumptions.
In particular, git format-patch is a method of turning a commit—or a whole chain of commits—into something that will survive email.  Whoever gets the patch can use git am to create an equivalent commit, preserving most of the metadata and the git patch-id.1
Since this is aimed at preserving a chain of commits, format-patch looks specifically at a single chain of commits.  The x1..x2 syntax you used is allowed, but when giving it a single revision, that's treated as a since specifier—that is, git format-patch X means git format-patch X..HEAD.
Note that in this kind of revision range—A..B for any valid specifiers A and B; see the gitrevisions documentation for more detail—commit B acts as a positive reference and is normally included in the selected commits, but A is a negative reference, as in ^A, and is always excluded.  Hence if A and B name the same commit, B winds up being excluded too.  However, you can exclude a commit that normally wouldn't appear anyway.  In particular, you have created this situation:
       I   <-- x1
      /
...--H   <-- master
      \
       J   <-- x2

such that the commits selected by x1..x2 are always just commit J, and the commits selected by x2..x1 are always just commit I—the same set you'd get with master..x2 and master..x1 respectively.
(Note: the -number option to git format-patch forces a change in behavior when given a single commit specifier, instead of a range.  It doesn't seem to have any effect when using a range specifier.)
The git diff command, however, does not obey these rules.  Normally, a range A..B means all commits reachable from B, excluding all commits reachable from A, which is what we saw above with the master/x1/x2 fork.  But git diff A..B just means git diff A B.  Git simply extracts commit A to use as the left side, and extracts commit B to use as the right side, and compares them.  There is no interdiff here either, nor any attempt to reach back to the common commit on master.
The git diff command has a special interpretation for the three-dot range syntax too: git diff A...B means find a merge base between A and B, then compare that to commit B.  This is also not any kind of interdiff—git diff just doesn't do that at all.

1The committer and committer-date are, by default, new when using git am.  However, you can also add --committer-date-is-author-date.  If you do this and you set things up so that your committer name matches the original committer name, and apply it to the right starting commit, you'll even get a commit that has the same hash ID, provided the original commit has the same author and committer dates.  That is, with a little effort, sometimes an emailed patch can result in a bit-for-bit identical commit, as if you had used git bundle or similar.

A:
Why is "git format-patch" between two commits different from "git diff"?

The interpretation of .. is different for the two commands. git diff is looking for two commits, git format-patch is looking for one or more patch series.
They're both trying to be helpful, to turn what you told them into something they can work with.
git diff effectively ignores the two dots. It's looking for two commits, you gave it two commits, those are the two commits. This is perhaps less baffling when you consider that it also has its own (quite useful, and sensible) interpretation of the three-dot syntax.
git format-patch is looking for patch series, so it uses the more common dots interpretation shared among all git rev-list-driven commmands.

A: There is another scenario where git format-patch is actually using git diff with more than two commits, as explained in this 2018 thread:

When re-submitting a patch series, it is often helpful (for reviewers)
to include an interdiff or range-diff against the previous version.
Doing so requires manually running git-diff or git-range-diff and
copy/pasting the result into the cover letter of the new version.
This series automates the process by introducing git-format-patch options --interdiff and --range-diff which insert such a diff into the
cover-letter or into the commentary section of the lone patch of a
1-patch series.
In the latter case, the interdiff or range-diff is indented to avoid confusing git-am and human readers.

And, in another 2018 thread:

When submitting a revised a patch series, the --range-diff option embeds
a range-diff in the cover letter showing changes since the previous
version of the patch series.
The argument to --range-diff is a simple
revision naming the tip of the previous series, which works fine if the
previous and current versions of the patch series share a common base.
However, it fails if the revision ranges of the old and new versions of
the series are disjoint.
To address this shortcoming, extend
--range-diff to also accept an explicit revision range for the previous
series.
For example:
git format-patch --cover-letter --range-diff=v1~3..v1 -3 v2

This is fixed with Git 2.29 (Q4 2020), where "format-patch --range-diff=<prev> <origin>..HEAD" has been taught not to ignore <origin> when <prev> is a single version.
See commit 07a7f8d, commit 72a7239, commit cdffbdc (08 Sep 2020) by Eric Sunshine (sunshineco).
(Merged by Junio C Hamano -- gitster -- in commit 634e008, 22 Sep 2020)

format-patch: use 'origin' as start of current-series-range when known
Signed-off-by: Eric Sunshine

When formatting a patch series over origin..HEAD, one would expect that range to be used as the current-series-range when computing a range-diff between the previous and current versions of a patch series.
However, infer_range_diff_ranges() ignores origin..HEAD when --range-diff=<prev> specifies a single revision rather than a range, and instead unexpectedly computes the current-series-range based upon <prev>.
Address this anomaly by unconditionally using origin..HEAD as the current-series-range regardless of <prev> as long as origin is known, and only fall back to basing current-series-range on <prev> when origin is not known.


text:
Q: Cannot run ECharts Demo locally After I download the following ECharts demo, and open it in my browser (Safari or Chrome), it keeps showing it is loading, and the demo will never start. How do I make this demo work locally for me?
Link: https://ecomfe.github.io/echarts-examples/public/editor.html?c=graph

A: There are many ways cause it keeps loading, I guess your problem is caused by loading data resource failed.
There is an ajax in this demo
$.get('data/asset/data/les-miserables.gexf', function() { ...

If you didn't change the resource URL, function $.get run failed so the statement myChart.hideLoading(); didn't execute that why it keeps loading
You should change url data/asset/data/les-miserables.gexf to https://ecomfe.github.io/echarts-examples/public/data/asset/data/les-miserables.gexf
There is jsfiddle


text:
Q: Is there any non-destructive way to change the preferred drive in a raid1 mdadm setup? I have observed empirically that for a raid1 mdadm array, mostly serving sequential reads from single processes, the first disk is basically always picked. This is also confirmed by this code which was linked online in this question.
To demonstrate the effect, see below iostat:
iostat -h | grep -E "sda|sdb"
     5.95         3.9M         5.9k         0.0k     **2.8T**     4.2G       0.0k sda <-- preferred
     0.38        12.1k         5.9k         0.0k       8.6G       4.2G       0.0k sdb

I would like to know if there is a non-destructive way to change that and decide which disk should be the preferred?
I tried changing the physical disk order, but the was the first disk still gets treated as preferred.
During this process the RaidDevice and Number changed as expected but to no avail to what I was trying to achieve. Moreover, while the old sda changed to sdb and vice-versa, in mdadm --detail they didn't.
Following are some info of the setup:
$ mdadm -V
mdadm - v3.4 - 28th January 2016

Unbalanced reads before switch:
iostat -h | grep -E "sda|sdb"
     5.95         3.9M         5.9k         0.0k       2.8T       4.2G       0.0k sda <-- preferred
     0.38        12.1k         5.9k         0.0k       8.6G       4.2G       0.0k sdb

Unbalanced reads after switch:
$ iostat -h | grep -E "sda|sdb"
    11.60       427.9k        99.5k         0.0k     252.4M      58.7M       0.0k sda
   120.68       105.5M        99.5k         0.0k      62.2G      58.7M       0.0k sdb <-- still preferred

Details of array before switch:
cat /proc/mdstat
md2 : active raid1 sdb3[0] sda3[2]
      13667560448 blocks super 1.2 [2/2] [UU]

mdadm --detail /dev/md2
/dev/md2:
        Version : 1.2
     Raid Level : raid1
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
           UUID : ddb468d7:8c866278:6f56b7eb:0a911253
    Number   Major   Minor   RaidDevice State
       0       8        3        0      active sync   /dev/sda3
       2       8       19        1      active sync   /dev/sdb3

Details of array after switch:
cat /proc/mdstat
md2 : active raid1 sda3[0] sdb3[2]
      13667560448 blocks super 1.2 [2/2] [UU]

mdadm --detail /dev/md2
/dev/md2:
        Version : 1.2
     Raid Level : raid1
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
           UUID : ddb468d7:8c866278:6f56b7eb:0a911253
    Number   Major   Minor   RaidDevice State
       0       8       19        0      active sync   /dev/sdb3
       2       8        3        1      active sync   /dev/sda3 <- this partition name didn't get changed


text:
Q: Reveal In Finder Using JXA (Javascript for Automation on Mac) I am converting some of the automator workflows I made over the years into JXA and I am having some trouble with some basic functions. Firstly, I am simply trying to open a folder in finder from a specific path. I came across this link for opening a location in finder, but it does not seem to work for a folder.
In other Javascript implementations, I am used to doing something like this:
var f = new File("path/to/my/file/or/folder");
f.execute();

it doesn't seem to work in JXA. I can navigate up and down a tree using something like this:
var run = function(){
    var finder = Application("Finder");
    finder.includeStandardAdditions = true;

    return finder.startupDisk.folders["Users"].open();
}

But that seems very tedious and I don't know how to make it dynamic. Is there a way to take a POSIX path and open finder at that location?
Thanks for all the help !

A: (function () {
    'use strict';

    var a = Application.currentApplication(),
        sa = (a.includeStandardAdditions = true, a),
        fi = Application('Finder');

    var strPath = $('~/Code/')
        .stringByStandardizingPath.js

    fi.reveal(Path(strPath));

    // OR e.g.
    //fi.reveal(sa.pathTo('downloads folder'));

    fi.activate();
})();


text:
Q: in VS Code ImportError: cannot import name 'Mapping' from 'collections' I am trying to connect to Postgress and create a folder test.db via Flask.
When I run "python3" in the terminal and from there when I run "from app import db" I get an import error:
ImportError: cannot import name 'Mapping' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)

I have tried all the troubleshooting but none of them worked. Please advise.
Here is the full stack:

A: As rightly pointed out, you need to import from the new abc module inside of collections for later versions of Python.
If you need to make your code backwards compatible with older versions of Python, you can use this:
try:
    from collections.abc import Mapping
except ImportError:
    from collections import Mapping

A: As Mitra said above, change:
from collections import Mapping

to
from collections.abc import Mapping

A: Use older version of python (eg 3.8)

A: Cause of the error:
If you tried the import in python3.9.x, it becomes clear:
╭─ ~/command_line $ ───────────────────────────────────────────────────── ✔ │ 22:02:44
╰─ python3
Python 3.9.10 (main, Jan 15 2022, 11:40:53)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from collections import Mapping
<stdin>:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working

It clearly mentions that in 3.10 it will stop working. So to use please change the version to python3.9 or below.
If you are using pipenv to manage your virtual-environment, then the steps could be as follow:
$ pipenv --rm        # to remove the virtual env
$ exit               # to exit the virtual env
$ vim Pipfile        # here change the version to '3.9' by replacing '3.10'
$ pipenv shell       # this will create a virtual env with 3.9
$ pipenv install     # to install the requirements

We just switched from python3.10 to python3.9, which supports the code for now. But I would suggest to use John R Perry's solution(the accepted one) instead for long term usage.

A: As stated by others, this is caused by a change in the collections interface starting with Python 3.10. As far as I can see there are three options to mitigate this issue so far:

*

*Revert to Python 3.9.

*If the error occurs in a third-party library, try to update this library first (pip install <package> --upgrade).

*Patch the code manually.
For patching the ImportError, see https://stackoverflow.com/a/69727802/13994294.

A: That's about python version.
in most time python 3.10 have this problems.
You can solve this problem with use python 3.9 or 3.8 version.
or
if error from packages like python-docx or other packages about MS you can probably solve it by using pipwin.

A: Same here, but I resolved the problem with:
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U

This wi

A: Youc could try from typing import Mapping as an alternative.

A: Just update to requests 2.27.1 and python 3.10.2 or later, and the problem will be fixed.

A: In my environment the problem was solved using bug fix Python version 3.10.2

A: You will encounter this problem starting Python version 3.8. You could either use Python version 3.7.9 and earlier or refer to John's answer above and make the change in the outdated import statement.

A: Recommend using a previous version of python (e.g 3.8 pr 3.9) in a virtualenv rather than reverting your python on your root system.
virtualenv --python="/YOUR PATH/python3.9" "name of your env"


text:
Q: An appearance was requested without a variable text field I have come across this error while trying to fill in a form field. I really have no idea what it means and only occurs on some of the PDFs that I have.
I found it being thrown from AcroFields.java here:
if (!PdfName.CH.equals(fieldType))
        throw new DocumentException("An appearance was requested without a variable text field.");

Could anyone provide insight into this error and what is causing it?

A: You're using a very old version of iText, please upgrade!
In the most recent version, exceptions are localized:
if (!PdfName.CH.equals(fieldType))
    throw new DocumentException(MessageLocalization.getComposedMessage(
        "an.appearance.was.requested.without.a.variable.text.field"));

As for your question: the error tells you exactly what is happening. You are setting a value for a field for which two or more appearances are defined. However, the value you've chosen is an invalid value.
For instance: you have a check box for which the possible states are "Off" and "On", but you're trying to set the value "1". There is no appearance defined for the value "1" hence the exception.


text:
Q: Showing a throbber/Spinner in the GUI using Async/await in lamda expression I have tried or a while now to get my gui to show an Throbber/progress spinner while I execute a task. Unfortunately the throbber is not showing up so far.
Its implemented using the MVVM principle. The button press in the Gui calls the command that then executed the method and Iam sure I need to integrate the displaying the throbber and then making the called method asynchronous.
Unfortunatly the command/method call is supposed to be written as a lambda expression. And I havent found a way yet to integrate async/await into the lambda expression for this case.
//Binding of - OpenExportDataDialogCommand
private ICommand openExportDataDialogCommand;
     //Here needs the activation of the Throbber to happen
     //exportWindow.Throbber.IsBusy = true;

        //And here the Method "ExportDataDialog" needs to be executed in a new thread, so as an async task.
        public ICommand OpenExportDataDialogCommand => openExportDataDialogCommand ??
            (openExportDataDialogCommand = new RelayCommand(_ => ExportDataDialog()));

private async Task ExportDataDialog()

        {
                //work is done and the window gets closed
        }

From what I understand I would usually just "await" the Method. But I always get an syntax error no matter where I implement the await command in the lambda expression.
EDIT:
I managed to improve the situation. The throbber now shows up but merely for a brief second. Then a new error hits "The calling thread cannot access this object because a different thread owns it".
According to this (The calling thread cannot access this object because a different thread owns it) article I need something like
(openExportDataDialogCommand = new RelayCommand this.Dispatcher.Invoke(async _ => await ExportDataDialog());

or someone with more expierence with lambda expressions my error here is probably quiet obvious, but again i dont know how to position the Dispatcher.Invoke.


text:
Q: I need to create a web page and create a checkbox named important or no I need to create a web page and create a checkbox named important or not when user will click on important then data should be stored in the database accordingly. The project which I have to extend ( https://gitlab.com/mariusz.jarocki/pwa2019 ) is written using Node JS and MongoDB at the backend side and AngularJS at the frontend side.
Can you evaluate this task? Is this difficult or easy?

A: In the grand scheme of things, the task you are describing is relatively easy. I can't speak to how difficult the task is for you specifically, though. The fact that you are asking the question might indicate that it is a difficult task for you.
Creating a web page with a form is simple, then you need to have the form submit a POST request that the Node.js server handles. Make sure the web page includes the checkbox status in the request. The server then needs a route for that specific request that adds or modifies a document in the DB.


text:
Q: Incorrect syntax near 'ENTUserAccount' Incorrect syntax near 'ENTUserAccount'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'ENTUserAccount'.
Source Error:
Line 76:             " WHERE " + fieldName + " = {0}" +
Line 77:             " AND " + fieldNameId + " <> {1}";
Line 78:             var result = db.ExecuteQuery(sql, new object[] { value, id });
Line 79:             List list = result.ToList();
Line 80:             return (list[0].DuplicateCount > 0);
Source File: c:\Users\ClassicSofts\Documents\Visual Studio 2012\Projects\PaidTimeOffSolution\V2.PaidTimeOffDAL\Framework\ENTUserAccountData.cs    Line: 78
Stack Trace:
[SqlException (0x80131904): Incorrect syntax near 'ENTUserAccount'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +1753346
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +5295154
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +242
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1682
   System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +59
   System.Data.SqlClient.SqlDataReader.get_MetaData() +90
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +365
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite) +1325
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +175
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +53
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +134
   System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41
   System.Data.Common.DbCommand.ExecuteReader() +12
   System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult) +1306
   System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries) +118
   System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +342
   System.Data.Linq.DataContext.ExecuteMethodCall(Object instance, MethodInfo methodInfo, Object[] parameters) +83
   System.Data.Linq.DataContext.ExecuteQuery(String query, Object[] parameters) +254
   V2.PaidTimeOffDAL.Framework.ENTUserAccountData.IsDuplicate(HRPaidTimeOffDataContext db, String tableName, String fieldName, String fieldNameId, String value, Int32 id) in c:\Users\ClassicSofts\Documents\Visual Studio 2012\Projects\PaidTimeOffSolution\V2.PaidTimeOffDAL\Framework\ENTUserAccountData.cs:78
   V2.PaidTimeOffDAL.Framework.ENTUserAccountData.IsDuplicateWindowsAccountName(HRPaidTimeOffDataContext db, Int32 userAccountId, String windowsAccountName) in c:\Users\ClassicSofts\Documents\Visual Studio 2012\Projects\PaidTimeOffSolution\V2.PaidTimeOffDAL\Framework\ENTUserAccountData.cs:69
   V2.PaidTimeOffBLL.Framework.ENTUserAccountEO.Validate(HRPaidTimeOffDataContext db, ENTValidationErrors& validationErrors) in c:\Users\ClassicSofts\Documents\Visual Studio 2012\Projects\PaidTimeOffSolution\V2.PaidTimeOffBLL\Framework\ENTUserAccountEO.cs:66
   V2.PaidTimeOffBLL.Framework.ENTUserAccountEO.Save(HRPaidTimeOffDataContext db, ENTValidationErrors& validationErrors, Int32 userAccountId) in c:\Users\ClassicSofts\Documents\Visual Studio 2012\Projects\PaidTimeOffSolution\V2.PaidTimeOffBLL\Framework\ENTUserAccountEO.cs:23
   V2.PaidTimeOffBLL.Framework.ENTBaseEO.Save(ENTValidationErrors& validationErrors, Int32 userAccountId) in c:\Users\ClassicSofts\Documents\Visual Studio 2012\Projects\PaidTimeOffSolution\V2.PaidTimeOffBLL\Framework\ENTBaseEO.cs:49
   Administration_User.Master_SaveButton_Click(Object sender, EventArgs e) in c:\Program Files\IIS\PaidTimeOffUI1\Administration\User.aspx.cs:27
   PaidTimeOffEditPage.btnSave_Click(Object sender, EventArgs e) in c:\Program Files\IIS\PaidTimeOffUI1\PaidTimeOffEditPage.master.cs:27
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9553594
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724


text:
Q: Accidentally merged master into develop and pushed I work in a git repo where we maintain a master and a develop branch. Changes are made in develop and merged into master before releases. Today I accidentally merged master into develop and pushed the result to develop. A git log in develop now shows the merge develop into master commits. I need to fix this somehow. I found the most recent good commit using git reflog. What is the correct approach to revert to it?
Since I have already pushed, I would like to avoid rewriting history. However, I'm not sure that I can use git revert. I'm not convinced that the "revert a faulty merge" howto and other SO questions apply since the commits that I want to revert are merges themselves (https://www.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.txt).

A: You can fix this by resetting your local branch back to the last good commit, then pushing that:
git checkout develop
git reset --hard lastgoodcommit
git push origin develop

Note that your upstream repository may disallow non-fast-forward merges by default. If so, you will need to modify that option on your upstream, do the above push, and then restore the original setting.

A: You can use git revert to revert the merge.  Just be aware that when you do that, you make a future "re-merge" more difficult.  Read that message you linked closely—it says a lot about how to make the future "re-merge" work—but be aware that it's talking about merging develop into master, and you said you did the opposite, merged master into develop:
A -- B -- C -- D -- E          <-- master
      \          \
       F - G - H - M           <-- develop

In this case (having merged master into develop instead of the other way around) you can choose a number of different options, all with advantages and drawbacks...
The easiest method, which I prefer if it's an option
(0) Do nothing.  If merging in C and D doesn't break the develop branch, just leave it that way.  Later, someone will git checkout master and git merge --no-ff develop and get this (let's say one more commit I got added to develop first):
A -- B -- C -- D -- E -- M2    <-- master
      \          \      /
       F - G - H - M - I       <-- develop

Here merge finds what's been done in develop since it split off from master, which was at B.  So it puts in F, G, and H, skips any parts of M that came off master (probably all of it), and finally puts in I and makes merge-commit M2 (because of commit E; but if E were not there, it would be because I used --no-ff too).
Some easy methods with obvious drawbacks
(1) Just "rewrite history": erase commit M from branch develop.  Alert everyone else who uses the branch that this is about to happen: that commit M is going away and they should take whatever measures they must, to handle this.
(2) Stop using the old name develop, make a new branch name develop1 or whatever:
A -- B -- C -- D -- E          <-- master
     |           \
     |             M           <-- develop
      \          /
       F - G - H               <-- develop1

This is the same as option (1) except that the commit M is still there, along with the branch label on it, and you have a new/different branch label pointing to commit H.  You still need to alert everyone, but it might make their jobs easier.  You can delete develop later, when everyone is good with that.
The revert and its drawbacks
(3) Revert the merge.  As in the linked article, let's use W to represent the new revert commit:
A -- B -- C -- D -- E          <-- master
      \          \
       F - G - H - M - W       <-- develop

What's in W?  Whatever it takes to "erase the effect" of the merge.  In this case, that means, changes that un-do whatever was done in C and D.  So far so good, develop has just the changes from F, G, and H, again.  The problem occurs later, if/when someone does:
git checkout master
git merge develop

The second command goes rooting around to find where master and develop were split, i.e., commit B, so it picks up all the changes since then.  Which at this point include those in W, which will un-do C and D, not at all what you wanted.  It can be fixed-up afterward, but whoever does the merge has to know about this "delete C and D" time-bomb waiting for them.
Note that this is the same merge as in the "do nothing" option (0).  The issue here is the contents of W.  In case (0), you want the contents of commit I, but here you don't want the contents of W.
One more option
This is arguably the worst option of all, given what's shown above, but I'll list it anyway:
(4) make an all-new branch with copies of the commits you want to keep, and name it develop.  (Or name it something else, but then we're back to the develop1-like situation above, and you should probably just use that one.)  Whether you keep the old-develop branch, or just abandon it (by not labeling it), is up to you, but I will draw it in:
       F' - G' - H'            <-- develop
      /
A -- B -- C -- D -- E          <-- master
      \          \
       F - G - H - M           <-- old-develop

This is described in the link you included.  It's only really useful in more complex cases.

A: I use GIT Extensions. There is a feature to right click a revision in the UI and revert back to it.

A: Yes, you can revert a merge, but you need to specify which parent is the mainline. Since you merged develop into master, this should do the trick:
git revert --mainline 1 HEAD

To make sure you have exactly what you want, you should do a diff with $lastgoodcommit, however, $lastgoodcommit should be HEAD^. This is of course, if you haven't made commits on top of the merge, if you have, then you need to replace HEAD with the merge commit.
Finally, you can also do the revert manually, by checking out the code on top of the current commit:
git checkout $lastgoodcommit -- .

The '-- .' is there to differentiate from a normal checkout, where HEAD is switched to the specified commit, in the command here, all the files in the working directory, and the staging area, are going to be exactly the same as they were in $lastgoodcommit. If you do a diff with $lastgoodcommit, you should see, again, no changes. Essentially it's a revert.
You could also try 'git checkout --patch' to selectively revert chunks of code.


text:
Q: How to return the count, while using nested foreach loops in the stream I am using java8 streams to iterate two lists, In that one list contains some custom objects and another contains string.
With this, I have to call a method by passing custom object and sting as a input and then I have to get the count.
This is what I tried:
public int returnCode()  {
        /*int count = 0;
         * list.forEach(x -> {
            list2.forEach(p -> {
                count+ = myDao.begin(conn, x.getCode(), p);
            });
            return count;
        });*/
    }

compiler is giving an error that count should be final.
Can anyone, give me how to do this in a better way.

A: Lambdas mainly substitutes anonymous inner classes. Inside an anonymous inner class you can access only final local variables. Hence the same holds true with lambda expressions. Local variable is copied when JVM creates a lambda instance, hence it is counter intuitive to allow any update to them. So declaring the variable as final would solve the issue. But if you make it final you won't be able to do this, leading to another pitfall.
count+ = myDao.begin(conn, x.getCode(), p);

So your solution is not good and does not comply with lambda. So this will be a one way of doing it.
final int count = customObjects.stream()
    .mapToInt(co -> strings.stream().mapToInt(s -> myDao.begin(conn, co.getCode(), s)).sum())
    .sum();

A: What you're attempting to do is not possible as local variables accessed from a lambda must be final or effectively final i.e. any variable whose value does not change.
You're attempting to change the value of count in the lambda passed to the forEach hence the compilation error.
To replicate your exact code using the stream API, it would be:
int count = list.stream()
                .limit(1)
                .flatMapToInt(x -> list2.stream().mapToInt(p -> myDao.begin(conn, x.getCode(), p)))
                .sum();

However, if you want to iterate over the entire sequence in list and not just the first then you can proceed with the following:
int count = list.stream()
                .flatMapToInt(x -> list2.stream().mapToInt(p -> myDao.begin(conn, x.getCode(), p)))
                .sum();


text:
Q: phpcs works, but output many error with it In my project i use composer phpcs to test my code style phpcs --standard=PSR12 src/ tests/ and it's work well, all error are outputs. For example:
FILE: /home/user/PhpstormProjects/php-vadzim-yanushchyk/src/Task11/fibonacciNumber.php
--------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------
 35 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------

Time: 99ms; Memory: 8MB

But also i receive many error with it.
PHP ParseError:  Unclosed '(' in  on line 1
PHP Stack trace:
PHP   1. {main}() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/bin/phpcs:0
PHP   2. include() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/bin/phpcs:117
PHP   3. PHP_CodeSniffer\Runner->runPHPCS() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/bin/phpcs:18
PHP   4. PHP_CodeSniffer\Runner->init() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Runner.php:70
PHP   5. PHP_CodeSniffer\Ruleset->__construct($config = class PHP_CodeSniffer\Config { private $settings = ['files' => [...], 'standards' => [...], 'verbosity' => 0, 'interactive' => FALSE, 'parallel' => 1, 'cache' => FALSE, 'cacheFile' => NULL, 'colors' => FALSE, 'explain' => FALSE, 'local' => FALSE, 'showSources' => FALSE, 'showProgress' => FALSE, 'quiet' => FALSE, 'annotations' => TRUE, 'tabWidth' => 4, 'encoding' => 'utf-8', 'extensions' => [...], 'sniffs' => [...], 'exclude' => [...], 'ignored' => [...], 'reportFile' => NULL, 'generator' => NULL, 'filter' => NULL, 'bootstrap' => [...], 'reports' => [...], 'basepath' => NULL, 'reportWidth' => 232, 'errorSeverity' => 5, 'warningSeverity' => 5, 'recordErrors' => TRUE, 'suffix' => '', 'stdin' => FALSE, 'stdinContent' => NULL, 'stdinPath' => NULL, 'unknown' => [...]]; public $dieOnUnknownArg = TRUE; private $cliArgs = [0 => '--tab-width=4'] }) /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Runner.php:332
PHP   6. PHP_CodeSniffer\Ruleset->populateTokenListeners() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Ruleset.php:218
PHP   7. PHP_CodeSniffer\Sniffs\AbstractPatternSniff->register() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Ruleset.php:1230
PHP   8. PHP_CodeSniffer\Sniffs\AbstractPatternSniff->parse($pattern = 'function abc(...);') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php:90
PHP   9. PHP_CodeSniffer\Sniffs\AbstractPatternSniff->createTokenPattern($str = '(') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php:824
PHP  10. PHP_CodeSniffer\Tokenizers\Tokenizer->__construct($content = '<?php (?>', $config = NULL, $eolChar = *uninitialized*) /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php:916
PHP  11. PHP_CodeSniffer\Tokenizers\PHP->tokenize($string = '<?php (?>') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php:90
PHP  12. token_get_all($code = '<?php (?>') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php:509
PHP ParseError:  Unclosed '(' in  on line 1
PHP Stack trace:
PHP   1. {main}() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/bin/phpcs:0
PHP   2. include() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/bin/phpcs:117
PHP   3. PHP_CodeSniffer\Runner->runPHPCS() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/bin/phpcs:18
PHP   4. PHP_CodeSniffer\Runner->init() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Runner.php:70
PHP   5. PHP_CodeSniffer\Ruleset->__construct($config = class PHP_CodeSniffer\Config { private $settings = ['files' => [...], 'standards' => [...], 'verbosity' => 0, 'interactive' => FALSE, 'parallel' => 1, 'cache' => FALSE, 'cacheFile' => NULL, 'colors' => FALSE, 'explain' => FALSE, 'local' => FALSE, 'showSources' => FALSE, 'showProgress' => FALSE, 'quiet' => FALSE, 'annotations' => TRUE, 'tabWidth' => 4, 'encoding' => 'utf-8', 'extensions' => [...], 'sniffs' => [...], 'exclude' => [...], 'ignored' => [...], 'reportFile' => NULL, 'generator' => NULL, 'filter' => NULL, 'bootstrap' => [...], 'reports' => [...], 'basepath' => NULL, 'reportWidth' => 232, 'errorSeverity' => 5, 'warningSeverity' => 5, 'recordErrors' => TRUE, 'suffix' => '', 'stdin' => FALSE, 'stdinContent' => NULL, 'stdinPath' => NULL, 'unknown' => [...]]; public $dieOnUnknownArg = TRUE; private $cliArgs = [0 => '--tab-width=4'] }) /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Runner.php:332
PHP   6. PHP_CodeSniffer\Ruleset->populateTokenListeners() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Ruleset.php:218
PHP   7. PHP_CodeSniffer\Sniffs\AbstractPatternSniff->register() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Ruleset.php:1230
PHP   8. PHP_CodeSniffer\Sniffs\AbstractPatternSniff->parse($pattern = 'function abc(...)') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php:90
PHP   9. PHP_CodeSniffer\Sniffs\AbstractPatternSniff->createTokenPattern($str = '(') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php:824
PHP  10. PHP_CodeSniffer\Tokenizers\Tokenizer->__construct($content = '<?php (?>', $config = NULL, $eolChar = *uninitialized*) /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php:916
PHP  11. PHP_CodeSniffer\Tokenizers\PHP->tokenize($string = '<?php (?>') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php:90
PHP  12. token_get_all($code = '<?php (?>') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php:509
PHP ParseError:  Unclosed '(' in  on line 1
PHP Stack trace:
PHP   1. {main}() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/bin/phpcs:0
PHP   2. include() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/bin/phpcs:117
PHP   3. PHP_CodeSniffer\Runner->runPHPCS() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/bin/phpcs:18
PHP   4. PHP_CodeSniffer\Runner->init() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Runner.php:70
PHP   5. PHP_CodeSniffer\Ruleset->__construct($config = class PHP_CodeSniffer\Config { private $settings = ['files' => [...], 'standards' => [...], 'verbosity' => 0, 'interactive' => FALSE, 'parallel' => 1, 'cache' => FALSE, 'cacheFile' => NULL, 'colors' => FALSE, 'explain' => FALSE, 'local' => FALSE, 'showSources' => FALSE, 'showProgress' => FALSE, 'quiet' => FALSE, 'annotations' => TRUE, 'tabWidth' => 4, 'encoding' => 'utf-8', 'extensions' => [...], 'sniffs' => [...], 'exclude' => [...], 'ignored' => [...], 'reportFile' => NULL, 'generator' => NULL, 'filter' => NULL, 'bootstrap' => [...], 'reports' => [...], 'basepath' => NULL, 'reportWidth' => 232, 'errorSeverity' => 5, 'warningSeverity' => 5, 'recordErrors' => TRUE, 'suffix' => '', 'stdin' => FALSE, 'stdinContent' => NULL, 'stdinPath' => NULL, 'unknown' => [...]]; public $dieOnUnknownArg = TRUE; private $cliArgs = [0 => '--tab-width=4'] }) /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Runner.php:332
PHP   6. PHP_CodeSniffer\Ruleset->populateTokenListeners() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Ruleset.php:218
PHP   7. PHP_CodeSniffer\Sniffs\AbstractPatternSniff->register() /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Ruleset.php:1230
PHP   8. PHP_CodeSniffer\Sniffs\AbstractPatternSniff->parse($pattern = 'abstract function abc(...);') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php:90
PHP   9. PHP_CodeSniffer\Sniffs\AbstractPatternSniff->createTokenPattern($str = '(') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php:824
PHP  10. PHP_CodeSniffer\Tokenizers\Tokenizer->__construct($content = '<?php (?>', $config = NULL, $eolChar = *uninitialized*) /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php:916
PHP  11. PHP_CodeSniffer\Tokenizers\PHP->tokenize($string = '<?php (?>') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php:90
PHP  12. token_get_all($code = '<?php (?>') /home/user/PhpstormProjects/php-vadzim-yanushchyk/vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php:509

How i can fix this problem? I have this error only on my computer, tests of github cs, lint when i push changes are successful.


text:
Q: How to convert node.js code to python using AWS Lamda@Edge I have this code in node.js. I just research this one and I want to convert this to python.
This code is to put signed URL on .m3u8 manifest file.
Does anyone know how to do this? I'm using AWS Lambda function.
Converting this node.js code to python.
const aws = require('aws-sdk');
const s3 = new aws.S3({ apiVersion: '2006-03-01' });
const bucketName = 'streaming-files';

exports.lambdaHandler = async (event, context, callback) => {
    const request = event.Records[0].cf.request;

    // Get the key name of S3 object
    const key = request.uri.substring(1);
    const s3Params = {
        Bucket: bucketName,
        Key: key
    };

    // Get the contents of the raw manifest file from the S3 bucket
    const s3Res = await s3.getObject(s3Params).promise();
    const srcBody = s3Res.Body.toString('utf-8');

    // rewriting process
    const qs = request.querystring;
    const signedBody = srcBody.replace(/\.m3u8/g, `.m3u8?${qs}`).replace(/\.ts/g, `.ts?${qs}`);

    // Add Respose header for content-type and CORS
    const response = {
        status: 200,
        statusDescription: 'OK',
        headers: {
            'content-type': [{
                key: 'Content-Type',
                value: 'application/x-mpegURL'
            }],
            'access-control-allow-methods': [{
                key: 'Access-Control-Allow-Methods',
                value: 'GET,HEAD'
            }],
            'access-control-allow-origin': [{
                key: 'Access-Control-Allow-Origin',
                value: '*'
            }]
        },
        body: signedBody,
    };
    callback(null, response);
};

Here's my python code. But I got stuck on getting the key name and also on rewriting process.
import json
import boto3

s3 = boto3.client('s3')

BUCKET_NAME = "streaming-files"

def lambda_handler(event, context):
    request = event['Records'][0]['cf']['request']

    # Get the key name of S3 object
    key = request['uri'];
    s3Res = s3.get_object(Bucket=BUCKET_NAME, Key=key)

    # Get the contents of the raw manifest file from the S3 bucket
    srcBody = s3Res['Body'].read().decode('utf-8')

    # rewriting process
    qs = request['querystring']
    signedBody = srcBody.replace(/\.m3u8/g, `.m3u8?${qs}`).replace(/\.ts/g, `.ts?${qs}`)

    response = {
        'status':  200,
        'statusDescription':  "OK",
        'headers': {
            'content-type': [
                {
                    'key': 'Content-Type',
                    'value': 'application/x-mpegURL'
                }
            ],
            'access-control-allow-methods': [
                {
                    'key': 'Access-Control-Allow-Methods',
                    'value': 'GET,HEAD'
                }
            ],
            'access-control-allow-origin': [
                {
                    'key': 'Access-Control-Allow-Origin',
                    'value': '*'
                }
            ]
        },
        'body': ''
    }
    return response

This code has syntax error:
const signedBody = srcBody.replace(/\.m3u8/g, `.m3u8?${qs}`).replace(/\.ts/g, `.ts?${qs}`);

I'm stuck with these.
How can I convert or what is the equivalent of these codes to python?
const key = request.uri.substring(1);
const signedBody = srcBody.replace(/\.m3u8/g, `.m3u8?${qs}`).replace(/\.ts/g, `.ts?${qs}`);


text:
Q: Formation of virtual image by parallel lights rays (also parallel to principal axis) in a diverging lens
*

*From my textbook, a diverging lens causes parallel light rays (also parallel to principal axis) refract in such a way that they can be extrapolated backwards to meet at a point which would be the focal point (I.e principal focus).

*However, is this not also similar to the formation of virtual images where real light rays can be extended using virtual light rays to converge at a point where the virtual image is located at?

*So does this mean that in the case stated in (1.), the parallel rays will form an image at the focal point?

*If so, how does this happen since the parallel rays (being parallel) will originate from different points of the object. So the image being formed at the single point where the virtual light rays converge contains multiple points?


text:
Q: Measure download volume from a service provider I have an internet service provider that uses satellites. I need to measure the actual download volume for specified time periods. My reading on this lead me to believe that SNMP will do this. Thus I looked for software to install on my ASUS router.
I found Merlin firmware for the RT-AC68U. This changes the firmware in my router and gives it SNMP capabilities. I set up the SNMP on the router. This is straight forward.
I am not able to understand how to get the measurements started or read them when I need to see the download volume over a specified time frame. How do I find those files and read them? How do I know that I have set up SNMP properly?


text:
Q: Add actionbarsherlock appcompat v7 to a project I have a project using actionbarsherlock working properly, but when I add a new Activity eclipse adds appcompat v7 automatically, add the projects doesn't compile anymore and it errors 100s of times saying some resources are already added to project.

A: You basically have to create the Java class manually, then create the XML file manually, then declare the Activity in your Android manifest. I ran into this issue and was really frustrated why they are forcing this AppCompat down our throats whenever we create a new activity


text:
Q: Download JSEclipse plugin stand-alone Is there anywhere I can download the stand-alone JSEclipse plugin, it seems like it only comes bundled with the trial edition FlexBuilder plugins.
It used to be available here:
http://www.interaktonline.com/products/eclipse/jseclipse/overview/
I still find it useful to use but I'd rather not have the cruft of an expired Flex builder trial license in my Eclipse.

A: It's not available anymore in the Adobe site, but I have it zipped, and uploaded the plugin to filefactory. Here's the link: JSeclipse. The zip has 2 folders: features and plugins. Unzip the folders into the corresponding folder in your eclipse and enjoy. I tested it in both Ganymede and Juno and it works in both.

A: You can download the plugin jar from here.
Or you can add the update site on Eclipse.

A: The answer given is for version 1.5 but the current version of JSEclipse is above 1.8
Does this mean that the correct answer is no? You can't get JSEclipse without FlexBuilder?


text:
Q: Undelete a specific folder with text files on a LUKS-encrypted, btrfs-formatted partition on GNU/Linux How can I "undelete" a folder full of files on a GNU/LINUX system, where the partition is LUKS-encrypted and formatted using btrfs *?
On my Debian Stable (currently Bullseye) machine I have all my data in a LUKS-encrypted partition (except /boot).  On that encrypted partition I'm using LVM to organize different volumes **, which are formatted using btrfs, where my actual data is.
So my disk setup looks as follows:
lsblk -o path,type,fstype,mountpoint
PATH                            TYPE  FSTYPE      MOUNTPOINT
/dev/sda                        disk
/dev/sda1                       part  ext2        /boot
/dev/sda2                       part
/dev/sda5                       part  crypto_LUKS
/dev/sr0                        rom
/dev/mapper/sda5_crypt          crypt LVM2_member
/dev/mapper/vg-root             lvm   btrfs       /
/dev/mapper/vg-var              lvm   btrfs       /var
/dev/mapper/vg-swap             lvm   swap        [SWAP]
/dev/mapper/vg-tmp              lvm   btrfs       /tmp
/dev/mapper/vg-home             lvm   btrfs       /home

In one of my partitions I accidentally deleted *** a folder (/home/USERNAME/mail/somefolderfullofimportantmessages) full of emails (text files, since I'm using the maildir-format).
While I was able to find some tools to recover lost files, they all have limitations like only working for extX-filesystems (like extundelete) or work only on images or whole partitions (like foremost) or work only on specific file types (like testdisk and photorec).
In my case, the most fitting tool was to apply the btrfs restore-command **** after fighting for quite a long time with the way it uses regex(or use the btrfs-undelete-tool from here), but with this I was only able to "re-discover" some non-deleted files in the folder path but not the deleted ones.
Why is that the case?  Might this be due to the LUKS-encryption?  If yes: what else should/could I have done?

* disclaimer: I had a backup and was able to restore everything from there, but let us just for the sake of the argument that this backup wouldn't exist.  And yes, I know, if you don't have backups, it's your own fault.
** yes, I know, I could have used btrfs subvolumes, but the automated installer I used to install the system didn't supply that option.  But on my next install I'm planning to get rid of the LVM.
*** technically speaking, I used isync/mbsync to sync my remote IMAP folder (which is out of my administrative control) with my local one.
But for some reason (I didn't understand) the tool thought that my local folder was empty and therefore sent a "delete everything"-comand to the remote folder.
And the next time I performed a sync the tool deleted my local folder since it assumed that my remote IMAP-folder is more up-to-date.
**** it was tricky to do that without an external boot drive.  I switched to a tty, killed all processes accessing /home (using lsof /home) and then unmounted /home (after masking some systemd-services which kept accessing /home and didn't want to stop), so that I was able to perform the btrfs restore -Dv /dev/mapper/vg-home --path-regex '^/(|home(|/USERNAME(|/mail/(|/.*))))$' /tmp command (-D is --dry-run, remove that only if you are sure that you don't accidentally blow up your system).


text:
Q: JCache (JSR-107) vs Singleton EJB I've been using Singleton-EJBs in this fashion (as shown by Adam Bien in his blog):
@Singleton
public class MyCache {

    ConcurrentHashMap<String, Object> myMap= new ConcurrentHashMap<String, Object<>();

    //...Crud methods to the map
}

Now with JCache being a candidate for java-ee-8 i read the following in the JCache spec:

A Cache is a Map-like data-structure that permits the temporary
  storage of Key-based Values. A  Cache is owned by a single
  CacheManager.

Assuming JCache makes it into the next java-ee spec, should something else be prefered over above?
What additional features will JCache API enable?

A: JCache will be very interesting now that it has been submitted as final in Java EE 8, and is getting more widespread vendor support.
In particular, one of the things enabled that is intriguing is the support for Entry Processor which is a way of talking to distributed data that maximizes in-memory performance with a minimum of locking and concurrency issues by using distributed processing across your cluster.
JCache looks like a fundamentally new way of looking at plain old caching, which migrates the whole conversation towards fully distributed caches that leverage both RAM and CPU across the cluster. This takes care of distributed computing in a more cloud-friendly (read: elastically scalable) way than local caching and in a way that leverages distributed processing in addition to distributed RAM.

A:
Now with JCache being a candidate for java-ee-8

There's indeed a very high chance that JCache will be in Java EE 8, but don't forget you can already use the reference implementation in Java EE 7 and even Java EE 6.

What additional features will JCache API enable?

A particularly nice and modern feature of JCache are the caching annotations for CDI beans. Besides being plain handy, they may also be able to help for those situations where JSF consults getter and other methods a tad too often.
I've collected a number of JCache related articles here. Especially the 2011 in-depth explanation by spec lead Greg Luck is a great read.


text:
Q: sizeof(array) shows wrong number c++ I have a class with
class IntFile
{
public:
    int value;
    int *array;
}

And there is my main
int main()
{
    IntFile myfile;

    myfile.array = new int[CAPACITY];
    int number;
    cout << "Enter number of elements: " << endl;
    cin >> number;

    cout << "Enter your numbers: ";
    for ( int i = 0; i < number; i++)
    {
        cin >> myfile.value;
        myfile.array[i] = myfile.value;
    }
    cout << endl;

    int n = sizeof(myfile.array);

    cout << " THE SIZE OF ARRAY IS " << n << endl;

    delete[]myfile.array;

    cout << endl;
    return 0;
}

Shouldn't the sizeof(array) = 4*number of elements in array?
Because for me, I'm always getting sizeof(myfile.array) = 4
CAPACITY is global and = 1000;


text:
Q: How do we update data in multiple places via the Firebase console? I'm creating an Angular app with a Firebase backend. I've read about best practises with NoSQL databases and therefore know that data duplication is actually a GOOD thing. I've also read that they provide an "easy" way to update data that is in multiple places. However, this is via an API and not via the console.
Currently, I'm in the early stages and creating my data manually in the Firebase console. I didn't envisage creating a sort of admin area in the my app for me to update data. However, I'm now wondering about how I would update records which contain data that is stored in multiple places.
What is the recommended way to achieve this? Are we expected to be updating our data through our apps? The thing I like about the Firebase console is that I have GUI access to my data.

A: Multi location updates (and transactions) can't be done from the console.  You'll have to write some code with the Firebase Admin SDK and manually run it in order to make that happen.

A: Could not be accomplished through console. However to update a specific data point under a certain node through console, let's say key-value pair is "name":"John Doe" for node n1 and name under node n1 needs to be updated to "Mary Jane". It can be accomplished by adding the same key "name" under node n1 and corresponding value as "Mary Jane", then click Add button next to it. This will overwrite the previously added name "John Doe" i.e. name will be updated to "Mary Jane"


text:
Q: Using ReactiveUI InvokeCommand Extension with Changing Targets While the below code works, I'm not sure it is the best practice.  I'm wondering if I am over-thinking the situation.
Situation: The below code is in my main ViewModel constructor.  The ViewModel has a property MessageHandler that has a ReactiveCommand property on it called ReceiveMessage.  The ViewModel has another property ScannerViewModel with a RawMessage Property on it.  I would like to use the ReactiveUI .InvokeCommand() extension method to pipe RawMessage to ReceiveMessage.  I want this due to the convenience of it checking the .CanExecute for me.  This should happen even though MessageHandler (or even ReceiveMessage potentially) could change, as well as ScannerViewModel.
 this.WhenAnyValue(t => t.MessageHandler.ReceiveMessage)
     .Select(cmd =>
             this.WhenAnyValue(t => t.ScannerViewModel.RawMessage)
                 .InvokeCommand(cmd))
     .Scan(Disposable.Empty,
             (acc, n) =>
                        {
                            acc.Dispose();
                            return n;
                        })
     .Subscribe();

So the above seems to work.  I'm not too sure about whether or not I need to dispose the previous InvokeCommand disposables as I go along, so maybe the .Scan section is unneeded, or perhaps could be done better.
I tried the overload of the InvokeCommand extension that lets you assign a target but it seemed to be static, or I could not figure out the syntax to make it take an Observable as a target:
 this.WhenAnyValue(t => t.ScannerViewModel.RawMessage)
     .InvokeCommand(MessageHandler, m => m.ReceiveMessage);

That would follow the RawMessage as its parent changed, but breaks if MessageHandler changed.  And this does not compile:
 this.WhenAnyValue(t => t.ScannerViewModel.RawMessage)
     .InvokeCommand(this.WhenAnyValue(t => t.MessageHandler), m => m.ReceiveMessage);

I'm not against keeping what I've got, unless someone finds a flaw with it.  I am looking for something that is maybe a little less verbose and easier to follow.

A: Don't ask me why I didn't think to just do this:
 this.WhenAnyValue(t => t.ScannerViewModel.RawMessage)
     .InvokeCommand(this, t => t.MessageHandler.ReceiveMessage);

I was looking at it upside down.  I think this will achieve what I want.
Time and again I keep finding this framework has already found solutions to problems I find -- it is just a matter of grokking it for myself.


text:
Q: INFO: Additional JARs have been added : 'xalan-2.7.0.jar' After a successful start of Tomcat and a few REST calls I get this message in Tomcat console and then the application reload it self. And because reload takes a few seconds, response time is too long. And then again - after a REST call I again get this message and it reloads the application again...
Google did not help me, can you? :)
My (long) pom.xml:
        <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>core</groupId>
    <artifactId>core</artifactId>
    <packaging>war</packaging>
    <version>0.1</version>
    <name>Core</name>

    <repositories>
        <repository>
            <id>terracotta-repository</id>
            <name>Terracotta</name>
            <url>http://www.terracotta.org/download/reflector/maven2</url>
        </repository>
    </repositories>

    <profiles>
        <profile>
            <!-- this profile is for deploying to jboss as -->
            <id>jboss</id>
            <dependencies>
                <dependency>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                    <version>2.0.2</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>2.5.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>2.5.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>2.5.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>2.5.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>2.5.6.SEC01</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>2.5.6</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-mail</artifactId>
            <version>1.0.3.RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>2.0.2</version>
            <scope>compile</scope>
        </dependency>

        <!-- Struts -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.1.8.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-convention-plugin</artifactId>
            <version>2.1.8.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-rest-plugin</artifactId>
            <version>2.1.8.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-spring-plugin</artifactId>
            <version>2.1.8.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.6.6</version>
        </dependency>

        <!-- Terracotta -->
        <dependency>
            <groupId>org.terracotta.modules</groupId>
            <artifactId>tim-distributed-cache</artifactId>
            <version>1.2.0</version>
            <scope>compile</scope>
        </dependency>

        <!-- JiBX -->
        <dependency>
            <groupId>org.jibx</groupId>
            <artifactId>jibx-run</artifactId>
            <version>1.2.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jibx</groupId>
            <artifactId>jibx-extras</artifactId>
            <version>1.2</version>
            <scope>compile</scope>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>

        <!-- Axis -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.5.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-http</artifactId>
            <version>1.5.1</version>
            <exclusions>
                <!-- provided by tomcat -->
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xercesImpl</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xmlParserAPIs</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-local</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>httpcomponents-httpcore</groupId>
            <artifactId>jakarta-httpcore</artifactId>
            <version>4.0-alpha2</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
            <version>1.6.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.4.0</version>
            <scope>compile</scope>
        </dependency>

        <!-- Commons -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-attributes</groupId>
            <artifactId>commons-attributes-api</artifactId>
            <version>2.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.4</version>
            <scope>compile</scope>
        </dependency>

        <!-- Quartz -->
        <dependency>
            <groupId>quartz</groupId>
            <artifactId>quartz</artifactId>
            <version>1.5.2</version>
            <scope>compile</scope>
        </dependency>

        <!-- Postgresql -->
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>8.4-701.jdbc3</version>
            <scope>compile</scope>
        </dependency>

        <!-- Hibernate & JPA -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.3.2.GA</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.4.0.GA</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.4.0.GA</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>3.1.0.GA</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-ehcache</artifactId>
            <version>3.3.2.GA</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.8</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.12</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.1</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>core</finalName>
        <plugins>
            <!--
                        <plugin>
                            <artifactId>maven-assembly-plugin</artifactId>
                            <configuration>
                                <descriptorRefs>
                                    <descriptorRef>jar-with-dependencies</descriptorRef>
                                </descriptorRefs>
                                <archive>
                                    <manifest>
                                        <mainClass></mainClass>
                                    </manifest>
                                </archive>
                            </configuration>
                            <executions>
                                <execution>
                                    <id>make-assembly</id>
                                    <phase>package</phase>
                                    <goals>
                                        <goal>attached</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
            -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-idea-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                    <dependenciesAsLibraries>true</dependenciesAsLibraries>
                    <useFullNames>false</useFullNames>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jibx</groupId>
                <artifactId>maven-jibx-plugin</artifactId>
                <version>1.2.1.1</version>
                <configuration>
                    <directory>src/main/resources/config/rest/mappings</directory>
                    <includes>
                        <include>*.xml</include>
                    </includes>
                    <!--<verbose>true</verbose>-->
                </configuration>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>bind</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>

            <!--  -->
            <plugin>
                <groupId>org.apache.axis2</groupId>
                <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
                <version>1.5.1</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <configuration>
                            <tasks>
                                <property name="compile_classpath" refid="maven.compile.classpath"/>
                                <property name="runtime_classpath" refid="maven.runtime.classpath"/>
                                <property name="test_classpath" refid="maven.test.classpath"/>
                                <property name="plugin_classpath" refid="maven.plugin.classpath"/>

                                <fileset id="dataClasses" dir="${basedir}/src/main/java" includes="**/*.java">
                                    <or>
                                        <contains text="@Entity"/>
                                        <contains text="@javax.persistence.Entity"/>
                                    </or>
                                </fileset>

                                <copy file="${basedir}/src/main/resources/hibernate/hibernate.cfg.tmpl.xml"
                                      tofile="${basedir}/src/main/resources/hibernate/hibernate.cfg.xml"
                                      overwrite="true"/>

                                <pathconvert targetos="unix" pathsep=""/>
        <mapping class=""
                                             property="mappedClasses"
                                             refid="dataClasses">
                                    <chainedmapper>
                                        <globmapper
                                                from="${basedir}${file.separator}src${file.separator}main${file.separator}java${file.separator}"
                                                to=""/>
                                        <packagemapper from="*.java" to=""/>
                                    </chainedmapper>
                                </pathconvert>

                                <echo message="mapped classes:  ${mappedClasses}"/>

                                <replace file="${basedir}/src/main/resources/hibernate/hibernate.cfg.xml"
                                         token="INSERT HBM FILES HERE"
                                         value="${mappedClasses}"/>

                                <copy file="${basedir}/src/main/resources/hibernate/hibernate.cfg.xml"
                                      tofile="${basedir}/target/classes/hibernate.cfg.xml" overwrite="true"/>

                                <java
                                        jvm="${java.home}"
                                        classpath="${compile_classpath}"
                                        classname="net.core.jpa.hibernate.HibernateUtils">
                                    <arg value="${basedir}/src/main/resources/hibernate/hibernate.sql"/>
                                </java>

                                <copy file="${basedir}/src/main/resources/hibernate/hibernate.sql"
                                      tofile="${basedir}/src/main/resources/hibernate/hibernate.sql.ori"
                                      overwrite="true"/>

                                <java
                                        jvm="${java.home}"
                                        classpath="${runtime_classpath}"
                                        classname="net.core.jpa.hibernate.SqlFixer">
                                    <arg value="${basedir}/src/main/resources/hibernate/hibernate.sql"/>
                                </java>

                                <!--
                                <taskdef name="instrument"
                                         classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
                                    <classpath>
                                        <path refid="maven.runtime.classpath"/>
                                        <path refid="maven.plugin.classpath"/>
                                    </classpath>
                                </taskdef>
                                <instrument verbose="false">
                                    <fileset dir="${project.build.outputDirectory}">
                                        <include name="**/data/**/*.class"/>
                                    </fileset>
                                </instrument>
                                -->

                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1-beta-1</version>
            </plugin>
        </plugins>
    </build>
</project>

Tomcat log:
    1.3.2010 13:29:16 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:core' did not find a matching property.
1.3.2010 13:29:16 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\Program Files\PC Connectivity Solution\;C:\Program Files\Nokia\Carbide.c++ v1.3\x86Build\Symbian_Tools\Command_Line_Tools;C:\Program Files\Common Files\Symbian\Tools;C:\Program Files\CSL Arm Toolchain\bin;C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files\ActivIdentity\ActivClient\;c:\Program Files\Hewlett-Packard\IAM\bin;c:\Python26;c:\Program Files\TortoiseSVN\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\TortoiseGit\bin;C:\Sun\SDK\bin;;
1.3.2010 13:29:16 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
1.3.2010 13:29:16 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 390 ms
1.3.2010 13:29:16 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
1.3.2010 13:29:16 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
1.3.2010 13:29:17 org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'core.root' = [C:\Work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\core\]
1.3.2010 13:29:17 org.apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [file:C:\Work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0/conf/livecliq-log4j.properties]
1.3.2010 13:29:17 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
1.3.2010 13:29:27 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
1.3.2010 13:29:27 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
1.3.2010 13:29:27 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16  config=null
1.3.2010 13:29:27 org.apache.catalina.startup.Catalina start
INFO: Server startup in 10983 ms
1.3.2010 13:29:37 org.apache.catalina.loader.WebappClassLoader modified
INFO:     Additional JARs have been added : 'xalan-2.7.0.jar'
1.3.2010 13:29:37 org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
1.3.2010 13:29:38 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
1.3.2010 13:29:38 org.apache.catalina.core.ApplicationContext log
INFO: Shutting down log4j
1.3.2010 13:29:38 org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'core.root' = [C:\Work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\core\]
1.3.2010 13:29:38 org.apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [file:C:\Work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0/conf/livecliq-log4j.properties]
1.3.2010 13:29:39 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
1.3.2010 13:29:59 org.apache.catalina.loader.WebappClassLoader modified
INFO:     Additional JARs have been added : 'xalan-2.7.0.jar'
1.3.2010 13:29:59 org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
1.3.2010 13:29:59 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
1.3.2010 13:29:59 org.apache.catalina.core.ApplicationContext log
INFO: Shutting down log4j
1.3.2010 13:30:00 org.apache.catalina.core.ApplicationContext log
INFO: Set web app root system property: 'core.root' = [C:\Work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\core\]
1.3.2010 13:30:00 org.apache.catalina.core.ApplicationContext log
INFO: Initializing log4j from [file:C:\Work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0/conf/log4j.properties]
1.3.2010 13:30:00 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext

A: More an hint than an answer but similar Eclipse/Tomcat/Spring problems (with other JARs) are reported in Application Context Keeps Reloading and Tomcat behaving Strangely. Check if your xalan JAR is not corrupted (try to open it with winzip) and redownload it if required. If not, maybe try to deploy on JBoss to see if this issue is related to the Tomcat plugin.


text:
Q: Sort GraphQL query randomly I am looking for a solution to randomly sort a GraphQL query. I have looked through the documentation and it appears that their is no options.
Does anyone know of one or a workaround to randomising the following query?
query {
  allContentfulAttraction(
    limit: 4
    filter: { location: { eq: "AttractionLocation1" } }
  ) {
    edges {
      node {
        id
      }
    }
  }
}

A: GraphQL simply provides a framework for resolving and validating field values based on a schema. It does not come with any preset means of filtering or sorting the queried data. It's up to the server whether to expose ways for the client to do that, and how to implement that functionality.
With regards to Gatsby specifically, looking at their API supports querying random nodes. At best, you could query for all nodes, and then select a random set of elements from the returned data by using lodash's sampleSize or Chance's pickset.

A: https://www.howtographql.com/graphql-js/8-filtering-pagination-and-sorting/ says sorting is handled by whichever framework you're using, such as Prisma orderBy or Lighthouse @orderBy.


text:
Q: How to retrieve value of text field inside while loop with JavaScript? Inside the while loop there are text boxes. There is JavaScript function called checkNum() which is use to retrieve the text box value but i don't get it how to do that?

    Text One

  <?php
  $i =0;
  $data = "select * from tbl_person";
  $query = mysqli_query($conn,$data);
  while($row = mysqli_fetch_array($query))
  {
   $i++;
  ?>

    <input type="text" name="num<?php echo $i;?>" id="num<?php echo $i;?>" onkeypress="return isNumberKey(event)"/>

  <?php
  }
  ?>

A:     function loopTexts(numRows)
    {
      for(var i = 1; i <= numRows; i++)
      {
        var txt = document.getElementById('txt'+i);
        var str = txt.value;
        alert(str);
      }
    }

<?php
//Some query here
    $numRows = mysqli_num_rows($resultSet);
//Loop through the result set and create the fields as you did
?>

    <input type="text" value="text1" id="txt1"/>
    <input type="text" value="text2" id="txt2"/>
    <input type="text" value="text3" id="txt3"/>
    <input type="text" value="text4" id="txt4"/>
    <input type="text" value="text5" id="txt5"/>
//echo the parameter $numRows to pass it to the JS function
    <input type="button" value="Loop!" onclick=<?php echo "loopTexts($numRows);"; ?>/>

If you don't know how many text boxes will be created during runtime, pass it as an argument to the javascript function and use it in the for loop.
Call the function in whatever event you are supposed to use it.

A: Have the function accept the input as a parameter:
function checkNum(input)
{
    var num = input.value;

}

Then add the onblur attribute to the field, and pass this as a parameter:
<input type="text" onblur="checkNum(this)" name="num<?php echo $i;?>" id="num<?php echo $i;?>" onkeypress="return isNumberKey(event)"/>


text:
Q: Connect local IP camera to cloud VPS via Openvpn tunnel using DNAT and SNAT I'm running two IP cameras on my local network with RTSP turned on. I have zoneminder (camera recorder) hosted on my local network and camera streaming directly to it using RTSP. However, I need to deploy zoneminder in my cloud vps and stream RTSP feed directly to it so I can view my cameras anywhere. ( I know I can still view my local zoneminder using openvpn but I prefer not to)
I setup openvpn server and zoneminder on my cloud vps. And I configured the client on Raspberry pi (with route no-exec) which sitting in the same network as my IP cameras.
Then I enable IP forwarding on my raspberry pi and added below two rules for DNAT and SNAT
iptables -t nat -I PREROUTING -p udp -i tun0 --dport 3354 -j DNAT --to-destination 192.168.5.10:8554

iptables -t nat -I POSTROUTING -p udp -s 192.168.5.10 --sport 8554 -j SNAT --to-source 192.168.100.50:3354

Network details as follows
Local network - 192.168.5.0/24
VPN network - 192.168.100.0/24
Raspberry pi local IP - 192.168.5.9
IP camera IP - 192.168.5.10
Raspberry pi VPN IP - 192.168.100.50
VPN sever IP - 192.168.100.1
RTSP port - 8554

But when I try to add a camera to zoenminder on my cloud VPS it always fails with error unable to reach the camera. I use below RTSP link to add camera
rtsp://192.168.100.50:3354/unicast

error form zoneminder
Unable to open input rtsp://192.168.100.50:3354/unicast

when I do a port scan using Nmap I get something like this
3354/udp open|filtered suitjd

where did I configure wrong?. basically I need direct communication to my local network items via vpn tunnel. How can I achieve this with any other methods


text:
Q: Limit Sprite kit Frame-rate I am new to programming and am creating a sprite kit game. I am making a scrolling background with a large image and this is lowering the frame rate to 30fps. However at the start of the game, before any other sprites are brought in, the frame rate varies between 30fps and 60fps. Because I am moving my background in the update method the speed the background scrolls at is constantly changing. I would like to limit the max frame rate to 30fps to achieve a constant speed.
I have also heard about using Delta time to achieve a constant speed but have been unable to find tutorials about this online.
Thanks in advance.

A: frameInterval deprecated now.
Set preferredFramesPerSecond property of your SKView object to 30.
For Example (swift 3.2) :
// ViewController.swift

    import Cocoa
    import SpriteKit
    import GameplayKit

    class ViewController: NSViewController {

        @IBOutlet var skView: SKView!

        override func viewDidLoad() {
            super.viewDidLoad()

            if let view = self.skView {

                skView.preferredFramesPerSecond = 30//this will set framerate to 30

                // Load the SKScene from 'GameScene.sks'
                if let scene = SKScene(fileNamed: "GameScene") {
                    // Set the scale mode to scale to fit the window
                    scene.scaleMode = .aspectFill

                    // Present the scene
                    view.presentScene(scene)
                }

                view.ignoresSiblingOrder = true

                view.showsFPS = true
                view.showsNodeCount = true
            }
        }
    }

A: You can achieve this by setting frameInterval on you SKView to 2.
It will effectively lower your maximum frame rate from 60 to 30.


text:
Q: Will all android devices display the same length app name? I wonder if all Android devices display the same length app name. I made an app and can see it's full 27 characters name on my Galaxy S4. How will the same name look on older phones/versions of Android? Will they display less characters of the app name than my S4? If so, how many will they display and is there an amount of characters all phones will display?

A: I don't think the name of the app length has changed with different releases of Android. But different sized devices might struggle more depending on how you're displaying your text. There are a couple threads on this subject.
Here's one: how much long can be a android application name
EDIT: You could test with an emulator on a very old device.


text:
Q: Export project from Unity to Visual Studio Can I export a project done in Unity to Microsoft Visual Studio?
I tried selecting my project from menu Preferences->External Script Editor->Microsoft Visual Studio, but when I run the application, I get this error:
A project with an Output type of Class Library cannot be started directly

Have I done something wrong? If so, what?

A: Microsoft have now acquired UnityVS company SyntaxTree, and are offering the UnityVS plugin for free for Visual Studio 2010-2013 Professional or higher. This should allow you to run Unity projects from within Visual Studio.
You can download it here, or get it from the Visual Studio Extensions Gallery.