Q: Build asset folder empty : android Studio, using Gradle I have created a simple app in android studio, where I have placed a font under
src/main/assets/fonts/fontName.ttf
When running a build/clean etc. the asset folder in the build stays empty. (build/exploded-aar/com.android.support/appcompat-v7/19.1.0/assets)
The application runs, no instances of the file are found on the device.


Q: Amazon MWS (PHP) - How does the request work I am trying to pull a report in PHP for active listings.
I've made progress, however, I cannot understand how this works and there is nothing out there that can explain it.
For example, in the Samples provided from the PHP library, I see quite a few XML files.  When you run the RequestReportResponse sample, does that generate the XML file, or does the XML file tell the RequestReportResponse what to do based on values and functions?
I am asking because, with the MWS Scratchpad - I select all the necessary fields, submit it then refresh the Amazon Reports page of my seller central section and it shows a pending report.
I'm just asking how the XML content affects the report or how the report can affect the XML.

A: The answer to your question comes in two parts.
Part 1 - Calling the Amazon API
Most MWS requests do not require any file (be it plain text or XML) to be sent to Amazon. For example, all parameters needed to do send RequestReport can (and must) be sent as regular parameters. I'm not sure what Amazon would do if you did submit a file along with it as I've never tried. But then again... why would you?
One of the calls that does require a file to be send is the SubmitFeed call where that file is the actual feed to be submitted. It depends on the type of feed you're submitting if Amazon expects it to be plain text or XML.
Part 2 - Handling Amazon's API responses
When you get information back from Amazon's API, it usually is in XML format (there are a few calls that may return plaintext instead). You will need to decode this data to get your information out.
To make it a bit clearer, I'll outline a typical process for you:
The process of getting all your listings from Amazon:

*

*Do a RequestReport call to Amazon. No XML attached

*Decode the XML that you're getting back (it is a RequestReportResponse). If all went well, you'll get a RequestReportId as part of the response, and Amazon will start processing your request.
Amazon may need a few minutes to actually create the report, in cases of very complex or large requests or during high activity hours it may actually take up to an hour or more. So we need to find out when the request we made is actually done.

*Poke Amazon API with a GetReportRequestList call asking for the status of your request with ReportRequestIdList.Id.1={YourRequestIdHere}. This also does not need a XML attachment.

*Decode the XML that you're getting back. (it is a GetReportRequestListResponse)
If its ReportProcessingStatus is not _DONE_, wait for at least 45 seconds, then repeat from step 3. If the report is actually done, you'll see a valid GeneratedReportId in the response. If it is missing, you'll need to do an extra GetReportList call to find its ID.

*Call GetReport to finally fetch your report with ReportId={YourGeneratedReportIdHere}

*Decode whatever you're getting back. Depending on the type of report you requested, the response may be XML or plain text.
This process is explained in detail (and with a pretty flow chart) in Amazon Marketplace Web Service Reports API Section Reference (Version 2009-01-01)
To finally answer your question with respect to getting active listings from Amazon MWS:
None of the three calls require you to send XML to Amazon. The data you receive from Amazon will be in XML format (with the possible exception step 6 if you requested a plain text report).


Q: clickhouse 1 node out of 3 not syncing I have a 3-node clickhouse cluster, almost identical to the setup in https://github.com/tetafro/clickhouse-cluster.
I ran the CREATE TABLE statement on the 3 nodes, as follows:

CREATE TABLE replica_test.hits_shard
(
 `WatchID` UInt64,
 `JavaEnable` UInt8,
 `Title` String,
 `GoodEvent` Int16,
 `EventTime` DateTime,
 `EventDate` Date,
 `CounterID` UInt32,
 `ClientIP` UInt32,
 `ClientIP6` FixedString(16),
 `RegionID` UInt32,
 `UserID` UInt64,
 `CounterClass` Int8,
 `OS` UInt8,
 `UserAgent` UInt8,
 `URL` String,
 `Referer` String,
 `URLDomain` String,
 `RefererDomain` String,
 `Refresh` UInt8,
 `IsRobot` UInt8,
 `RefererCategories` Array(UInt16),
 `URLCategories` Array(UInt16),
 `URLRegions` Array(UInt32),
 `RefererRegions` Array(UInt32),
 `ResolutionWidth` UInt16,
 `ResolutionHeight` UInt16,
 `ResolutionDepth` UInt8,
 `FlashMajor` UInt8,
 `FlashMinor` UInt8,
 `FlashMinor2` String,
 `NetMajor` UInt8,
 `NetMinor` UInt8,
 `UserAgentMajor` UInt16,
 `UserAgentMinor` FixedString(2),
 `CookieEnable` UInt8,
 `JavascriptEnable` UInt8,
 `IsMobile` UInt8,
 `MobilePhone` UInt8,
 `MobilePhoneModel` String,
 `Params` String,
 `IPNetworkID` UInt32,
 `TraficSourceID` Int8,
 `SearchEngineID` UInt16,
 `SearchPhrase` String,
 `AdvEngineID` UInt8,
 `IsArtifical` UInt8,
 `WindowClientWidth` UInt16,
 `WindowClientHeight` UInt16,
 `ClientTimeZone` Int16,
 `ClientEventTime` DateTime,
 `SilverlightVersion1` UInt8,
 `SilverlightVersion2` UInt8,
 `SilverlightVersion3` UInt32,
 `SilverlightVersion4` UInt16,
 `PageCharset` String,
 `CodeVersion` UInt32,
 `IsLink` UInt8,
 `IsDownload` UInt8,
 `IsNotBounce` UInt8,
 `FUniqID` UInt64,
 `HID` UInt32,
 `IsOldCounter` UInt8,
 `IsEvent` UInt8,
 `IsParameter` UInt8,
 `DontCountHits` UInt8,
 `WithHash` UInt8,
 `HitColor` FixedString(1),
 `UTCEventTime` DateTime,
 `Age` UInt8,
 `Sex` UInt8,
 `Income` UInt8,
 `Interests` UInt16,
 `Robotness` UInt8,
 `GeneralInterests` Array(UInt16),
 `RemoteIP` UInt32,
 `RemoteIP6` FixedString(16),
 `WindowName` Int32,
 `OpenerName` Int32,
 `HistoryLength` Int16,
 `BrowserLanguage` FixedString(2),
 `BrowserCountry` FixedString(2),
 `SocialNetwork` String,
 `SocialAction` String,
 `HTTPError` UInt16,
 `SendTiming` Int32,
 `DNSTiming` Int32,
 `ConnectTiming` Int32,
 `ResponseStartTiming` Int32,
 `ResponseEndTiming` Int32,
 `FetchTiming` Int32,
 `RedirectTiming` Int32,
 `DOMInteractiveTiming` Int32,
 `DOMContentLoadedTiming` Int32,
 `DOMCompleteTiming` Int32,
 `LoadEventStartTiming` Int32,
 `LoadEventEndTiming` Int32,
 `NSToDOMContentLoadedTiming` Int32,
 `FirstPaintTiming` Int32,
 `RedirectCount` Int8,
 `SocialSourceNetworkID` UInt8,
 `SocialSourcePage` String,
 `ParamPrice` Int64,
 `ParamOrderID` String,
 `ParamCurrency` FixedString(3),
 `ParamCurrencyID` UInt16,
 `GoalsReached` Array(UInt32),
 `OpenstatServiceName` String,
 `OpenstatCampaignID` String,
 `OpenstatAdID` String,
 `OpenstatSourceID` String,
 `UTMSource` String,
 `UTMMedium` String,
 `UTMCampaign` String,
 `UTMContent` String,
 `UTMTerm` String,
 `FromTag` String,
 `HasGCLID` UInt8,
 `RefererHash` UInt64,
 `URLHash` UInt64,
 `CLID` UInt32,
 `YCLID` UInt64,
 `ShareService` String,
 `ShareURL` String,
 `ShareTitle` String,
 `ParsedParams` Nested(
 Key1 String,
 Key2 String,
 Key3 String,
 Key4 String,
 Key5 String,
 ValueDouble Float64),
 `IslandID` FixedString(16),
 `RequestNum` UInt32,
 `RequestTry` UInt8
)
ENGINE=ReplicatedMergeTree('/clickhouse/tables/{shard}/tables/hits', '{replica}')
PARTITION BY toYYYYMM(EventDate)
ORDER BY (CounterID, EventDate, intHash32(UserID))
SAMPLE BY intHash32(UserID);

CREATE TABLE replica_test.hits_distributed
(
 `WatchID` UInt64,
 `JavaEnable` UInt8,
 `Title` String,
 `GoodEvent` Int16,
 `EventTime` DateTime,
 `EventDate` Date,
 `CounterID` UInt32,
 `ClientIP` UInt32,
 `ClientIP6` FixedString(16),
 `RegionID` UInt32,
 `UserID` UInt64,
 `CounterClass` Int8,
 `OS` UInt8,
 `UserAgent` UInt8,
 `URL` String,
 `Referer` String,
 `URLDomain` String,
 `RefererDomain` String,
 `Refresh` UInt8,
 `IsRobot` UInt8,
 `RefererCategories` Array(UInt16),
 `URLCategories` Array(UInt16),
 `URLRegions` Array(UInt32),
 `RefererRegions` Array(UInt32),
 `ResolutionWidth` UInt16,
 `ResolutionHeight` UInt16,
 `ResolutionDepth` UInt8,
 `FlashMajor` UInt8,
 `FlashMinor` UInt8,
 `FlashMinor2` String,
 `NetMajor` UInt8,
 `NetMinor` UInt8,
 `UserAgentMajor` UInt16,
 `UserAgentMinor` FixedString(2),
 `CookieEnable` UInt8,
 `JavascriptEnable` UInt8,
 `IsMobile` UInt8,
 `MobilePhone` UInt8,
 `MobilePhoneModel` String,
 `Params` String,
 `IPNetworkID` UInt32,
 `TraficSourceID` Int8,
 `SearchEngineID` UInt16,
 `SearchPhrase` String,
 `AdvEngineID` UInt8,
 `IsArtifical` UInt8,
 `WindowClientWidth` UInt16,
 `WindowClientHeight` UInt16,
 `ClientTimeZone` Int16,
 `ClientEventTime` DateTime,
 `SilverlightVersion1` UInt8,
 `SilverlightVersion2` UInt8,
 `SilverlightVersion3` UInt32,
 `SilverlightVersion4` UInt16,
 `PageCharset` String,
 `CodeVersion` UInt32,
 `IsLink` UInt8,
 `IsDownload` UInt8,
 `IsNotBounce` UInt8,
 `FUniqID` UInt64,
 `HID` UInt32,
 `IsOldCounter` UInt8,
 `IsEvent` UInt8,
 `IsParameter` UInt8,
 `DontCountHits` UInt8,
 `WithHash` UInt8,
 `HitColor` FixedString(1),
 `UTCEventTime` DateTime,
 `Age` UInt8,
 `Sex` UInt8,
 `Income` UInt8,
 `Interests` UInt16,
 `Robotness` UInt8,
 `GeneralInterests` Array(UInt16),
 `RemoteIP` UInt32,
 `RemoteIP6` FixedString(16),
 `WindowName` Int32,
 `OpenerName` Int32,
 `HistoryLength` Int16,
 `BrowserLanguage` FixedString(2),
 `BrowserCountry` FixedString(2),
 `SocialNetwork` String,
 `SocialAction` String,
 `HTTPError` UInt16,
 `SendTiming` Int32,
 `DNSTiming` Int32,
 `ConnectTiming` Int32,
 `ResponseStartTiming` Int32,
 `ResponseEndTiming` Int32,
 `FetchTiming` Int32,
 `RedirectTiming` Int32,
 `DOMInteractiveTiming` Int32,
 `DOMContentLoadedTiming` Int32,
 `DOMCompleteTiming` Int32,
 `LoadEventStartTiming` Int32,
 `LoadEventEndTiming` Int32,
 `NSToDOMContentLoadedTiming` Int32,
  `FirstPaintTiming` Int32,
 `RedirectCount` Int8,
 `SocialSourceNetworkID` UInt8,
 `SocialSourcePage` String,
 `ParamPrice` Int64,
 `ParamOrderID` String,
 `ParamCurrency` FixedString(3),
 `ParamCurrencyID` UInt16,
 `GoalsReached` Array(UInt32),
 `OpenstatServiceName` String,
 `OpenstatCampaignID` String,
 `OpenstatAdID` String,
 `OpenstatSourceID` String,
 `UTMSource` String,
 `UTMMedium` String,
 `UTMCampaign` String,
 `UTMContent` String,
 `UTMTerm` String,
 `FromTag` String,
 `HasGCLID` UInt8,
 `RefererHash` UInt64,
 `URLHash` UInt64,
 `CLID` UInt32,
 `YCLID` UInt64,
 `ShareService` String,
 `ShareURL` String,
 `ShareTitle` String,
 `ParsedParams.Key1` Array(String),
 `ParsedParams.Key2` Array(String),
 `ParsedParams.Key3` Array(String),
 `ParsedParams.Key4` Array(String),
 `ParsedParams.Key5` Array(String),
 `ParsedParams.ValueDouble` Array(Float64),
 `IslandID` FixedString(16),
 `RequestNum` UInt32,
 `RequestTry` UInt8
)
ENGINE = Distributed('hivestack', replica_test, 'hits_shard', rand());

I have an out-of-sync issue with node-2 as follows:

*

*if i insert data to node-2, the data is only seen by node-2

*

*insert ... into node2 => hits_shard then select count(*) fom node1 => hits_shard the result is 0

*if i insert data into node-1 or node-3, it's seen by all 3 nodes.

SELECT * from system.replicas:
replica_test,hits_shard,ReplicatedMergeTree,1,1,0,0,0,0,/clickhouse/tables/02/tables/hits,clickhouse02,/clickhouse/tables/02/tables/hits/replicas/clickhouse02,-1,0,0,0,0,1969-12-31 19:00:00,1969-12-31 19:00:00,1969-12-31 19:00:00,1969-12-31 19:00:00,"","","",0,0,1969-12-31 19:00:00,0,1,1,"","",{'clickhouse02':1}

select * from system.replication_queue is empty
clickhouse version: clickhouse/clickhouse-server:22.4.5.9
zookeeper version: bitnami/zookeeper:3.8.0
I verified that all 3 nodes can talk to each others via clickhouse-client and nc  9000
Would appreciate any tips on how to debug/fix this

A: Are you sure you have the same zookeeper clickhouse settings on all 3 nodes?
Do you insert into Distributed table or insert into ReplicatedMergeTree?
For first case, check on node-2
SELECT * FROM system.distribution_queue FORMAT Vertical
SELECT * FROM system.clusters FORMAT Vertical

and compare <remote_servers> section in your config for all 3 nodes


Q: Azure SQL Database DTU percentage Reach 100% on particular function My scenario is I have a button name(publish) at admin side use for publish agreement and after publish it visible to user-side. Recently I saw when I publish agreement
DTU percent reach almost 100% and I tested rest of all functionality DTU not goes upto 5%.
My database size is 250mb I upgraded the DTU to a higher tier(from B1 to B2,S1,S2,S3) but when publish agreement it reach 100%

process took (3 minute maximum) when publish a large agreement
I checked the Query that taking long time also not complicated
(@EntityKeyValue1 bigint)SELECT
[Extent1].[Revision] AS [Revision],
[Extent1].[ClauseVersionId] AS [ClauseVersionId],
[Extent1].[SourceClauseVersionId] AS [SourceClauseVersionId],
[Extent1].[DisplayHeader] AS [DisplayHeader],
[Extent1].[Body] AS [Body],
[Extent1].[EndUserGuidanceNote] AS [EndUserGuidanceNote],
[Extent1].[DocumentParty_DocumentPartyId] AS [DocumentParty_DocumentPartyId],
[Extent1].[PublishedClause_ClauseId] AS [PublishedClause_ClauseId]
FROM [dbo].[PublishedClauseVersion] AS [Extent1]
WHERE ([Extent1].[PublishedClause_ClauseId] IS NOT NULL) AND ([Extent1].[PublishedClause_ClauseId] = @EntityKeyValue1)

I saw many answer and article but I didn't get any proper solution for this issue.

A: Check if the 2 sides of the comparison matches , Meaning the PublishedClause_ClauseId is also BigInt Data type as the parameter you are using "@EntityKeyValue1" , Mismatching them cause query optimizer to either scan or not use indexes, Match them then redeploy


Q: curl_multi_fdset returns always 1 What I want to do: download multiple files at the same time.
Issue: curl_multi_fdset always return 1.
Issue 2: I don't really understand how fd_set work. I am new to C and the doc is quite confusing.
Sources: I used this example and this progress bar.
My full .cpp: Github
So the problem seems to be in the initializing method:
static void initialize(CURLM *cm, int i, char* url[], std::string filepath)
{
CURL *eh = curl_easy_init();

FILE *fp; // added to the example
fp = fopen(filepath.c_str(), "wb"); // added to the example

curl_easy_setopt(eh, CURLOPT_WRITEFUNCTION, callback);
curl_easy_setopt(eh, CURLOPT_WRITEDATA, fp); // added to the example
curl_easy_setopt(eh, CURLOPT_NOPROGRESS, 0); // added to the example
curl_easy_setopt(eh, CURLOPT_HEADER, 0L);
curl_easy_setopt(eh, CURLOPT_URL, url[i]);
curl_easy_setopt(eh, CURLOPT_PRIVATE, url[i]);
curl_easy_setopt(eh, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(eh, CURLOPT_PROGRESSFUNCTION, progress_func); // added to the example

curl_multi_add_handle(cm, eh);
}

However, it also won't work without these additional options. So it has to be something different but I didn't change anything regarding the fd_set. Any help is appreciated.
Call of initialize:
CURLM *cm = nullptr;
CURLMsg *msg;
long L;
unsigned int C = 0;
int M, Q, U = -1;
fd_set R, W, E;
struct timeval T;

curl_global_init(CURL_GLOBAL_ALL);
/* we can optionally limit the total amount of connections this multi handle uses */
curl_multi_setopt(cm, CURLMOPT_MAXCONNECTS, (long) MAX);

if ((argc - 2) < MAX)
{
    for (C = 0; C < argc - 2; ++C)
    {
        path = "test" + std::to_string(C) + ".html";
        initialize(cm, C, urls, path);
    }
}

Call of the function which returns 1:
FD_ZERO(&R);
FD_ZERO(&W);
FD_ZERO(&E);

if (curl_multi_fdset(cm, &R, &W, &E, &M))
{
    fprintf(stderr, "E: curl_multi_fdset\n");
    return EXIT_FAILURE;
}


Q: How do I move both files and folders to the specified directory? There is a code that moves files from one directory to another, but it doesn't move folders.
import os,glob
import shutil

inpath = str5
outpath = str6

os.chdir(inpath)
for file in glob.glob("*.*"):

    shutil.move(inpath+'/'+file,outpath)

How to make it move both files and folders to the specified directory?

A: *.* selects files that have an extension, so it omits sub-folders.
Use * to select files and folders.
Then you should see your desired result.
for file in glob.glob("*"):
    shutil.move(inpath+'/'+file,outpath)

A: You can use os.listdir to get all the files and folders in a directory.
import os
import shutil

def move_file_and_folders(inpath, outpath):
    for filename in os.listdir(inpath):
        shutil.move(os.path.join(inpath, filename), os.path.join(outpath, filename))

In your case,
inpath = <specify the source>
outpath = <specify the destination>
move_file_and_folders(inpath, outpath)


Q: Applescript Finder Selection "Stuck" I've been using the code below for awhile to auto-magically scale images down through the various wallpaper sizes that I want. This morning, it ceased working and is giving some of the most bizarre behavior I've ever seen.
If I reboot my box, the script works as expected the first time it runs. After that, the previous selection seems to be stuck in the Image Events memory. What I mean is the following:
I have this directory structure:
.
|-- 11
|   `-- Math.png
|-- 1610
|-- 169
|   `-- Math.png
|-- 43
|   `-- Math.png
|-- Math.jpg
`-- Math.png

I run the script for the first time after rebooting with ./169/Math.png selected in the Finder and get the following results in Applescript Editor:
tell application "Finder"
        get selection
                --> {document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk}
        get document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:Math.png"
end tell
tell application "Image Events"
        open alias "Paul:Users:tim:Downloads:test:169:Math.png"
                --> image "Math.png"
        get dimensions of image "Math.png"
                --> {2560, 1440}
        scale image "Math.png" to size 1920
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -1708
        «event ascrgdut»
                --> error number -1708
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
        offset of "." in "Math.png"
                --> 5
end tell
tell application "Finder"
        get parent of document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:"
end tell
tell application "Image Events"
        save image "Math.png" in "/Users/tim/Downloads/test/169/Math_1920x1080.png" as PNG
                --> file "Paul:Users:tim:Downloads:test:169:Math_1920x1080.png"
        scale image "Math.png" to size 1366
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
        offset of "." in "Math.png"
                --> 5
end tell
tell application "Finder"
        get parent of document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:"
end tell
tell application "Image Events"
        save image "Math.png" in "/Users/tim/Downloads/test/169/Math_1366x768.png" as PNG
                --> file "Paul:Users:tim:Downloads:test:169:Math_1366x768.png"
end tell
Result:
file "Paul:Users:tim:Downloads:test:169:Math_1366x768.png" of application "Image Events"
tell application "Finder"
        get selection
                --> {document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk}
        get document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:Math.png"
end tell
tell application "Image Events"
        open alias "Paul:Users:tim:Downloads:test:169:Math.png"
                --> image "Math.png"
        get dimensions of image "Math.png"
                --> {2560, 1440}
        scale image "Math.png" to size 1920
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -1708
        «event ascrgdut»
                --> error number -1708
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
        offset of "." in "Math.png"
                --> 5
end tell
tell application "Finder"
        get parent of document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:"
end tell
tell application "Image Events"
        save image "Math.png" in "/Users/tim/Downloads/test/169/Math_1920x1080.png" as PNG
                --> file "Paul:Users:tim:Downloads:test:169:Math_1920x1080.png"
        scale image "Math.png" to size 1366
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
        offset of "." in "Math.png"
                --> 5
end tell
tell application "Finder"
        get parent of document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:"
end tell
tell application "Image Events"
        save image "Math.png" in "/Users/tim/Downloads/test/169/Math_1366x768.png" as PNG
                --> file "Paul:Users:tim:Downloads:test:169:Math_1366x768.png"
end tell
Result:
file "Paul:Users:tim:Downloads:test:169:Math_1366x768.png" of application "Image Events"
tell application "Finder"
        get selection
                --> {document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk}
        get document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:Math.png"
end tell
tell application "Image Events"
        open alias "Paul:Users:tim:Downloads:test:169:Math.png"
                --> image "Math.png"
        get dimensions of image "Math.png"
                --> {2560, 1440}
        scale image "Math.png" to size 1920
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -1708
        «event ascrgdut»
                --> error number -1708
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
        offset of "." in "Math.png"
                --> 5
end tell
tell application "Finder"
        get parent of document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:"
end tell
tell application "Image Events"
        save image "Math.png" in "/Users/tim/Downloads/test/169/Math_1920x1080.png" as PNG
                --> file "Paul:Users:tim:Downloads:test:169:Math_1920x1080.png"
        scale image "Math.png" to size 1366
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
tell application "Finder"
        get selection
                --> {document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk}
        get document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:Math.png"
end tell
tell application "Image Events"
        open alias "Paul:Users:tim:Downloads:test:169:Math.png"
                --> image "Math.png"
        get dimensions of image "Math.png"
                --> {2560, 1440}
        scale image "Math.png" to size 1920
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -1708
        «event ascrgdut»
                --> error number -1708
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
        offset of "." in "Math.png"
                --> 5
end tell
tell application "Finder"
        get parent of document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:"
end tell
tell application "Image Events"
        save image "Math.png" in "/Users/tim/Downloads/test/169/Math_1920x1080.png" as PNG
                --> file "Paul:Users:tim:Downloads:test:169:Math_1920x1080.png"
        scale image "Math.png" to size 1366
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
        offset of "." in "Math.png"
                --> 5
end tell
tell application "Finder"
        get parent of document file "Math.png" of folder "169" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:169:"
end tell
tell application "Image Events"
        save image "Math.png" in "/Users/tim/Downloads/test/169/Math_1366x768.png" as PNG
                --> file "Paul:Users:tim:Downloads:test:169:Math_1366x768.png"
end tell
Result:
file "Paul:Users:tim:Downloads:test:169:Math_1366x768.png" of application "Image Events"

I run the script again with ./Math.png selected in Finder:
tell application "Finder"
        get selection
                --> {document file "Math.png" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk}
        get document file "Math.png" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:Math.png"
end tell
tell application "Image Events"
        open alias "Paul:Users:tim:Downloads:test:Math.png"
                --> image "Math.png"
        get dimensions of image "Math.png"
                --> {2560, 1440}
        scale image "Math.png" to size 1920
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
        offset of "." in "Math.png"
                --> 5
end tell
tell application "Finder"
        get parent of document file "Math.png" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:"
end tell
tell application "Image Events"
        save image "Math.png" in "/Users/tim/Downloads/test/Math_1920x1080.png" as PNG
                --> file "Paul:Users:tim:Downloads:test:Math_1920x1080.png"
        scale image "Math.png" to size 1366
        get name of image "Math.png"
                --> "Math.png"
        get name of image "Math.png"
                --> "Math.png"
        offset of "." in "Math.png"
                --> error number -10004
end tell
tell current application
        offset of "." in "Math.png"
                --> 5
end tell
tell application "Finder"
        get parent of document file "Math.png" of folder "test" of folder "Downloads" of folder "tim" of folder "Users" of startup disk
                --> alias "Paul:Users:tim:Downloads:test:"
end tell
tell application "Image Events"
        save image "Math.png" in "/Users/tim/Downloads/test/Math_1366x768.png" as PNG
                --> file "Paul:Users:tim:Downloads:test:Math_1366x768.png"
end tell
Result:
file "Paul:Users:tim:Downloads:test:Math_1366x768.png" of application "Image Events"

Notice that the previously selected ./169/Math.png is the one that gets open when I call open currentWallpaper as (alias), despite the fact that the correct wallpaper shows up in the Finder selection. In other words, it's not like Finder is stuck with the old selection, but that the wallpapers that I'm looping through get stuck on the old ones.
Perhaps even more bizarre, is that if I move the old wallpaper, that I had selected, the currentWallpaper reference moves with it! In other words, even if I trash the old selection, the output from the script reports that it's opening the one in ./.Trashes.
It does not seem to get confused as long as the names are different.
The Script:
tell application "Finder" to set wallpapers to selection

set myDimensions to {w169:[{2560, 1440}, {1920, 1080}, {1366, 768}], w1610:[{2560, 1600}, {1920, 1200}, {1440, 900}, {1280, 800}], f43:[{1600, 1200}], s:[{1024, 1024}]}

tell application "Image Events"
    repeat with currentWallpaper in wallpapers
            set theWallpaper to open (currentWallpaper as alias)
            tell theWallpaper
                    set theWallpaperDimensions to dimensions of theWallpaper
                    set currentAspects to {}
                    if my aspectsEqual(16 / 10, theWallpaperDimensions) then set currentAspects to w1610 of myDimensions
                    if my aspectsEqual(16 / 9, theWallpaperDimensions) then set currentAspects to w169 of myDimensions
                    if my aspectsEqual(4 / 3, theWallpaperDimensions) then set currentAspects to f43 of myDimensions
                    if my aspectsEqual(1, theWallpaperDimensions) then set currentAspects to s of myDimensions
                    repeat with dim in currentAspects
                            -- Scale and Crop to current dimensions
                            if item 1 of theWallpaperDimensions is greater than item 1 of dim then
                                    scale to size (get item 1 of dim)

                                    -- Set up save target
                                    set namePrefix to text items 1 thru ((offset of "." in (get name)) - 1) of (get name) as string
                                    tell application "Finder"
                                            set _ to parent of currentWallpaper as alias
                                            set parentPath to POSIX path of _
                                    end tell
                                    set saveTarget to parentPath & namePrefix & "_" & (get item 1 of dim) & "x" & (get item 2 of dim) & ".png"

                                    --save to target
                                    save in saveTarget as PNG
                            end if
                    end repeat
            end tell
    end repeat
end tell

on aspectsEqual(baseAspect, wallpaperDimensions)
    set wallpaperAspect to (item 1 of wallpaperDimensions) / (item 2 of wallpaperDimensions)
    set aspectDifference to baseAspect - wallpaperAspect
    if aspectDifference is less than 0 then set aspectDifference to aspectDifference * -1
    return aspectDifference is less than 1.0E-3
end aspectsEqual

A: The problem is caused by way "Image Events" returns references to opened images:
open alias "Paul:Users:tim:Downloads:test:Math.png"
        --> image "Math.png"
open alias "Paul:Users:tim:Downloads:test:169:Math.png"
        --> image "Math.png"

The opened image is referenced by name. If you open another image with the same name, the returned reference may occasionally refer to a previously opened image of the same name.
As a work-around add a close every image before you enter the loop that processes the selected images. Furthermore you need to close the opened image when you are done with it:
tell application "Image Events"
    close every image
    repeat with currentWallpaper in wallpapers
        set theWallpaper to open (currentWallpaper as alias)
        tell theWallpaper
        ...
        end tell
        close theWallpaper
    end repeat
end tell


Q: Combining two datasets to match each - R I have two datasets like this:

*

*Population by country

Country  Population

America      value
Argentina    value
Australia    value
Brazil       value
Japan        value
...

*Landmass by country

Country    Landmass

Argentina   value
Mexico      value
Uruguay     value
Maldives    value
...

The number of rows and the number of country names are different from each set, is there a way to combine both data, (adding Landmass column to the respective country in the population set)  it doesn't matter if that country isn't present in the population set, only combine to the ones that are there.

A: I think what you're after is a left_join which from the docs:
https://dplyr.tidyverse.org/reference/join.html
returns all rows from x, and all columns from x and y. i.e.
pops <- data.frame(
  "Country"  = c("America", "Argentina", "Australia","Brazil", "Japan"),
  "Population" = seq(100, 200, 25)
)

landmass <- data.frame(
  "Country"  = c("Argentina", "Mexico", "Uruguay","Maldives"),
  "Landmass" = seq(1250, 2000, 250)
)

dplyr::left_join(pops, landmass, by = c("Country"= "Country"))

yields


Q: Solve a system of equations depending on a set of parameters with Mathematica Using Mathematica, I want to solve a system of nonlinear equations like
f(x,y;m)=0
g(x,y;m)=0

where m is an external parameter on which the equations depends on.
As the equations are very hard, what I do is to explicitly fix m, above all, and then find a solution for that specific value of m (by FindRoot[]). But this is very slow and inefficient (and more specifically in my case, where indeed I have three parameters).
What I would like is an automatic method that studies numerically the solution for a discrete set of values for m, that fixes it without that I explicitly change it from time to time. So that I would get all together the solutions for those values of m.
It would be nice also that a similar procedure can be applied to the initial seeds for FindRoot [], since in my case I get several solutions changing the latter, and so there are different solutions for that value of m, and so similarly I would like to have all the solutions for a given set of initial seeds.
Is it possible to do such a thing? How?
Many thanks

A: For the first part, assuming that you have a function solve[m] and a range of values for m={1,2,3,...}, you can use:
Map[solve, m]

I'm not sure what you mean by "fixing it", but this will give you an array, which you can investigate further.


Q: Use of jTDS to connect to SQL Server 2012 throws IOException; MS SQL Driver works The following code using jTDS driver (1.3.1):
DriverManager.getConnection("jdbc:jtds:sqlserver://anIpAddress;databaseName=aDatabase", "user", "pass")

results in:
java.sql.SQLException: I/O Error: DB server closed connection.
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2481)
    at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:632)
    at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:371)
    at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.example.crd.test.TestDb.main(TestDb.java:20)
Caused by: java.io.IOException: DB server closed connection.
    at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:852)
    at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:731)
    at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:477)
    at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:114)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2368)

However, this code using MS SQL driver (4.2) works without exception:
DriverManager.getConnection("jdbc:sqlserver://anIpAddress;databaseName=aDatabase", "user", "pass")

I'm trying to connect to a SQL Server 2012 database. Note: The user has read only access to the database. I do not have permission to change any configuration on SQL Server 2012. I have tried the same code to connect to a SQL Server 2005 database, and both the Microsoft and jTDS drivers work without exception in that case.
How can I connect to the SQL Server 2012 database without exception using jTDS?


Q: Integrate REST Web Services with Spring Integration I have implemented Restful web services using spring technologies. Now, I need to integrate these services to work together on the same context using spring integration.
How To make web services methods as endpoints ? How can I realize the coreography of web services ? How It is possible to transform messages exchanged between web services ?

A: The spring-integration tag has links to lots of resources.


Q: Disable gridview controls using jquery in aspx form I have a form in which there is a CheckBox and a gridview. When I uncheck the CheckBox I want controls in my Gridview to be disabled. here is my gridview aspx:
                            <div id="gridVersion" runat="server">
                                <ac:GridViewWithPager ID="gdvwAllowedVersion" runat="server" UseCustomPager="True"
                                    AllowPaging="True" AutoGenerateColumns="False" Width="50%">
                                    <Columns>
                                        <asp:TemplateField ItemStyle-CssClass="centerdata">
                                            <ItemTemplate>
                                                <asp:RadioButton ID="rdblSelectedVersionList" runat="server" AutoPostBack="true" Checked='<%#Eval("IsSelected") %>'
                                                    EnableViewState="true" OnCheckedChanged="rdblSelectedVersionList_CheckedChanged" />
                                            </ItemTemplate>
                                            <HeaderStyle HorizontalAlign="Center" Width="2%"></HeaderStyle>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="IDEAlliance Version" HeaderStyle-Width="11%" HeaderStyle-HorizontalAlign="Left">
                                            <ItemTemplate>
                                                <asp:Label ID="lblVersion" runat="server" Text='<%# Eval("IdeAllianceVersion") %>' />
                                            </ItemTemplate>
                                            <HeaderStyle HorizontalAlign="Left" Width="11%"></HeaderStyle>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Restrict Import Of" ItemStyle-CssClass="centerdata"
                                            HeaderStyle-Width="2%" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="2%">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkCheckRestrictImport" runat="server" Checked='<%# Eval("RestrictedForImport")%>' />
                                            </ItemTemplate>
                                            <HeaderStyle HorizontalAlign="Center" Width="2%"></HeaderStyle>
                                            <ItemStyle HorizontalAlign="Center" Width="2%"></ItemStyle>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Restrict Upgrade To" ItemStyle-CssClass="centerdata"
                                            HeaderStyle-Width="2%" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="2%">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkCheckRestrictUpgrade" runat="server" Checked='<%# Eval("RestrictedForUpgrade")%>' />
                                            </ItemTemplate>
                                            <HeaderStyle HorizontalAlign="Center" Width="2%"></HeaderStyle>
                                            <ItemStyle HorizontalAlign="Center" Width="2%"></ItemStyle>
                                        </asp:TemplateField>
                                    </Columns>
                                </ac:GridViewWithPager>
                            </div>

My CheckBox control is something like this:
<asp:CheckBox ID="chkActivateSettings" runat="server" Text="Activate Restriction Settings.">
                                    </asp:CheckBox>

I have already written a Jquery code that hides and shows this grid. But now what I want is to disable control in this grid upon unchecking the CheckBox. So I want to modify this code:
$(document).ready(function () {

    if ($('#<%=chkActivateSettings.ClientID %>').is(":checked")) {
        //show the hidden div
        $('#<%=gridVersion.ClientID %>').show("fast");
    }
    else {
        //otherwise, hide it
        $('#<%=gridVersion.ClientID %>').hide("fast");
    }
    // Add onclick handler to checkbox w/id checkme
    $('#<%=chkActivateSettings.ClientID %>').click(function () {

        // If checked
        if ($('#<%=chkActivateSettings.ClientID %>').is(":checked")) {
            //show the hidden div
            $('#<%=gridVersion.ClientID %>').Ena("fast");
        }
        else {
            //otherwise, hide it
            $('#<%=gridVersion.ClientID %>').hide("fast");
        }
    });

});

Looking forward to your usual cooperation.

A: Try this:
1) Add Enabled="True" to gridview markup:
<ac:GridViewWithPager ID="gdvwAllowedVersion" runat="server" Enabled="True" UseCustomPager="True" AllowPaging="True" AutoGenerateColumns="False" Width="50%">

2) Use Jquery's DOM manipulation method attr(key, value) to enable/disable gridview:
$(document).ready(function () {

    // Add onclick handler to checkbox w/id checkme
    $('#<%=chkActivateSettings.ClientID %>').click(function () {

        // If checked
        if ($('#<%=chkActivateSettings.ClientID %>').is(":checked")) {
            //show the hidden div
            $('#<%=gdvwAllowedVersion.ClientID %>').attr("disabled", false);
        }
        else {
            //otherwise, hide it
            $('#<%=gdvwAllowedVersion.ClientID %>').attr("disabled", true);
        }
    });

});


Q: Cannot deploy Next.js to Netlify. Deploy failed due to an error in @netlify/plugin-nextjs plugin I can run npm run build with no problems at all, but whenever I try and deploy my Next.js project to Netlify I get an odd error stating Deploy failed due to an error in @netlify/plugin-nextjs plugin
After doing some research I found that I should install @netlify/plugin-nextjs into my package.json as a dev dependency, then add it to a netlify.toml in the root of my project which I have done. Here is the github repo which Netlify's support forums have led me to: https://github.com/netlify/netlify-plugin-nextjs
I've followed the directions on their github repo above for the @netlify/plugin-nextjs plugin as well as searched for any relevant posts under their github issues and unfortunately I couldn’t find anything related nor useful in the github issues.
I’ve tried clearing cache and deploy but it didn’t help.
I am using Next.js version v11.1.2
Here is the build log with the error detailed:
11:58:50 PM: Started restoring cached go cache
11:58:50 PM: Finished restoring cached go cache
11:58:50 PM: go version go1.16.5 linux/amd64
11:58:50 PM: go version go1.16.5 linux/amd64
11:58:50 PM: Installing missing commands
11:58:50 PM: Verify run directory
11:58:52 PM:
11:58:52 PM: ────────────────────────────────────────────────────────────────
11:58:52 PM:   Netlify Build
11:58:52 PM: ────────────────────────────────────────────────────────────────
11:58:52 PM:
11:58:52 PM: ❯ Version
11:58:52 PM:   @netlify/build 18.21.2
11:58:52 PM:
11:58:52 PM: ❯ Flags
11:58:52 PM:   baseRelDir: true
11:58:52 PM:   buildId: 618232a9499e9a000783387d
11:58:52 PM:   deployId: 618232a9499e9a000783387f
11:58:52 PM:
11:58:52 PM: ❯ Current directory
11:58:52 PM:   /opt/build/repo
11:58:52 PM:
11:58:52 PM: ❯ Config file
11:58:52 PM:   /opt/build/repo/netlify.toml
11:58:52 PM:
11:58:52 PM: ❯ Context
11:58:52 PM:   production
11:58:52 PM:
11:58:52 PM: ❯ Installing plugins
11:58:52 PM:    - @netlify/plugin-nextjs@3.9.2
11:59:02 PM:
11:59:02 PM: ❯ Loading plugins
11:59:02 PM:    - @netlify/plugin-nextjs@3.9.2 from netlify.toml
11:59:03 PM:
11:59:03 PM: ────────────────────────────────────────────────────────────────
11:59:03 PM:   1. @netlify/plugin-nextjs (onPreBuild event)
11:59:03 PM: ────────────────────────────────────────────────────────────────
11:59:03 PM:
11:59:03 PM:
11:59:03 PM: ────────────────────────────────────────────────────────────────
11:59:03 PM:   Plugin "@netlify/plugin-nextjs" failed
11:59:03 PM: ────────────────────────────────────────────────────────────────
11:59:03 PM:
11:59:03 PM:   Error message
11:59:03 PM:   Error: This site does not seem to be using Next.js. Please run "npm install next" in the repository.
11:59:03 PM:   If you are using a monorepo, please see the docs on configuring your site: https://ntl.fyi/next-monorepos
11:59:03 PM:
11:59:03 PM:   Plugin details
11:59:03 PM:   Package:        @netlify/plugin-nextjs
11:59:03 PM:   Version:        3.9.2
11:59:03 PM:   Repository:     git+https://github.com/netlify/netlify-plugin-nextjs.git
11:59:03 PM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
11:59:03 PM:   Report issues:  https://github.com/netlify/netlify-plugin-nextjs/issues
11:59:03 PM:
11:59:03 PM:   Error location
11:59:03 PM:   In "onPreBuild" event in "@netlify/plugin-nextjs" from netlify.toml
11:59:03 PM:       at validateNextUsage (/.netlify/plugins/node_modules/@netlify/plugin-nextjs/helpers/validateNextUsage.js:15:12)
11:59:03 PM:       at onPreBuild (/.netlify/plugins/node_modules/@netlify/plugin-nextjs/index.js:32:5)
11:59:03 PM:
11:59:03 PM:   Resolved config
11:59:03 PM:   build:
11:59:03 PM:     command: next build
11:59:03 PM:     commandOrigin: config
11:59:03 PM:     environment:
11:59:03 PM:       - FACEBOOK_APP_ID
11:59:03 PM:       - FACEBOOK_APP_SECRET
11:59:03 PM:       - GATSBY_STRIPE_PK
11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_API_KEY
11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_APPID
11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_DATABASE_URL
11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_PROJECT_ID
11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
11:59:03 PM:       - NEXT_PUBLIC_STRAPI
11:59:03 PM:       - NEXT_PUBLIC_STRAPI_DEV
11:59:03 PM:       - NEXT_PUBLIC_STRAPI_FETCH
11:59:03 PM:       - NEXT_PUBLIC_STRAPI_PROD
11:59:03 PM:       - STRAPI_API
11:59:03 PM:       - CYPRESS_CACHE_FOLDER
11:59:03 PM:     ignore: git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../
11:59:03 PM:     publish: /opt/build/repo/.next
11:59:03 PM:     publishOrigin: config
11:59:03 PM:   plugins:
11:59:03 PM:     - inputs: {}
11:59:03 PM:       origin: config
11:59:03 PM:       package: '@netlify/plugin-nextjs'
11:59:04 PM: Caching artifacts
11:59:04 PM: Started saving node modules
11:59:04 PM: Finished saving node modules
11:59:04 PM: Started saving build plugins
11:59:04 PM: Finished saving build plugins
11:59:04 PM: Started saving yarn cache
11:59:29 PM: Finished saving yarn cache
11:59:29 PM: Started saving pip cache
11:59:29 PM: Finished saving pip cache
11:59:29 PM: Started saving emacs cask dependencies
11:59:29 PM: Finished saving emacs cask dependencies

Here is my package.json file:
{
  "name": "@minimal/minimal-kit-react",
  "author": "minimals.cc",
  "version": "2.6.0",
  "private": true,
  "scripts": {
    "dev": "next dev -p 3222",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "@apollo/client": "^3.4.16",
    "@auth0/auth0-spa-js": "1.18",
    "@emotion/cache": "^11.4.0",
    "@emotion/react": "^11.4.1",
    "@emotion/server": "^11.4.0",
    "@emotion/styled": "^11.3.0",
    "@fontsource/alata": "^4.5.0",
    "@fontsource/barlow": "^4.5.0",
    "@fontsource/inter": "^4.5.0",
    "@fontsource/karla": "^4.5.0",
    "@fontsource/poppins": "^4.5.0",
    "@fontsource/public-sans": "^4.5.0",
    "@fontsource/raleway": "^4.5.0",
    "@fullcalendar/daygrid": "^5.9.0",
    "@fullcalendar/interaction": "^5.9.0",
    "@fullcalendar/list": "^5.9.0",
    "@fullcalendar/react": "^5.9.0",
    "@fullcalendar/timegrid": "^5.9.0",
    "@fullcalendar/timeline": "^5.9.0",
    "@hookform/devtools": "^4.0.1",
    "@hookform/resolvers": "^2.8.0",
    "@iconify/icons-ant-design": "^1.1.0",
    "@iconify/icons-eva": "^1.1.0",
    "@iconify/icons-ic": "^1.1.10",
    "@iconify/icons-simple-icons": "^1.1.46",
    "@material-ui/core": "^4.11.0",
    "@material-ui/data-grid": "^4.0.0-alpha.21",
    "@material-ui/icons": "^4.11.2",
    "@material-ui/lab": "^4.0.0-alpha.56",
    "@mui/icons-material": "^5.0.0",
    "@mui/lab": "^5.0.0-alpha.47",
    "@mui/material": "^5.0.0",
    "@mui/styles": "^5.0.0",
    "@mui/utils": "^5.0.0",
    "@mui/x-data-grid": "^5.0.0-beta.1",
    "@react-pdf/renderer": "^2.0.19",
    "@reduxjs/toolkit": "^1.6.1",
    "@stripe/react-stripe-js": "^1.5.0",
    "@stripe/stripe-js": "^1.18.0",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^12.1.0",
    "@testing-library/user-event": "^13.2.1",
    "@turf/bbox": "^6.5.0",
    "amazon-cognito-identity-js": "^5.1.0",
    "animejs": "^3.2.1",
    "apexcharts": "^3.28.3",
    "autosuggest-highlight": "^3.1.1",
    "axios": "^0.21.4",
    "axios-mock-adapter": "^1.20.0",
    "change-case": "^4.1.2",
    "d3-array": "^3.0.2",
    "d3-scale": "^4.0.0",
    "date-fns": "^2.24.0",
    "deck.gl": "^8.5.8",
    "dotenv": "^10.0.0",
    "draft-js": "^0.11.7",
    "draftjs-to-html": "^0.9.1",
    "emoji-mart": "^3.0.0",
    "firebase": "^8.10.0",
    "formik": "^2.2.9",
    "framer-motion": "^4.1.17",
    "fs": "^0.0.1-security",
    "graphql": "^15.7.1",
    "highlight.js": "^11.3.1",
    "history": "^5.0.1",
    "i18next": "^20.6.1",
    "i18next-browser-languagedetector": "^6.1.2",
    "immutable": "^4.0.0-rc.14",
    "jsonwebtoken": "^8.5.1",
    "jwt-decode": "^3.1.2",
    "lazysizes": "^5.3.2",
    "lodash": "^4.17.21",
    "lowlight": "^2.4.0",
    "madge": "^5.0.1",
    "mapbox-gl": "^2.4.1",
    "next": "^11.1.2",
    "notistack": "^1.0.6-next.3",
    "nprogress": "^0.2.0",
    "numeral": "^2.0.6",
    "pnp-webpack-plugin": "^1.7.0",
    "process": "^0.11.10",
    "prop-types": "^15.7.2",
    "react": "17.0.2",
    "react-apexcharts": "^1.3.9",
    "react-beautiful-dnd": "^13.1.0",
    "react-copy-to-clipboard": "^5.0.4",
    "react-dom": "17.0.2",
    "react-draft-wysiwyg": "^1.14.7",
    "react-dropzone": "^11.4.0",
    "react-helmet-async": "^1.1.2",
    "react-highlight": "^0.14.0",
    "react-hook-form": "^7.15.3",
    "react-i18next": "^11.12.0",
    "react-image-lightbox": "^5.1.4",
    "react-infinite-scroll-component": "^6.1.0",
    "react-intersection-observer": "^8.32.1",
    "react-lottie": "^1.2.3",
    "react-map-gl": "^6.1.17",
    "react-markdown": "^7.1.0",
    "react-quill": "^2.0.0-beta.4",
    "react-redux": "^7.2.5",
    "react-resize-aware": "^3.1.1",
    "react-scripts": "^4.0.1",
    "react-scroll": "^1.8.4",
    "react-slick": "^0.28.0",
    "react-spring": "^9.2.4",
    "redux": "^4.1.1",
    "redux-persist": "^6.0.0",
    "rehype-highlight": "^5.0.0",
    "rehype-raw": "^6.1.0",
    "simplebar": "^5.3.5",
    "simplebar-react": "^2.3.5",
    "slick-carousel": "^1.8.1",
    "stylis": "^4.0.10",
    "stylis-plugin-rtl": "^2.0.2",
    "typescript": "^4.3.5",
    "uuid": "^8.3.2",
    "worker-loader": "^3.0.8",
    "yup": "^0.32.9"
  },
  "devDependencies": {
    "@babel/core": "^7.15.8",
    "@babel/eslint-parser": "^7.15.4",
    "@babel/preset-react": "^7.14.5",
    "@iconify/icons-fa-solid": "^1.1.1",
    "@iconify/react": "^3.0.1",
    "@netlify/plugin-nextjs": "^4.0.0-beta.5",
    "@types/node": "^16.7.13",
    "@typescript-eslint/eslint-plugin": "^4.31.0",
    "@typescript-eslint/parser": "^4.31.0",
    "eslint": "^7.32.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-airbnb-typescript": "^14.0.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-config-wesbos": "2.1.0",
    "eslint-plugin-html": "^6.1.2",
    "eslint-plugin-import": "^2.24.2",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-react": "^7.25.1",
    "eslint-plugin-react-hooks": "^4.2.0",
    "graphql": "latest",
    "prettier": "^2.3.2",
    "typescript": "^4.4.2"
  }
}

Here is my netlify.toml:
[build]
publish = ".next"

[[plugins]]
package = "@netlify/plugin-nextjs"

A: I had this same issue. Removing the @netlify/plugin-nextjs from the plugins tab on Netlify fixed the issue for me. I removed the plugin and triggered a new deploy.

A: I had the same issue and I resolved it by updating the plugin from the plugins tab in Netlify.

A: In my case, the solution was to disable the plugin, and then re-enable it. Disabling the plugin broke my site temporarily because it's needed to run Next.js, but it was the only way I could get my deploy to succeed.
Other things I tried that did not work:

*

*Re-building node_modules

*Updating package-lock.json

*Triggering a re-deploy without cache

A: If you are using a monorepo to fix this issue go to the deploy settings of your site and under build settings change the publish directory to
[subdir]/.next

where [subdir] is the sub directory you have your next project in.
After that clear change and deploy again

A: I have faced the same issues.
I tried adding the NETLIFY_NEXT_PLUGIN_SKIP= "TRUE"to the environment variables and it worked for me

A: 1st in your project folder cmd or git bash run (yarn build)
then go to the  netlify build setting and change (Build command:
next build)
this process is work for me

A: remove the netlify.toml file and let netlify build it with the default npm run build

A: I also faced the same issue. There is something wrong in @netlify/plugin-nextjs plugin latest version 4.0
Try doing this and this worked for me.
In netlify, under your project,  do this.
Site Settings -> Plugins -> Next.js Runtime -> click Change version and select version 3.
NextJs plugin version change screenshot
And redeploy the site.


Q: Change NSTabViewController NSSegmentedControl In 10.10 Apple introduced some updates on AppKit with Storyboards and a few classes. One of those is NSTabViewController.
In the WWDC Session 212 the presenter showed some properties of the class.

Supposedly, the default NSSegmentedControl could be modified, or, setting tabStyle to NSTabViewControllerTabStyleUnspecified could enable us to modify the tabs style. The problem is that segmentedControl doesn't appear to be an available property on the SDK.
Maybe it didn't made it to release? How can we change the style without it?
My goal was to implement something like the Xcode 6 left tab.

A: The way to do this is to create a tabless tab view and a custom segmented control whose action changes tabs inyour tab view.
You can fill a duplicate bug report at bugreport.apple.com:

*

*rdar://34206798 NSTabViewController.h documentation is outdated

*rdar://34206839 NSTabViewController should provide a way to customise
its NSSegmentedControl


Q: How to build and Install TAGLIB in Codeblocks I am struggling to create a program which embeds song lyrics in *.mp3 files using C++ programming for my ongoing project. After searching, I found a library named "TAGLIB" that can process ID3v2.3 standard metadata.
According to the LIBTAG installation guide, I ran CMAKE and configured liked this image and this image and build with mingw
C:\Desktop\taglib> mingw32-make
and
C:\Desktop\taglib> mingw32-make install
I got this folder C:\Program Files (x86)\taglib having contents inside it, including,
bin\libtag.dll
bin\libtag_c.dll
bin\libtag_c.dll

include\*.h files

lib\pkgconfig\taglib.pc
lib\pkgconfig\taglib_c.pc
lib\libtag.a
lib\libtag.dll.a
lib\libtag_c.dll.a

In Codeblocks, I linked libtag.a, libtag.dll.a and libtag_c.dll.a and configured search directories to C:\Program Files (x86)\taglib and did same to the current project. But compiler gives this type of error for]many times
undefined reference to _imp___ZN6TagLib6StringC1EPKcNS0_4TypeE'|
when I tried to compile example codes provided with library.
Then I used GCC to compile code.  But this time no luck..
C:\Program Files (x86)\taglib>gcc -o f.exe framelist.cpp -L"C:/Program Files (x86)/taglib/lib/" -libta.a -I"C:/Program Files (x86)/taglib/include/taglib"
Getting this error:
`
framelist.cpp:32:10: error: #include expects "FILENAME" or <FILENAME>
 #include C:/Program Files (x86)/taglib/include/taglib/id3v2tag.h>
          ^
framelist.cpp: In function 'int main(int, char**)':
framelist.cpp:59:23: error: invalid use of incomplete type 'class TagLib::ID3v2:
:Tag'
            << id3v2tag->header()->majorVersion()
                       ^
In file included from framelist.cpp:30:0:
C:/Program Files (x86)/taglib/include/taglib/mpegfile.h:37:27: note: forward dec
laration of 'class TagLib::ID3v2::Tag'
   namespace ID3v2 { class Tag; class FrameFactory; }
                           ^
framelist.cpp:61:23: error: invalid use of incomplete type 'class TagLib::ID3v2:
:Tag'
            << id3v2tag->header()->revisionNumber()
                       ^
In file included from framelist.cpp:30:0:
C:/Program Files (x86)/taglib/include/taglib/mpegfile.h:37:27: note: forward dec
laration of 'class TagLib::ID3v2::Tag'
   namespace ID3v2 { class Tag; class FrameFactory; }
                           ^
framelist.cpp:63:23: error: invalid use of incomplete type 'class TagLib::ID3v2:
:Tag'
            << id3v2tag->header()->tagSize()
                       ^
In file included from framelist.cpp:30:0:
C:/Program Files (x86)/taglib/include/taglib/mpegfile.h:37:27: note: forward dec
laration of 'class TagLib::ID3v2::Tag'
   namespace ID3v2 { class Tag; class FrameFactory; }
                           ^
framelist.cpp:67:14: error: 'TagLib::ID3v2::FrameList' has not been declared
       ID3v2::FrameList::ConstIterator it = id3v2tag->frameList().begin();
              ^
framelist.cpp:68:13: error: 'it' was not declared in this scope
       for(; it != id3v2tag->frameList().end(); it++)
             ^
framelist.cpp:68:27: error: invalid use of incomplete type 'class TagLib::ID3v2:
:Tag'
       for(; it != id3v2tag->frameList().end(); it++)
                           ^
In file included from framelist.cpp:30:0:
C:/Program Files (x86)/taglib/include/taglib/mpegfile.h:37:27: note: forward dec
laration of 'class TagLib::ID3v2::Tag'
   namespace ID3v2 { class Tag; class FrameFactory; }
                           ^
`

As you can understand, I'm fairly new to adding external library, help me figuring out, How can I properly install "LIBTAG" to start coding in Codeblocks.


Q: Remove c__DisplayClass from code coverage I'm getting c__DisplayClass files appearing in my code coverage analysis that appear to be auto generated code from closures (see this link).
My question is, HOW do you remove this auto generated code from code coverage results?

A: After some research, I've discovered you can make use of a .runsettings file (documentation).
You can customize your code coverage results within this file like so:
<CodeCoverage>
  <ModulePaths>
    <Exclude></Exclude>
  </ModulePaths>
  <Functions>
    <Exclude>
      <Function>.*c__DisplayClass.*</Function>
    </Exclude>
  </Functions>
</CodeCoverage>

This gave me the results I wanted.  All auto generated c__DisplayClass functions are excluded from the results.

A: Just to add to Anthony's excellent answer, I had lots of auto generated rubbish which can be hidden neatly with the following .runsettings file:
<CodeCoverage>
    <ModulePaths>
        <Exclude></Exclude>
    </ModulePaths>
    <Functions>
        <Exclude>
            <Function>.*<*>.*</Function>
        </Exclude>
    </Functions>
</CodeCoverage>

Note that < and > are the triangular brackets < and > so this should (in my experience) cover all automatically generated code in the coverage results.


Q: calling non exported functions from dll using c++ console app i have a dll with COM METHOD functions i want to call
i know the prototype and parameters of each fun. and also return type
can anyone help me in calling these functions in details please because i am a beginner in this part
i use vs2010
thanks in advance


Q: PHP to WebService I want to connect to a webservice.
I have the following code to test connecting to the service;
$soapURL = 'http://xxx.xxx.xx.xx4/wsdl/wsdl' ;
$soapParameters = Array('login' => "xxx", 'password' => "1234") ;
$client = new SoapClient($soapURL, $soapParameters);
var_dump($client->__getFunctions());

Which works fine and give me back the following;
array(6) {
    [0]=> string(35) "CallResponse Call(Call $parameters)"
    [1]=> string(59) "FieldManagerResponse FieldManager(FieldManager $parameters)"
    [2]=> string(56) "FixScheduleResponse FixSchedule(FixSchedule $parameters)"
    [3]=> string(44) "GeocodeResponse Geocode(Geocode $parameters)"
    [4]=> string(59) "ShowCallInfoResponse ShowCallInfo(ShowCallInfo $parameters)"
    [5]=> string(59) "WorkScheduleResponse WorkSchedule(WorkSchedule $parameters)"
}

I want to call the ShowCallinfo function which has 2 parameters, an integer 0, and a string 'CA12345' - and should return a set of data;
Latest combination I have tried (immediately after the other code) are;
$result = $client->ShowCallInfo(0,'CA212345');

Which results in a SoapFault exception: [HTTP] Not Found in

A: The SoapFault you're facing is not due to the parameters but due to the fact that the SoapAction address is not reachable from your network or is simply invalid.

*

*You should first check the url in <soap:address location="{url}" /> in the WSDL and ensure that it is reachable,

*You should then use a WSDL to php generator that will ease you the task of sending the request. Indeed you won't have to wonder about soap as you'll only deal with objects or at least you'll know exactly how to send the parameters. I can only advise you to try the PackageGenerator as it's mine but you can find other project of this type out there


Q: Rails 3.2 force_ssl except on landing page I want to enforce SSL on all routes except my landing page.  I tried setting force_ssl in all my controllers, and for the controller that contains root, I did:
force_ssl :except => :index
However, after I deployed this to my staging app on Heroku, my app is still enforcing ssl on the home page.  Is there something else that needs to be done to disable ssl on that specific route?

A: rack-ssl-enforcer gem will help you


Q: Dynamically load coordinates to google map from database as I go through with my studies on web dev and ajax; i came across with this template that has a map(google map) on it. the script for loading the map is placed on an external .js file here is the code.
    function LoadMapProperty() {
    var locations = new Array(
        [14.4718329, 121.0086019], [14.530026, 120.996063], [14.4737421, 121.0032217], [14.5075023, 120.993699],
        [14.5075023, 120.993699], [14.471466, 121.0277539], [14.4779355, 120.99883], [14.4731542, 121.0037827],
        [14.4966062, 120.9884816], [14.4926289, 120.98628], [14.4779355, 120.99883], [14.4663681, 121.0085009],
        [14.4965154, 120.9895496], [14.527833, 120.996831], [14.4849982, 120.9869173], [14.5016121, 120.9960593],
        [14.4745177, 120.9987967], [14.4745177, 120.9987967], [14.5292715, 120.9960647], [14.4798793, 120.9983465],
        [14.530001, 120.995553], [14.4745177, 120.9987967], [14.4745177, 120.9987967], [14.5292715, 120.9960647],
        [14.4901257, 120.9883528], [14.4799374, 120.9978811], [14.4678564, 120.9801271], [14.4745177, 120.9987967],
        [14.503642, 120.994828], [14.5002999, 120.9973589], [14.5292715, 120.9960647], [14.51565, 120.9960106]
    );
    var markers = new Array();
    var mapOptions = {
        center: new google.maps.LatLng(14.4718329, 121.0086019),
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        scrollwheel: false
    };

    var map = new google.maps.Map(document.getElementById('property-map'), mapOptions);

    $.each(locations, function(index, location) {
        var marker = new google.maps.Marker({
            position: new google.maps.LatLng(location[0], location[1]),
            map: map,
            icon: 'http://html.realia.byaviators.com/assets/img/marker-transparent.png'
        });

        var myOptions = {
            content: '

1041 Fife Ave

Area:200m2

€450 000.00

View more

',
            disableAutoPan: false,
            maxWidth: 0,
            pixelOffset: new google.maps.Size(-146, -190),
            zIndex: null,
            closeBoxURL: "",
            infoBoxClearance: new google.maps.Size(1, 1),
            position: new google.maps.LatLng(location[0], location[1]),
            isHidden: false,
            pane: "floatPane",
            enableEventPropagation: false
        };
        marker.infobox = new InfoBox(myOptions);
        marker.infobox.isOpen = false;

        var myOptions = {
            draggable: true,
            content: '

',
            disableAutoPan: true,
            pixelOffset: new google.maps.Size(-21, -58),
            position: new google.maps.LatLng(location[0], location[1]),
            closeBoxURL: "",
            isHidden: false,
            // pane: "mapPane",
            enableEventPropagation: true
        };
        marker.marker = new InfoBox(myOptions);
        marker.marker.open(map, marker);
        markers.push(marker);

        google.maps.event.addListener(marker, "click", function (e) {
            var curMarker = this;

            $.each(markers, function (index, marker) {
                // if marker is not the clicked marker, close the marker
                if (marker !== curMarker) {
                    marker.infobox.close();
                    marker.infobox.isOpen = false;
                }
            });

            if(curMarker.infobox.isOpen === false) {
                curMarker.infobox.open(map, this);
                curMarker.infobox.isOpen = true;
                map.panTo(curMarker.getPosition());
            } else {
                curMarker.infobox.close();
                curMarker.infobox.isOpen = false;
            }

        });
    });
}

function LoadMap() {
    var locations = new Array(
        [14.4718329, 121.0086019], [14.530026, 120.996063], [14.4737421, 121.0032217], [14.5075023, 120.993699],
        [14.5075023, 120.993699], [14.471466, 121.0277539], [14.4779355, 120.99883], [14.4731542, 121.0037827],
        [14.4966062, 120.9884816], [14.4926289, 120.98628], [14.4779355, 120.99883], [14.4663681, 121.0085009],
        [14.4965154, 120.9895496], [14.527833, 120.996831], [14.4849982, 120.9869173], [14.5016121, 120.9960593],
        [14.4745177, 120.9987967], [14.4745177, 120.9987967], [14.5292715, 120.9960647], [14.4798793, 120.9983465],
        [14.530001, 120.995553], [14.4745177, 120.9987967], [14.4745177, 120.9987967], [14.5292715, 120.9960647],
        [14.4901257, 120.9883528], [14.4799374, 120.9978811], [14.4678564, 120.9801271], [14.4745177, 120.9987967],
        [14.503642, 120.994828], [14.5002999, 120.9973589], [14.5292715, 120.9960647], [14.51565, 120.9960106]
    );
    var markers = new Array();
    var mapOptions = {
        center: new google.maps.LatLng(14.4718329, 121.0086019),
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        scrollwheel: false
    };

    var map = new google.maps.Map(document.getElementById('map'), mapOptions);

    $.each(locations, function(index, location) {
        var marker = new google.maps.Marker({
            position: new google.maps.LatLng(location[0], location[1]),
            map: map,
            icon: 'http://html.realia.byaviators.com/assets/img/marker-transparent.png'
        });

        var myOptions = {
            content: '

1041 Fife Ave

Area:200m2

€450 000.00

View more

',
            disableAutoPan: false,
            maxWidth: 0,
            pixelOffset: new google.maps.Size(-146, -190),
            zIndex: null,
            closeBoxURL: "",
            infoBoxClearance: new google.maps.Size(1, 1),
            position: new google.maps.LatLng(location[0], location[1]),
            isHidden: false,
            pane: "floatPane",
            enableEventPropagation: false
        };
        marker.infobox = new InfoBox(myOptions);
        marker.infobox.isOpen = false;

        var myOptions = {
            draggable: true,
            content: '

',
            disableAutoPan: true,
            pixelOffset: new google.maps.Size(-21, -58),
            position: new google.maps.LatLng(location[0], location[1]),
            closeBoxURL: "",
            isHidden: false,
            // pane: "mapPane",
            enableEventPropagation: true
        };
        marker.marker = new InfoBox(myOptions);
        marker.marker.open(map, marker);
        markers.push(marker);

        google.maps.event.addListener(marker, "click", function (e) {
            var curMarker = this;

            $.each(markers, function (index, marker) {
                // if marker is not the clicked marker, close the marker
                if (marker !== curMarker) {
                    marker.infobox.close();
                    marker.infobox.isOpen = false;
                }
            });

            if(curMarker.infobox.isOpen === false) {
                curMarker.infobox.open(map, this);
                curMarker.infobox.isOpen = true;
                map.panTo(curMarker.getPosition());
            } else {
                curMarker.infobox.close();
                curMarker.infobox.isOpen = false;
            }

        });
    });
}

function InitMap() {
    google.maps.event.addDomListener(window, 'load', LoadMap);
    google.maps.event.addDomListener(window, 'load', LoadMapProperty);
}

I am new with this ajax thing and as i said just trying to learn things. as with the code you'll notice that the coordinates are bundled in an array. so my question is, Is there a way where in I can fetch some coordinates from my database and put them in this .js script? any links on  other website, suggestions or hint is much appreciated.
Thank you for your time.

A: Here's some code that should help you get started.
function addMarkers(map, locations) {
    $.each(locations, function(index, location) {
        var marker = new google.maps.Marker({
            position: new google.maps.LatLng(location[0], location[1]),
            map: map,
            icon: 'http://html.realia.byaviators.com/assets/img/marker-transparent.png'
        });

        var myOptions = {
            content: '

1041 Fife Ave

Area:200m2

€450 000.00

View more

',
            disableAutoPan: false,
            maxWidth: 0,
            pixelOffset: new google.maps.Size(-146, -190),
            zIndex: null,
            closeBoxURL: "",
            infoBoxClearance: new google.maps.Size(1, 1),
            position: new google.maps.LatLng(location[0], location[1]),
            isHidden: false,
            pane: "floatPane",
            enableEventPropagation: false
        };
        marker.infobox = new InfoBox(myOptions);
        marker.infobox.isOpen = false;

        var myOptions = {
            draggable: true,
            content: '

',
            disableAutoPan: true,
            pixelOffset: new google.maps.Size(-21, -58),
            position: new google.maps.LatLng(location[0], location[1]),
            closeBoxURL: "",
            isHidden: false,
            // pane: "mapPane",
            enableEventPropagation: true
        };
        marker.marker = new InfoBox(myOptions);
        marker.marker.open(map, marker);
        markers.push(marker);

        google.maps.event.addListener(marker, "click", function(e) {
            var curMarker = this;

            $.each(markers, function(index, marker) {
                // if marker is not the clicked marker, close the marker
                if (marker !== curMarker) {
                    marker.infobox.close();
                    marker.infobox.isOpen = false;
                }
            });

            if (curMarker.infobox.isOpen === false) {
                curMarker.infobox.open(map, this);
                curMarker.infobox.isOpen = true;
                map.panTo(curMarker.getPosition());
            } else {
                curMarker.infobox.close();
                curMarker.infobox.isOpen = false;
            }

        });
    });
}
// Assign handlers immediately after making the request,
// and remember the jqXHR object for this request
var jqxhr = $.ajax( "getlocations.php" ).done(function() {
    addMarkers(map, locations)
});

Basically, the code fetches data from the script on getlocations.php and calls addMarkers using the data (it must be returned in JSON form) in "locations". You can add parameters to the AJAX to make it more flexible, like this:
$.ajax(
{
type: "GET",
url: "getlocations.php",
data: { city: "Boston", page: 1 } // or whatever parameters you need to send in the URL
}).done(function() {
    addMarkers(map, locations)
});


Q: Hibernate,Primary key consist from auto generated id and foreign key as pk Welecome, i pretty new in hibernate and i have problem.
Above I insert code example.
 Order should consist 2 primary keys id(own.auto generated pk) and other pk(also as fk from Client table) id of client whose make order. Everything work fine except that when I have added @GeneratedValue(strategy=GenerationType.AUTO) I
am geting above errrors:
org.hibernate.PropertyAccessException: could not set a field value by reflection setter of pl.pb.intern.test.model.Order.id
    at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:151)
    at org.hibernate.mapping.Component$ValueGenerationPlan.execute(Component.java:423)
    at org.hibernate.id.CompositeNestedGeneratedValueGenerator.generate(CompositeNestedGeneratedValueGenerator.java:121)
    at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:117)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:206)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:191)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:114)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
    at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:735)
    at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:727)
    at org.hibernate.engine.spi.CascadingAction$5.cascade(CascadingAction.java:258)
    at org.hibernate.engine.internal.Cascade.cascadeToOne(Cascade.java:388)
    at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:331)
    at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:209)
    at org.hibernate.engine.internal.Cascade.cascadeCollectionElements(Cascade.java:418)
    at org.hibernate.engine.internal.Cascade.cascadeCollection(Cascade.java:358)
    at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:334)
    at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:209)
    at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:166)
    at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:132)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.cascadeOnUpdate(DefaultSaveOrUpdateEventListener.java:364)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:338)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:241)
    at org.hibernate.event.internal.DefaultUpdateEventListener.performSaveOrUpdate(DefaultUpdateEventListener.java:55)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
    at org.hibernate.internal.SessionImpl.fireUpdate(SessionImpl.java:786)
    at org.hibernate.internal.SessionImpl.update(SessionImpl.java:778)
    at org.hibernate.internal.SessionImpl.update(SessionImpl.java:774)
    at pl.pb.intern.test.dao.HibernateClientDAO.updateClient(HibernateClientDAO.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

Caused by: java.lang.IllegalArgumentException: Can not set long field pl.pb.intern.test.model.Order.id to org.hibernate.id.IdentifierGeneratorHelper$2
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
    at sun.reflect.UnsafeLongFieldAccessorImpl.set(Unknown Source)
    at java.lang.reflect.Field.set(Unknown Source)
    at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:139)
    ... 67 more

My entities:
  @Entity
    public class Client
    {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    int id;

    @OnetoMany(mappedBy="client", cascade=CascadeType.ALL , fetch=FetchType.EAGER,orphanRemoval=true)
    List<Order> orders
    //other fields

    }

    @Enitity
    public classs Order
    {
        @Id
         @GeneratedValue(strategy=GenerationType.AUTO)
         int id;

         @Id
        @ManyToOne
        @JoinColumn( name="order_client_id",insertable=false, updatable=false)
        Client client;

           public void setId(long id)
          {
           this.id=id
          }

          public login getId()
         {
           return this.id;
        }
     }

    }

I have reviewed hibernate docs and i did't find any contraindications against connection auto generated primary key and foreign key as pk. What am doing wrong in this example??

A: On the composite primary key issue, see JPA composite primary key
From the exception stack trace, it seems the method signatures of your Order.getId()/Order.setId() have the wrong signatures. According to JavaBean conventions, since Order.id is an int, setId() should take an int parameter and getId() should return an int accordingly. Or, you can change the type of Order.id to long since getId()/setId() already make use of long.
Also, you may wish to edit your code to fix the following typos and syntax errors:
Client.java:
    - @OnetoMany supposed to be @OneToMany
    - Missing end-of-line semicolon on List<Order> orders
Order.java
    - Missing end-of-line semicolon on this.id = id in Order.setId


Q: I was working on my application but suddenly i got table does not exist in all my tables Hey guy i was working on my app but suddenly i got an error says table does not exist in engine.
When i went to see in my database i found out that all my tables are not working for w/e reason but as you can see (in the picture below) it says it does exist, i already checked if i have ibdata1 under C:/xampp/mysql/data/ and i found it.
 Please if there is any solution i can do because i have like 10 tables i cant just re-create them, it's to much work...
The error is
table does not exist in engine


Q: UIDocumentInteractionController change file name for Sharing iam using the following code to show the sharing options for PDF
    self.documentController = UIDocumentInteractionController(url: url)
    self.documentController.name = "Test name" // not working
    self.documentController.presentOptionsMenu(from: self.shareButton, animated: true)

the problem is that I save the PDF file name with datestamp to avoid having two files with the same name, but when the share options is being shown the actual file name appears,
is there is a way to show custom name instead of the actual filename (I don't want to copy the file to other place and rename it, waste of time and performance)

A: In such a situation, we can create a temporary folder which can contain the same file with lastPathExtension will be document.fileExtension and we can pass this newly file path to UIDocumentInteractionController.init(url: newFileUrl)
For Example:
func openUnsupportedFileWithPath(documentName : String, fileurl : URL, fileExtension : String, aDocument: SILDocumentDB? = nil, sourceView: UIView? = nil) -> Void {

    // Create new temporary path
    let paths: String = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
    var newFileUrl: String = paths.appending("/Downloads/TemporaryFolder)")
    newFileUrl = newFileUrl.appendingFormat("%@","\(documentName)")

    let destinationPathUrl : URL
    do {
        // Move newly filePath with new fileName and fileExtension
        destinationPathUrl = URL(fileURLWithPath: destinanewFileUrltionPath)
        try FileManager.default.moveItem(at: fileurl, to: destinationPathUrl)
    } catch {
        print(error)
    }

    //Pass newly filePath to UIDocumentInteractionController
    documentInteractionController = UIDocumentInteractionController.init(url: newFileUrl)
    documentInteractionController?.name = documentName
    documentInteractionController?.delegate = self

    let canPreview = documentInteractionController?.presentPreview(animated: true)
    if (canPreview == false) {
        let activityViewController = UIActivityViewController.init(activityItems: [fileurl], applicationActivities: nil)

        activityViewController.setValue(documentName, forKey: "subject")
        if ISIPAD {
            activityViewController.popoverPresentationController?.sourceView = sourceView ?? self.view
        }
        self.present(activityViewController, animated: true, completion: nil)
    }
}

And UIDocumentInteractionController get dismiss, remove the temporary filePath on documentInteractionControllerDidEndPreview(_ controller: UIDocumentInteractionController) method.
public func documentInteractionControllerDidEndPreview(_ controller: UIDocumentInteractionController) {
        documentInteractionController = nil
        let paths: String = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
        let filePath: String = paths.appending("/Downloads/TemporaryFolder)")

        let _fileManager : FileManager  = FileManager.default
        if filePath.length > 0 {
            if _fileManager.fileExists(atPath: filePath) {
                do{
                    try _fileManager.removeItem(atPath: filePath)
                }catch  let error as NSError{

                    print("\(error.localizedDescription)")
                }
            }
        }
    }


Q: Last month's last date using Javascript I have a textbox in which I show only month and year. So when I have June 2013, and when I look for First half, then I want the previous month's date to 14th of June.
So in Javascript I was simply using
var currentmonth=doucument.getElementbyId("textbox");
var currentdate="01-"+currentmonth;// as earlier I had 1st to 15 of month.

I want to get the last months' last date that too in a format, like
"31-May-2013".

I am trying to change like:
currentdate= new Date(currentdate).get...//but not working

A: Create date object:
var currentdate = new Date("01-"+currentmonth)

Set last day of month using setFullYear, getFullYear and getMonth methods:
currentdate.setFullYear(test.getFullYear(), test.getMonth()+1, 0)


Q: Discrepancy in the user roles(authorities) in the access token obtained from grant_type=password and grant_type=refresh_token I have a situation:
Step 1: Obtained access token (grant_type=password) (A1) and also a refresh token.(RT1)
Step 2: Accessed resource (R) using the token (A1) - Success
Step 3:Revoked user access role for Resource R.
Step 4: Obtained access token (grant_type=password) (A2) and also a refresh token.(RT2)
Step 5: Accessed resource (R) using the token (A2) - Failed
till here all fine.now comes the unexpected part.
Step 6: Obtained new access token (grant_type=refresh_token) using RT2. Unexpectedly using this access token i was able to access resource R.
During this whole flow none of the token was expired one.
I see two issues here:- User roles aren't getting updated for refresh token on grant_type=password and for grant_type=refresh_token. Although access token has changed (Step 4)  but refresh token remains same RT1 == RT2. hence any further usage of RT gives access token with previous roles.
How do i tell spring (oauth2) to update user roles (for the newly created token's) while obtaining the access token using refresh token and also  while updating  RT with new roles (step4), to resolve this discrepancy.
Below is the Authorization server configuration:
 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
       xmlns:security="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2.xsd
                           http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
                           http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
    <property name="userDetailsService">
      <bean class="com.dummy.mc.security.service.UserDetailsServiceImpl">
        <property name="userRepository" ref="userRepository" />
        <property name="grantedAuthorityRepository" ref="grantedAuthorityRepository" />
      </bean>
    </property>
    <property name="passwordEncoder">
      <bean class="com.dummy.mc.security.password.McpmPasswordEncoder">
        <property name="encodeHashAsBase64" value="true" />
      </bean>
    </property>
    <property name="saltSource">
      <bean class="org.springframework.security.authentication.dao.ReflectionSaltSource">
        <property name="userPropertyToUse" value="salt" />
      </bean>
    </property>
  </bean>

    <!--https://stackoverflow.com/questions/49761597/spring-oauth2-clientid-passed-in-as-username-for-password-grant-type-->

    <bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.store.JdbcTokenStore">
        <constructor-arg ref="dataSource" />
    </bean>

    <bean id="tokenServices"
          class="org.springframework.security.oauth2.provider.token.DefaultTokenServices">
        <property name="tokenStore" ref="tokenStore" />
        <property name="supportRefreshToken" value="true" />
        <property name="clientDetailsService" ref="clientDetailsService" />
        <property name="reuseRefreshToken" value="false"/>

    </bean>

    <bean id="oauthAccessDeniedHandler"
          class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler" />

    <bean id="clientCredentialsTokenEndpointFilter"
          class="org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter">
        <property name="authenticationManager" ref="clientDetailAuthenticationManager" />
    </bean>

    <!-- Authentication manager for client (not resource-owner) authentication required to
        protect the token endpoint URL -->

    <security:authentication-manager id="clientDetailAuthenticationManager">
        <security:authentication-provider user-service-ref="clientDetailsUserService"/>
    </security:authentication-manager>

    <bean id="clientDetailsUserService" class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService">
        <constructor-arg ref="clientDetailsService"/>
    </bean>

    <bean id="clientAuthenticationEntryPoint"
          class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
        <property name="realmName" value="test/client" />
        <property name="typeName" value="Basic" />
    </bean>

    <security:http pattern="/oauth/token" create-session="stateless" use-expressions="true" authentication-manager-ref="authenticationManager">
        <security:intercept-url pattern="/oauth/token" access="isAuthenticated()" />
        <security:anonymous enabled="false" />
        <security:http-basic entry-point-ref="clientAuthenticationEntryPoint" />
        <!-- include this only if you need to authenticate clients via request
            parameters -->
        <security:custom-filter ref="clientCredentialsTokenEndpointFilter"
                                after="BASIC_AUTH_FILTER" />
        <security:access-denied-handler ref="oauthAccessDeniedHandler" />
    </security:http>

    <authorization-server client-details-service-ref="clientDetailsService"
                          xmlns="http://www.springframework.org/schema/security/oauth2" token-services-ref="tokenServices" >
        <authorization-code />
        <implicit />
        <refresh-token />
        <client-credentials />
        <password authentication-manager-ref="authenticationManager" />
    </authorization-server>

    <!-- <oauth:resource-server id="resourceFilter" token-services-ref="tokenServices" authentication-manager-ref="authenticationManager" />
 -->
    <security:authentication-manager id="authenticationManager">
        <security:authentication-provider ref="daoAuthenticationProvider">
        </security:authentication-provider>
    </security:authentication-manager>

    <oauth:client-details-service id="clientDetailsService">

        <oauth:client client-id="core-api" secret="secret"
                      authorized-grant-types="password,client_credentials,refresh_token" scope="read"
                      resource-ids="api-core" access-token-validity="36000"
                      authorities="ROLE_CLIENT,ROLE_TRUSTED_CLIENT" />
    </oauth:client-details-service>
</beans>

Resource Server Configuration:
 <mvc:default-servlet-handler />

    <mvc:annotation-driven/>
    <security:global-method-security pre-post-annotations="enabled"/>

    <!-- TODO: make an access denied view that tells me something useful -->
    <security:http  use-expressions="true"  entry-point-ref="oauthAuthenticationEntryPoint">
        <security:intercept-url pattern="/**" access="isFullyAuthenticated() and hasRole('api.core')" />
        <security:custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" />
        <security:access-denied-handler ref="oauthAccessDeniedHandler" />

        <security:anonymous />
    </security:http>

    <!-- It's just a "feature" of the Spring Security that an authentication manager is mandatory.
        so install an empty one because it isn't used at run time -->
    <security:authentication-manager/>

    <oauth:resource-server id="resourceServerFilter"  token-services-ref="tokenServices" resource-id="api-core"/>

    <bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.DefaultTokenServices" >
        <property name="tokenStore" ref="tokenStore" />
    </bean>

    <bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.store.JdbcTokenStore">
        <constructor-arg ref="dataSource" />
    </bean>

    <bean id="oauthAuthenticationEntryPoint" class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint">
        <property name="realmName" value="test/client" />
        <property name="typeName" value="Basic" />
    </bean>

    <bean id="oauthAccessDeniedHandler" class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler" />

A: Authorities are loaded when access token its required.
Using jdbc store, authorities are saved to OAUTH_ACCESS_TOKEN table, AUTHENTICATION column.
When refresh token its required, authorities are loaded from database.
If authorities changed after access token was required, you will have to implement custom token store.
Take a look to org.springframework.security.oauth2.provider.token.store.JdbcTokenStore, and extend from it.


Q: useEffect hook not firing on orientation change I am trying to change the height of a container, when in mobile landscape mode only. I am playing around in the developer tools to swap the orientation of a mobile device but it only works on the first render. I am new to react hooks so not sure if I am implementing it right.
The idea is that I am testing that once in landscape, if it's on mobile the height should be less than 450px (which is the check I am doing for the if statement)
Could someone point me in the right direction, please?
Thanks!

const bikeImageHeight = () => {
    const windowViewportHeight = window.innerHeight;
    const isLandscape = window.orientation === 90 || window.orientation === -90;
    let bikeImgHeight = 0;

    if (windowViewportHeight <= 450 && isLandscape) {
      bikeImgHeight = windowViewportHeight - 50;
    }

    return bikeImgHeight;
  };

  useEffect(() => {
    bikeImageHeight();

    window.addEventListener("resize", bikeImageHeight);

    return () => {
      window.removeEventListener("resize", bikeImageHeight);
    };
  }, []);

A: The useEffect hook is not expected to fire on orientation change. It defines a callback that will fire when the component re-renders. The question then is how to trigger a re-render when the screen orientation changes. A re-render occurs when there are changes to a components props or state.
Lets make use of another related stackoverflow answer to build a useWindowDimensions hook. This allows us to hook into the windows size as component state so any changes will cause a re-render.
useWindowDimensions.js
import { useState, useEffect } from 'react';

function getWindowDimensions() {
  const { innerWidth: width, innerHeight: height } = window;
  return {
    width,
    height
  };
}

export default function useWindowDimensions() {
  const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());

  useEffect(() => {
    function handleResize() {
      setWindowDimensions(getWindowDimensions());
    }

    window.addEventListener('resize', handleResize);
    return () => window.removeEventListener('resize', handleResize);
  }, []);

  return windowDimensions;
}

You can then use that hook in your component. Something like:
BikeImage.js
import React from 'react'
import useWindowDimensions from './useWindowDimensions'

export default () => {
  const windowDimensions = useWindowDimensions();

  // Define these helper functions as you like
  const width = getImageWidth(windowDimensions.width)
  const height = getImageHeight(windowDimensions.height)

  // AppImage is a component defined elsewhere which takes
  // at least width, height and src props
  return <AppImage  width={width} height={height} src="..." .../>
}

A: Here is a custom hook that fires on orientation change,
import React, {useState, useEffect} from 'react';

// Example usage
export default () => {
  const orientation = useScreenOrientation();
  return
{orientation}
;
}

function useScreenOrientation() {
  const [orientation, setOrientation] = useState(window.screen.orientation.type);

  useEffect(() => {
    const handleOrientationChange= () => setOrientation(window.screen.orientation.type);
    window.addEventListener('orientationchange', handleOrientationChange);
    return () => window.removeEventListener('orientationchange', handleOrientationChange);
  }, []);

  return orientation;
}

Hope this takes you to the right direction.

A: You need to trigger a re-render, which can be done by setting state inside of your bikeImageHeight.
  const [viewSize, setViewSize] = useState(0)

    const bikeImageHeight = () => {
        const windowViewportHeight = window.innerHeight;
        const isLandscape = window.orientation === 90 || window.orientation === -90;
        let bikeImgHeight = 0;

        if (windowViewportHeight <= 450 && isLandscape) {
          bikeImgHeight = windowViewportHeight - 50;
        }
        setViewSize(bikeImgHeight)
        return bikeImgHeight;
  };

And per the comments conversation, here's how you'd use debounce:
function debounce(func, wait, immediate) {
    var timeout;
    return function() {
        var context = this, args = arguments;
        var later = function() {
            timeout = null;
            if (!immediate) func.apply(context, args);
        };
        var callNow = immediate && !timeout;
        clearTimeout(timeout);
        timeout = setTimeout(later, wait);
        if (callNow) func.apply(context, args);
    };
};

const YourComponent = () => {

  const bikeImageHeight = () => {
    const windowViewportHeight = window.innerHeight;
    const isLandscape = window.orientation === 90 || window.orientation === -90;
    let bikeImgHeight = 0;

    if (windowViewportHeight <= 450 && isLandscape) {
      bikeImgHeight = windowViewportHeight - 50;
    }
    setViewSize(bikeImgHeight)
    return bikeImgHeight;
  };

  const debouncedBikeHeight = debounce(bikeImageHeight, 200)

  useEffect(() => {
    bikeImageHeight();

    window.addEventListener("resize", debouncedBikeHeight);

    return () => {
      window.removeEventListener("resize", debouncedBikeHeight);
    };
  }, []);

  return
some jsx

}

Example debounce taken from here: https://davidwalsh.name/javascript-debounce-function