text:
Q: Decompress .gz file from Azure blob in r I want to read a .csv.gz from a Azure blob container, but I am struggling with the .gz format. When I download the file local and then read it in R with readr it works fine. But when I try to read it from Azure the file isn't read propperly. It seems that the file is not decompressed. This is the code I used to read the file local (also read_csv2 works fine):
df<-read_delim("filename.csv.gz", delim=";",col_names=c('epoch','SegmentID','TT','Speed','LoS','Coverage'),
                    col_types=cols(epoch = col_integer(),SegmentID = col_integer(),TT = col_integer(),Speed = col_integer(),LoS = col_integer(),Coverage = col_integer()))

And this is what I try to do to reach the file from Azure:
blob_urls_with_sas<-paste("https://name.blob.core.windows.net","/container/filename.csv.gz",
                          sas_token, sep="")
dfAzure<-read_delim(blob_urls_with_sas,delim=";",
col_names=c('epoch','SegmentID','TT','Speed','LoS','Coverage'),
                col_types=cols(epoch = col_integer(),SegmentID = col_integer(),TT = col_integer(),
                               Speed = col_integer(),LoS = col_integer(),Coverage =col_integer()))

or from the AzureStor package
test <- storage_read_delim(cont, "filename.csv.gz",delim=";",
col_names=c('epoch','SegmentID','TT','Speed','LoS','Coverage'),                           col_types=cols(epoch = col_integer(),SegmentID = col_integer(),TT = col_integer(),
                       Speed = col_integer(),LoS = col_integer(),Coverage = col_integer()))

A: One option would be to use fread() from data.table which naturally handles .gz files. Make sure you install R.utils first.


text:
Q: How to union two tables A and B but B has one column missing while the result should have all the columns? I have A table (P1, P2, P3) and B table (P1, P2), now I want to union them together. I know I can do something like
SELECT P1, P2 FROM A
UNION
SELECT P1, P2 FROM B
to merge all the rows. But in the result I have to get P3 too and for rows coming from B P3 should be null, how can I do this?

A: (SELECT P1, P2,P3 FROM A)
UNION ALL
(SELECT P1, P2,null FROM B)

check http://sqlfiddle.com/#!9/32f84/2

redpajama_set_name: RedPajamaStackExchange


text:
Q: Extra de-limiter caused data to shift to the right 1 column So I was given a .csv file, and unfortunately one of the field's sometimes contains a customer name in the format lastname, firstname which is throwing off the data. Fortunately, I can detect when this happens because one of the columns that is getting shifted has a fixed value. An example:
Good row:
[New Contact!]  [phonenumber]   5939262 [Unknown]   2000    5083    5083

Bad row:
[lastname]  [firstname] [phonenumber]   2800    [Unknown]   2000    5061    5061

So if the 5th column = [Unknown], I know that the the columns need to be shifted left for that row. The first column contains data that is not being used, so if I lose the name I don't care, it's just the numbers.
Is there any easy way to do this without regenerating the data?

A: You can try this macro to fix the file after the import:
Sub fixIt()
    Dim r As Range
    For Each r In Worksheets("Sheet1").UsedRange.Rows ' <-- put the right sheet name here
        If WorksheetFunction.CountA(r) > 7 Then r.value = r.Offset(, 1).value
    Next
End Sub


text:
Q: how to pass var inside callback request i need to pass the var "surl", inside the callback request. I trying to do this, but the function start is called many times, and it changes surl value before the request gets done.
function start(bd){
    if(bd.length > 0){
        var zzz = bd.length-1;
        var sowner = bd[zzz].owner;
        var surl = bd[zzz].url;
        request({
            url: 'https://myurlapi/'+bd[zzz].owner+bd[zzz].url,
            followRedirect: false
        }, function (error, response, body, surl) {
            console.log(surl);
        });
    }
}

the surl var must to be passed exactly in the moment that the request is called, not when it is done.

A: Try renaming the argument surl in your callback function to something else:
}, function (error, response, body, newUrl) {
           console.log(surl);
});


text:
Q: Java Date.toString in Oracle's TO_DATE The default format for Date.toString() seems to be, in an US locale, something like:
Thu Nov 24 15:20:52 CET 2016

Oracle database has a function "TO_DATE" that allows convert from string to date. First argument is the date format.
Which is the correct date format to map a Java Date.toString() string? Is it:
DAY MONTH DD HH24:MI:SS TZD YYYY

?
Thanks.

A: An Oracle DATE data type does not have a time zone - you need a TIMESTAMP WITH TIMEZONE data type:
SELECT TO_TIMESTAMP_TZ(
         'Thu Nov 24 15:20:52 CET 2016',
         'DY MON DD HH24:MI:SS TZR YYYY'
       )
FROM DUAL

If you want to convert to a DATE (and the time zone region is always CET) then you can use:
SELECT TO_DATE(
         'Thu Nov 24 15:20:52 CET 2016',
         'DY MON DD HH24:MI:SS "CET" YYYY'
       )
FROM DUAL

If you want it as a DATE data type and to respect the time zone in the original string then you will need to (1) convert it to a TIMESTAMP WITH TIMEZONE data type; (2) convert that value to a standardized time zone (UTC is often used for this); then (3) convert that to a date:
SELECT CAST(
         TO_TIMESTAMP_TZ(
           'Thu Nov 24 15:20:52 CET 2016',
           'DY MON DD HH24:MI:SS TZR YYYY'
         )
         AT TIME ZONE 'UTC'
         AS DATE
       )
FROM   DUAL;

Which will output the date 2016-11-24 14:20:52 (the UTC representation of the input date).

A: In Java, default Date format with toString() method is EEE MMM dd HH:mm:ss zzz yyyy. I don't know why but Oracle doesn't supports parse syntax 'EEE','MMM' and 'zzz' .
Read more : Table 9-4 Datetime Format Elements


text:
Q: Why does MSVC (Visual C++) need separate dllimport and dllexport attributes and gcc not? I know why and when __declspec(dllimport) and __declspec(dllexport) are used in Visual C++.
I know the GCC alternative to both __declspec(dllimport) and __declspec(dllexport) is __attribute__((visibility("default"))).
I'm just wondering why Visual C++ does need both commands, while GCC is able to figure out itself whether it should import or export the symbol?
Are there some disadvantages of the GCC approach, f.ex. by exporting (templated/inlined) functions that should have been imported instead?
Of course the easy answer is: "It's a design choice of GNU/Microsoft", maybe it's the only answer. Thank you for your input!

A: I don't have the knowledge to elaborate on the internals of gcc but you can experiment yourself noticing that both gcc/llvm, when compiling with -fvisibility=hidden, will export symbols in the shared library text section (T type symbol in nm -gD command output) only for the ones where the visibility("default") is restored and the method/type is properly defined within the library boundary. Users of such library (such as other shared libraries) will not re-export those in the text section, even if they are decorated with default visibility, but will just manifest their use as undefined symbols (U type symbols in nm output). gcc/llvm clearly has the information at linking time to determine which table the symbol must be written in, distinguishing between (using the MSVC terminology) export and import usage. It's also important to observe that some features, such as RTTI, may not work properly if symbols are accessed with inconsistent linkage, so it's better that the default visibility attribute is always present in the library headers.


text:
Q: Argparse to show usage help for subcommand Consider this arg_test.py script:
#!/usr/bin/env python3

import argparse

parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(help='subcommand help')

# create the parser for subcommand
parser_a = subparsers.add_parser('do-stuff', help='Help for do-stuff subcommand')

args = parser.parse_args()

With the help for the subcommand I get:
./arg_test.py do-stuff -h
usage: arg_test.py do-stuff [-h]

optional arguments:
  -h, --help  show this help message and exit

How can I add some usage description when using -h? For example I would like to get:
./arg_test.py do-stuff -h
usage: arg_test.py do-stuff [-h]

This subcommand does awsome stuff       << HOW DO I ADD THIS?

optional arguments:
  -h, --help  show this help message and exit


text:
Q: How to build .NET SDK from source How to compile .NET SDK from source?
When I run build.sh, I get a message that the package is being downloaded (I don't understand why, since the goal is to compile).
I get a 404 error while downloading and then this:
    dotnet_install: Error: Could not find/download: `.NET Core Runtime` with version = 1.0.5
dotnet_install: Error: Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support

A:
When I run build.sh, I get a message that the package is being downloaded (I don't understand why, since the goal is to compile)

That's normal. You are trying to compile the SDK, which is itself written in C#. You need a C# compiler (such as the one included in the .NET SDK) to compile the SDK itself.
That's not too different from a C/C++ compiler (such as gcc) requiring a C/C++ compiler to build.
I guess the biggest difference is that the required compiler is downloaded automatically instead of failing and asking the user to install the compiler manually.

dotnet_install: Error: Could not find/download: `.NET Core Runtime` with version = 1.0.5
dotnet_install: Error: Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support

That's definitely a bug in the SDK build system. I see that you have reported it here: https://github.com/dotnet/sdk/issues/14966. This needs to be fixed by the SDK developers.


text:
Q: Using Retrofit getting response with http code 200 but empty body I am using Retrofit for the first time, after the login validation I run my retrofit api call function loginApiCall to verify the user.
I got the response 200 even if my validation are wrong(email and password wrong), but getting the true result of this check response.isSuccessful() in response.
private void loginApiCall() {
    Call<LoginResponse> call = RetrofitClient
            .getInstance().getApi().userLogin("*******@gmail.com", "****");
    call.enqueue(new Callback<LoginResponse>() {
        @Override
        public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
            if (response.isSuccessful())
                Toast.makeText(LoginScreen.this, "Success", Toast.LENGTH_SHORT).show();
            else
                Toast.makeText(LoginScreen.this, "no Success", Toast.LENGTH_SHORT).show();
        }
        @Override
        public void onFailure(Call<LoginResponse> call, Throwable t) {
            Toast.makeText(LoginScreen.this, "Failed", Toast.LENGTH_SHORT).show();

        }
    });
}

Here Retrofit setup for my calls
public class RetrofitClient {

private static RetrofitClient mInstance;
private Retrofit retrofit;
private RetrofitClient() {
    OkHttpClient okHttpClient = new OkHttpClient.Builder().build();

    retrofit = new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .client(okHttpClient)
            .build();
}

public static synchronized RetrofitClient getInstance() {
    if (mInstance == null) {
        mInstance = new RetrofitClient();
    }
    return mInstance;
}

public QareebApiInterface getApi() {
    return retrofit.create(QareebApiInterface.class);
}

here is Interface for POST
public interface QareebApiInterface {
@FormUrlEncoded
@POST(WebServiceConstant.END_POINT_NEW_USER)
Call<LoginResponse> userLogin(
        @Field("email") String email,
        @Field("password") String password
);
}

Here is gradle files related to retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'

I have converted volley call to retrofit where only username and password was sending to the server (There is no Auth). Is there any issue of auth as i am not sending or missing anything? but if missing why response is 200?
Following is the volley call(which is working fine) which i replaced with retrofit.
public void  loginApiCall(final String email, final String password) {

    RequestQueue queue = Volley.newRequestQueue(this);
    StringRequest postRequest = new StringRequest(Request.Method.POST, BASE_URL,
            new com.android.volley.Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.d(TAG, "onResponse: "+response);
                }
            },
            new com.android.volley.Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {

                }
            }
    ) {
        @Override
        protected Map<String, String> getParams() {

            Map<String, String> params = new HashMap<String, String>();
            params.put("email", email);
            params.put("password", password);
            return params;
        }
    };
    queue.add(postRequest);
}

A: You need to add logging to see real response
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient okHttpClient = new
OkHttpClient.Builder().addInterceptor(interceptor).build();

It's can be 200 with error description

A: I've the same issue and on okhttp I see my JSON response.
It seems an issue on GSON parsing but can't fix it.
On debug the response is populated except that the body


text:
Q: Generate JsonSchema and validate with swagger request and response models I have swagger files with  OAS3 and OAS2. With these swagger file I want to generate Jsonschema for API response and request payloads. So that when I invoke the API, I want to check if the API response is valid/invalid against the generated schema.Similarly when I pass the request payload, I want to valid if the request payload is valid/invalid against generated json schema.
Is there any Java library that can read the swagger OpenAPI specs and generate Jsonschema for request and response payloads?


text:
Q: There should be a better way to write the code which will not throw NoMethodError, i am stuck There should be a better way to write the code which will not throw NoMethodError, I am stuck.
My stack trace
# NoMethodError · undefined method `account' for nil:NilClass

def email_talent_match_only_one(talent, match)
  @talent = talent
  @position = match.position
  @account = match.position.account

  if @account.present? and @talent.present?
  # ...
end

A: This is a fairly common error in Ruby. When you're trying to retrieve the account match.position is returning nil. You are then trying to call account on NilClass which is causing the error.
If this is expected you may want to use the &. syntax or the try method which will return nil rather than throw an error.
@account = match.position&.account
# or
@account = match.position.try(:account)


text:
Q: How do you resize a screen (or "canvas") in Expression Blend +Sketchflow? You can't select the actual "Screen" by clicking on it in the designer.  Even if you have no other elements added.  If you add any element, you get the typical resize behavior you would expect, but since you cannot select the screen, you cannot resize it or even view the properties.

A: You are able to select the screen in the "Objects and Timeline" list.  Once you do, you get the expected resize handles and can even view the properties using the tab on the right and resize it manually there.


text:
Q: Why does my recursive function print in descending order and then in ascending order? I have a simple recursive c++ program and I am trying to understand exactly how it works. I understand why the program prints out 3 2 1, but then I don't understand why it goes the other way and prints 1 2 3. I used a hand-simulation and walked through the program step-by-step but still don't understand how the 1 2 3 comes about. I found this article from GeeksForGeeks but am still having difficulty grasping the concept. Any explanation would be awesome.
#include <iostream>

using namespace std;

void test(int n)
{
  if (n > 0)
  {
    cout << n << " ";
    test(n - 1);
    cout << n << " ";
  }
}

int main()
{
  test(3);
  return 0;
}

A: The order of function calls in your recursion looks something like this:
test(3)
-- cout << 3 << " ";
-- test(2)
-- -- cout << 2 << " ";
-- -- test(1)
-- -- -- cout << 1 << " ";
-- -- -- test(0)
-- -- -- cout << 1 << " ";
-- -- cout << 2 << " ";
-- cout << 3 << " ";

A: Change your program to
#include <iostream>

using namespace std;

void test(int n)
{
  if (n > 0)
  {
    cout << "enter" << n << " ";  // <- add "enter" here
    test(n - 1);
    cout << "exit" << n << " ";   // <- add "exit" here
  }
}

int main()
{
  test(3);
  return 0;
}

and you will see next output
enter3 enter2 enter1 exit1 exit2 exit3

You can think about recursive calls as operations with a stack.
There are two operations: push and pop.
What your program does is
push test 3
push test 2
push test 1
pop test 1
pop test 2
pop test 3

On every push and pop you do cout and thus see the output 3 2 1 1 2 3.
Here you can find more about recursion.

A: The thing is that all the answers don't help you because even if someone got it explained to you, you will stuck in the next algorithm.
I am offering a fundamental approach that helped me a lot with understanding some search algorithms, linked lists, binary trees and much more because I am a simple mind.
What you have to do is figuring out ways to represent the data in the most creative ways you can come up with. Because programming is just flipping data in lots of ways. A few examples I came up with is using plastic cans and post its or grapes and plates, I've seen some indian video guys that draw the data flow on charts or just with circles on a sheet of paper with different colors if you want
and that works as follows:

*

*put the data on the post its, one for each round. You got a simple algorithm and I would write a "3" because it is passed through the function.

*The jars, represent the function calls, I would take a jar for every call.

*Simulate the algorithm bit by bit. Like taping the 3 on the jar -> first cout "3" -> test get called "n - 1" so "2" goes in a new jar (writing 2 on the post it)
-> second cout "2" -> test get called "n - 1" so 1 goes again in a new jar. (writing 1 on the post it)
->third cout "1" -> test get called "n - 1" so 0 goes in a new jar. (writing 0 on the post it) - but wait! 0 is not bigger as 0! So that jar won't pass the if command! so the test doesn't gets called again - function over.
Now look at your place! you got still 4 jars and the second cout in the function is not even called once - now its time because every jar represents one function call that is not finished and still open. what number is in the jar you put in last? Right, a 1! So "1" get to the cout. Crumple the post it, put the jar back. What is in the next jar? a "2"? bingo - that is printed through the second cout. The last cup has a 3 in it? - right, print it with cout than crumple the post it up. No cups anymore? No data to print out? you done!
Thats how the program works!
Congrats, because I am sure you grasped it now! :)

Btw. if you come to a point where you don't know where the data flows, every good IDE has a debugger that let you run exactly the steps the program does and it stops after every step. It is really good explained how to use a debugger in alex allain "jump to c++" and he has a whole chapter on how to read and write a program, also a whole chapter about recursion and i think 6 for pointers alone. He gave the tip to find ways to represent data and I hope that helps you as much as it helped me :)
Cheers

A: It's because you have the cout statement after calling the "test" method in your if-statement. After it walks down all the method calls and hits the base case, it then returns out of each of those method calls moving on to the next line (the cout statement) in the reverse order the methods got called in.

A: To make it clear rewrite the function
void test( unsigned int n )
{
    if ( n )
    {
        std::cout << n << " ";
        test( n - 1 );
        std::cout << n << " ";
    }
}

the following way
void test( unsigned int n )
{
    if ( n )
    {
        std::cout << n << " ";
        std::cout << n << " ";
        test( n - 1 );
    }
}

That is move the second statement
std::cout << n << " ";

above the statement
test( n - 1 );

For the call test( 3 ); of the modified function you will get the following output
3 3 2 2 1 1

So each recursive call of the function two times outputs the passed value n. I hope it is clear because the function explicitly contains the same statement two times
std::cout << n << " ";
std::cout << n << " ";

Now returning to the original function definition we see that between the two outputs of the same value n the function calls itself with the value n - 1.
So each function call outputs the same value two times but between the outputs the function calls itself recursively.
Now the output can look like
3         3
     |
call itself for 2

... and so on.


text:
Q: Cannot open files or folders in MacOS shared Folder created from Ubuntu: permission denied I have created a shared folder on my macOS computer that I wanted to have my Ubuntu machine be able to connect to.  I am able to access the shared folder from my Ubuntu machine; however, when I create a folder or file from my Ubuntu machine in the shared folder and I attempt to open it on my MacOS I receive a permission denied error.
I am no issues accessing folders and files from the Ubuntu machine created by the MacOS so I'm not sure what the issue might be.


text:
Q: Should I use self-signed certificates in general? For SVN in particular? How secure is it to use self-signed certificates?  As far as I understand it, an attacker could pretend to be my server if I don't have a certificate from an authority.  Is this much of a risk?
Should I buy a certificate for Subversion?

A: There's no real harm in using self signed certs for in house projects as long as everyone is aware. From a security standpoint you may want to distribute the cert to your users so that they can ensure it's valid when they make the initial connection. There's no reason to pay for a cert in this case. A self signed cert provides the same level of cryptographic protection as a paid cert it just isn't automatically trusted by the client program.


text:
Q: Converting nested JSON to CSV - specifically an object containing necessary values for each record and an array of values I want to parse out a set of CSV records from JSON.
The JSON looks like this:
{
   "orderbookSnapshotItem":{
      "exchange":"WhirlyGig",
      "contract":"OptimalSpring",
      "bidPrice":[
         {
            "price":"47.205",
            "counterparty":"WhirlyGig",
            "quantity":"10",
            "allOrNothing":"false",
            "timestamp":"2023-03-02T11:52:36.554Z",
            "orderId":"0",
            "implied":"false"
         },
         {
            "price":"47.200",
            "counterparty":"WhirlyGig",
            "quantity":"5",
            "allOrNothing":"false",
            "timestamp":"2023-03-02T11:52:36.554Z",
            "orderId":"0",
            "implied":"false"
         }
      ],
      "askPrice":[
         {
            "price":"47.295",
            "counterparty":"WhirlyGig",
            "quantity":"10",
            "allOrNothing":"false",
            "timestamp":"2023-03-02T11:52:36.554Z",
            "orderId":"0",
            "implied":"false"
         },
         {
            "price":"47.300",
            "counterparty":"WhirlyGig",
            "quantity":"25",
            "allOrNothing":"false",
            "timestamp":"2023-03-02T11:52:36.554Z",
            "orderId":"0",
            "implied":"false"
         }
      ],
      "qtyDecimals":"0",
      "contractTitle":"Ancient Greek LPG - Apr23",
      "instrumentName":"GDP"
   }
}

No header line is required, I intend to specify all fields required with jq.
I want to unbundle each orderbookSnapshotItem into a set of records which each look like:
  "ICE",
  "TFM FMJ0023!",
  "0",
  "Dutch TTF Natural Gas Futures - TTF - Apr23",
  "TFM",
  "47.295",
  "ICE",
  "10",
  "false",
  "2023-03-02T11:52:36.554Z",
  "0",
  "false"
  "47.295",
  "ICE",
  "10",
  "false",
  "2023-03-02T11:52:36.554Z",
  "0",
  "false"

Or more exactly, as a CSV with no header, but if there was one it would be like this:
exchange,contract,qtyDecimals,contractTitle,instrumentName,bidprice,bidcounterparty,bidquantity,bidallornothing,bidtimestamp,bidorderid,bidimplied,askprice,askcounterparty,askquantity,askallornothing,asktimestamp,askorderid,askimplied

I have got quite a long way however it's just not right and I am struggling. I would be so very grateful if someone would point me in the right direction. It's approaching 01:00am and I can see I am not getting single lines containg both bid & ask but extra lines.
Below is my lamentable jq script.
.orderbookSnapshotItem as $parent | $parent | [.exchange as $ex | .contract as $con | .qtyDecimals as $decimals | .contractTitle as $title | .instrumentName as $name | $parent | .bidPrice[] | $ex, $con, $decimals, $title, $name, .price,.counterparty,.quantity,.allOrNothing,.timestamp,.orderId,.implied | $parent | .askPrice[] | $ex, $con, $decimals, $title, $name, .price,.counterparty,.quantity,.allOrNothing,.timestamp,.orderId,.implied]

Thank you for looking.

A: If this isn't exactly what you're after, it will hopefully set you on the right path:
# input: an object, the source of the values
# $obj: an object, the source of the relevant keys
# output: an array
def array($obj):
  . as $in | [$obj|keys_unsorted[] as $k | $in[$k]];

({} | {price,counterparty,quantity,allOrNothing,timestamp,orderId,implied}) as $fields
| .orderbookSnapshotItem
| [.exchange,.contract,.qtyDecimals, .contractTitle, .instrumentName]  as $common
| range(0; .bidPrice|length) as $i
| ($common + (.bidPrice[$i] | array($fields)) + (.askPrice[$i] | array($fields)))
| @csv


text:
Q: Строка как условие python если возможность задавать условие оператору IF другим условным оператором IF?
    if fotel.isdigit() == True:
        findzn = 'fotel[-10:].find(tel[-10:])>-1'
    else:
        findzn = 'SequenceMatcher(lambda x: x==" ", fotel, gosno).ratio > 0.8'
    if (findzn) :
        .........

Что-то типа этого. Необходимо для поиска в базе данных в зависимости от их типа.


text:
Q: Refresh UIImageView's Image I have a question that has probably been asked a lot, but I just can't get it. I'm making an iOS tabbed app with Swift 5 and Xcode 11. I have a background UIImageView that changes the image every time a user presses a button. The image actually displays pretty well, there's just one thing: The background image doesn't change, it just takes the previous image. Here's my code:

    func theme(){
        let backgroundImage = UIImageView(frame: self.view1.bounds)
        backgroundImage.autoresizingMask = [.flexibleHeight, .flexibleWidth]
        self.view1.insertSubview(backgroundImage, at: 0)
        if UserDefaults.standard.integer(forKey: "like") == 1{
            backgroundImage.image = nil
            backgroundImage.image = UIImage(named: "img1")
            self.tabBarController?.tabBar.barTintColor = UIColor(red:0.84, green:0.84, blue:0.84, alpha:1.0)
            self.tabBarController?.tabBar.tintColor = UIColor(red:0.21, green:0.56, blue:0.96, alpha:1.0)
            ansView.backgroundColor = UIColor.white
            historyButton.backgroundColor = UIColor.black
            for button in operatorButtons {
                button.backgroundColor = UIColor.black
            }
            for button in numberButtons {
                button.backgroundColor = UIColor(red:0.53, green:0.52, blue:0.53, alpha:0.5)
            }
            equalButton.backgroundColor = UIColor(red:1.00, green:0.49, blue:0.18, alpha:1.0)
            self.view.backgroundColor = UIColor(red:0.78, green:0.78, blue:0.78, alpha:1.0)
            view1.contentMode = UIView.ContentMode.scaleAspectFill
        }else if UserDefaults.standard.integer(forKey: "like") == 2{
            self.tabBarController?.tabBar.barTintColor = UIColor.black
            self.tabBarController?.tabBar.tintColor = UIColor(red:0.98, green:0.64, blue:0.02, alpha:1.0)
            backgroundImage.image = nil
            backgroundImage.image = UIImage(named: "img2")
            ansView.backgroundColor = UIColor(red:0.53, green:0.52, blue:0.53, alpha:1)
            historyButton.backgroundColor = UIColor(red:0.00, green:0.00, blue:0.00, alpha:0.9)
            for button in operatorButtons {
                button.backgroundColor = UIColor(red:0.00, green:0.00, blue:0.00, alpha:0.9)
            }
            for button in numberButtons {
                button.backgroundColor = UIColor(red:0.53, green:0.52, blue:0.53, alpha:0.5)
            }
            equalButton.backgroundColor = UIColor(red:0.53, green:0.52, blue:0.53, alpha:0.5)
            self.view.backgroundColor = UIColor.black
            view1.contentMode = UIView.ContentMode.scaleAspectFill
        }else if UserDefaults.standard.integer(forKey: "like") == 3{
            self.tabBarController?.tabBar.barTintColor = UIColor(red:0.78, green:0.75, blue:0.90, alpha:1.0)
            self.tabBarController?.tabBar.tintColor = UIColor(red:0.51, green:0.44, blue:0.78, alpha:1.0)
            view1.backgroundColor = UIColor(patternImage: UIImage(named: "ing3")!)
            ansView.backgroundColor = UIColor(red:1.00, green:1.00, blue:1.00, alpha:0.5)
            historyButton.backgroundColor = UIColor(red:0.60, green:0.54, blue:0.82, alpha:1.0)
            for button in operatorButtons {
                button.backgroundColor = UIColor(red:0.60, green:0.54, blue:0.82, alpha:1.0)
            }
            for button in numberButtons {
                button.backgroundColor = UIColor(red:1.00, green:1.00, blue:1.00, alpha:0.5)
            }
            equalButton.backgroundColor = UIColor(red:0.51, green:0.44, blue:0.78, alpha:1.0)
            self.view.backgroundColor = UIColor(red:0.78, green:0.75, blue:0.90, alpha:1.0)
            view1.contentMode = UIView.ContentMode.scaleToFill
        }
    }

The above code was my theme function, which I call every time the view appears.
As you see above, I have tried
backgroundImage.image = nil

But it didn't work for me. I have also searched stack-overflow for similar questions, but it was no use. Any help is appreciated

A: In the third condition you forgot to set image or it's intentionally ?
And there is no need to set nil before replacing the new image.


text:
Q: Getting Data in Power BI from Oracle Apex application backend tables I was wondering if it is possible to connect the Oracle Apex's data tables in Microsoft Power BI.
Please note that these tables are the ones used in backend of web applications developed and hosted on Oracle Apex website/cloud https://apex.oracle.com (=NOT on-premises).

A: Oracle does not provide database connection information for the database used for https://apex.oracle.com. You can create REST APIs exposing information in the tables and use that information.


text:
Q: Option selected not work in IE9 Simple code:

Sort by
   <select id="cmp_sort">
        <option value="original" selected="selected">original</option>
        <option value="name">name</option>
   </select>

In all browsers, including ie7-8, after loading page default value in combobox is "original". But IE9 show nothing (empty line). When i press on that line i'll receive "original/name" as i needed.
I try to do  $("cmp_sort").val("original") on document.load, but its not help. However, when i execute this code in console, all works fine. What should i do? Thanks.

A: You need to provide the hash tag:
$("#cmp_sort").val("original")
$("cmp_sort") will look for any html tags called cmp_sort, which don't exist.


text:
Q: Calculating percentile buckets and appending them to an existing table in R I am working with a dataset of around 8500 lines in R and have one column with data ranging from -1000 to 25. I need to calculate what percentile relative to the column the value in each row is and append this value in an adjacent cell. Basically, I need to add another column to the table with the corresponding percentile for each value. Multiple values can have the same percentile (ie: 20.1 and 20.2 will both be in the 99th percentile).
Can anyone help me figure out how to do this? I managed to make a table that tells the cutoff for each percentile but the cuttoffs do not exactly match with my data and therefore I cannot merge the tables by.x, by.y etc.

A: The function ecdf can be used to compute the percentiles :
x = runif(8500, -1000, 25)
Fn = ecdf(x)
percentiles = Fn(x)


text:
Q: Pandas - Compare 2 columns in a dataframe and return count DataFrame:

I want to compare these 2 columns and extract the count of matched and un matched rows.
result will be like
Matched = 3
Un matched = 2

A: try this:
import pandas as pd
df = pd.DataFrame(data={'input_number':[123,253,458,479,1564],'org_number':[1234,253,458,478,1564]})
matched, un_matched = df[df['input_number']==df['org_number']].shape[0],df[df['input_number']!=df['org_number']].shape[0]
print("Matched = {}\nUn matched = {}".format(matched,un_matched))

A: Compare values first by Series.eq and count by Series.value_counts, then replace True, False indices:
s = (df.input_number.eq(df.org_number)
                    .value_counts()
                    .rename({True:'mach', False: 'no match'}))

If need DataFrame:
sdf1 = (df.input_number.eq(df.org_number)
                       .value_counts()
                       .rename({True:'mach', False: 'no match'})
                       .rename_axis('state')
                       .reset_index(name='count'))

A: Another way, boolean index, conditionally allocate match status. Thereafter get_summies and sum down the columns. Code below
pd.get_dummies(np.where(df['code_207']==df['code_207a'],'matched','unmatched')).sum(0)


text:
Q: Deploying .NET Core in IIS without publishing manually I have a number of services which run via IIS and that are worked on daily.  On my local machine these are run via IIS.  When I was using .NET Framework this was easy, I would point to the source folder and it just worked.  Now with .NET Core I must manually "publish" every time I make a change.  Is there some way to automatically publish when I build or when changes are made?

A: You can create an Azure Devops (VSTS) account and configure build and release triggers.
This will basically pull your repository every-time you push to certain branch and then follow the build and release process you configured to deploy your solution to your IIS.
Here is a link with some more details to help you : https://medium.com/@taithienbo/build-and-deploy-an-asp-net-core-app-running-on-iis-using-azure-pipelines-e675041f62d4


text:
Q: Rails 4 - will_paginate This is my first attempt using will_paginate (I know! Where have I been??)
titles_controller.erb
  def index
    @titles = Title.active.sorted.paginate(:page => params[:page])
  end

index.html.erb
<% will_paginate @titles.each do |title| %>

Error:
undefined method `total_pages' for #<Enumerator:0x00000002bacaf0>

WTF am I doing wrong?  Thanks in advance.

A: In your case you dont acctually need to write:
<%= will_paginate @titles %>

Because it is in the context of the title_controller, will_paginate will assume their is a @titles variable available. Thus it is possible to just write:
<%= will_paginate %>

A: Please read will paginate docs. You need to write:
<%= will_paginate @posts %>

There is no need for adding each.
So entire view would look like:
<% @titles.each do |title| %>
  <!-- do smth with title -->
<% end %>

<%= will_paginate @titles %>


text:
Q: How to define an empty set with axiom of subsets in coq I have an axiom
Parameter set : Type.
Parameter IN : set->set->Prop.

Axiom AXIOM_OF_SUBSETS :
  forall prop x, exists y, forall u,
    IN u y <-> IN u x /\ (prop u)
.

Now I would like to build an empty set out of this, like
Definition EMPTYSET : set.
  Check (AXIOM_OF_SUBSETS (fun _ : set => False) x).

The result of Check is:
AXIOM_OF_SUBSETS (fun _ : set => False) x
     : exists y : set,
         forall u : set, IN u y <-> IN u x /\ False

Is there a way to define an EMPTYSET in this situation?

I have found a very simple, but dangerous solution for this:
Just change Parameter set : Type. to Parameter set : Prop..
It worked well at least for axioms, lemmas and theorems that I have written so far.
Will this be the right way to resolve the issue for the rest of the program?

For the problem right above, refer to the https://github.com/coq/coq/wiki/Prop_or_Set .

A: I take it that you want to formalize Zermelo-Fraenkel set theory in Coq. There are two issues with your code:

*

*In order to apply your axiom, you need to have some set lying around. (Your code mentions a variable x that is not defined anywhere.) One popular option is to combine the axiom of subsets with another axiom that guarantees the existence of some set, such as the axiom of infinity.  If you go this way, you need to declare this axiom explicitly.

*Coq does not allow the axiom of choice by default.  As a result, it is not possible to extract a witness of an existence proof, and to define EMPTYSET based on the proof term you gave.  You can solve this issue by either assuming the axiom of choice (check singleton_choice in Coq.Logic.ClassicalChoice (https://coq.github.io/doc/master/stdlib/Coq.Logic.ClassicalChoice.html)), or by slightly changing your formulation of your axiom to avoid the existential quantifier.
Axiom set : Type.
Axiom In : set -> set -> Prop.
Axiom comprehension : (set -> Prop) -> set -> set.
Axiom comprehension_spec :
  forall prop x u, In u (comprehension prop x) <-> In u x /\ prop u.


text:
Q: TabWidget - How to set position of indicator text? i'm trying to use TabHost and TabWidget in my Android application. This is my layout main.xml:
<TabHost
    android:id="@+id/mainTabHost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="65px"/>
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <LinearLayout
            android:id="@+id/contentTags"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical">
        </LinearLayout>
        <LinearLayout
            android:id="@+id/contentPreferences"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical">
        </LinearLayout>
    </FrameLayout>
</TabHost>

And my code:
final TabHost mainTabHost = (TabHost) this.findViewById(R.id.mainTabHost);
mainTabHost.setup();
final TabHost.TabSpec tabSpecTags = mainTabHost.newTabSpec("tabTags");
tabSpecTags.setIndicator(this.getString(R.string.tab_name_tags));
tabSpecTags.setContent(R.id.contentTags);
mainTabHost.addTab(tabSpecTags);
final TabHost.TabSpec tabSpecPreferences = mainTabHost.newTabSpec("tabPreferences");
tabSpecPreferences.setIndicator(this.getString(R.string.tab_name_preferences));
tabSpecPreferences.setContent(R.id.contentPreferences);
mainTabHost.addTab(tabSpecPreferences);

The problem is that i do not want my tabs to be so tall (65px). However, if i set the layout_height of the TabWidget to e.g. 30px, i can't see the tab labels (indicator) on the tabs at all.
Seems like there is a "minimum required" height for the TabWidget (65px?) and the indicator is positioned at the bottom of this 65px?
Is there a way to adjust the positioning of the indicator?
Thanks!

A:
However, if i set the layout_height of
  the TabWidget to e.g. 30px, i can't
  see the tab labels (indicator) on the
  tabs at all.

Note that the techniques for doing this won't necessarily be reliable in future Android releases, if they change up how a TabHost is constructed.

Is there a way to adjust the
  positioning of the indicator?

Starting with API Level 4 (a.k.a., Android 1.6), TabHost.TabSpec accepts a View as the indicator via setIndicator(). I haven't tried it, but it may give you greater control over the layout of an individual tab's indicator.

A: i see...
when u addTab, usually we use setIndicator like this:
QTabHost.addTab(QTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").bla bla....
u can use TextView to replace "TAB 2", became like this:
tview=new TextView(this);
tview.setText("Title here");
QTabHost.addTab(QTabHost.newTabSpec("tab_test2").setIndicator(tview).bla bla....
all u need is just modify the textview.
Thanks... ^^

A: int iH = getTabWidget().getLayoutParams().height;

for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
            tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = iH;
        }

A: for (int i = 0; i < 4; i++) {
    tabhost.getTabWidget().getChildAt(i).getLayoutParams().height = 50;
}

by using this we can do very easily


text:
Q: Having problems when removing duplicates So I am trying to remove duplicates from an array. The array is made from strings.
$string = "B+,A,A,A+,C,B,B,";
$okay = explode(",", $string);
array_pop($okay);
$newarray = array_unique($okay);
for ($x = 0 ; $x < count($newarray) ; $x++) {
  echo $newarray[$x];
}

However, when I try to run it, for some reason, it says the following:
Warning: Undefined array key 2 in Standard input code on line 14
I do not know what is causing this. I think that array_unique just removes that element at that space, hence $newarray[2] is undefined. If so, are there any ways that I can use to display the new array properly?

A: Instead of using:
for ($x = 0 ; $x < count($newarray) ; $x++) {
  echo $newarray[$x];
}

you could use:
foreach ($newarray as $value) {
  echo $value.'
';
}

circumventing the problem with the keys completely.
If you want to show the keys as well you could do:
foreach ($newarray as $key => $value) {
  echo "$key = $value
";
}


text:
Q: Converting NSData representation of UIImage to NSImage is there a way to use an NSData that has been created from a UIImage to create an NSImage? I already have the NSData representation of a UIImage and it is sent via TCP/IP to a MacOSX application... Now I need to convert the NSData received to an NSImage. What is the most efficient way to do this?
I'm using:
NSData * UIImagePNGRepresentation (UIImage *image);

To convert the UIImage to NSData before it is sent over the network.

A: You can following method to create NSImage from NSData
- (instancetype)initWithData:(NSData *)data

Use it as follow
NSImage *image = [[NSImage alloc] initWithData:imageData];

As per documentation

The data object containing the image data. The data can be in any format that OS X supports, including PDF, PICT, EPS, or any number of bitmap data formats.


text:
Q: Getting infor from same column and displaying it on multiple columns I want to find out the sum of the sales for each gender and display it on a separate column. So the Gender column has M and F, and SalesAmount has the various sales for these genders. What I'm looking for is to display Total sales for M and total Sales for F on separate columns. Can you help me with the sql code? Thanks

A: use case when
  select  sum(case when Gender='M' then sales else 0 end) as M,
  sum(case when Gender='F' then sales else 0 end) as F from table

A: This will help,
 SELECT Name,Gender,sum(sales), sum(case when Gender='M' then sales else 0 end) as MaleSales,
      sum(case when Gender='F' then sales else 0 end) as FemaleSales
      FROM table
     group by Name,Gender


text:
Q: When not bundling, is there any way to filter the libraries copied with copyWorkboxLibraries? I'm building my project with npm scripts and node so I'm using workbox-build and calling copyWorkboxLibraries in a script and then in my SW I'm calling importScripts with the path set in setConfig.  Is there any way to copy fewer than all of the workbox libraries or is it up to the developer to remove what isn't needed?

A: You could do something like this in the build script:
const pkgs = [
  'workbox-core',
  'workbox-sw',
];

copyWorkboxLibraries('./docs')
  .then(s => {
    console.log(`Workbox libraries available in ${s}.`);
    return s;
  })
  .then(async d => {
    const dir = await fs.opendir(path.resolve('./docs/' + d));
    for await (const dirent of dir) {
      if (!pkgs.some(pk => dirent.name.includes(pk))) {
        fs.unlink(path.resolve('./docs/' + d + '/' + dirent.name));
      }
    }
  });

This will remove every file whose name doesn't start with workbox-core or workbox-sw from the workbox-v[version] folder that you will be deploying along with your SW.


text:
Q: how to fix error java.util.NoSuchElementException the following code which is given below this giving me error( java.util.NoSuchElementException) how to fix it

*

*Gets the String that follows the line that starts with the given String.

*Gets and returns the String on the very next line.

*If the given String doesn't exist, should return null.

*

*Example(s):

*

*

*If an ArrayList lines contains: "hello" and "world", and we call getNextStringStartsWith("hello"), we'll get the String "world".

*

*

*If an ArrayList lines contains: "Course" and "CIT590", and we call getNextStringStartsWith("Course"), we'll get the String "CIT590".

*

*

*If an ArrayList lines contains: "hello" and "world", and we call getNextStringStartsWith("goodbye"), we'll get null.
string getNextStringStartsWith(String str) {
Iterator<String> iterator = lines.iterator();
while (iterator.hasNext() && !iterator.next().equals(str)) {
    iterator.next();
}
if(iterator.hasNext()){
    return iterator.next();
}else{

    return null;
}

}

A: I didn't actually understand the logic that you are trying to implement, but below could be your code, if you want to search a str in lines, and return str if found, else null:
String getNextStringStartsWith(String str) {
      // TODO Implement method
      Iterator<String> iterator = lines.iterator();
      while (iterator.hasNext()) {
          String data = iterator.next();
          if (str.equals(data)) {
             return data
          }
       }
       return null
}

Edit 1: As I understand, you want to get the word after str if the lines has str
String getNextStringStartsWith(String str) {
      // TODO Implement method
      Iterator<String> iterator = lines.iterator();
      while (iterator.hasNext()) {
          String data = iterator.next();
          // check if the current element is string and next
          // element exists, if so return next element. Else
          // continue and return null after loop
          if (str.equals(data) && iterator.hasNext()) {
             return iterator.next();
          }
       }
       return null
}

Hope this helps !


text:
Q: Why isn't std::set just called std::binary_tree? std::set in C++ is not a real set in terms of data structures. std::unordered_set is a real set, but std::set is a binary search tree, more specifically a red-black tree. Why, then, is it called std::set? Is there some specific functionality that sets a std::set apart from a binary tree? Thanks.

A:
Why isn't std::set just called std::binary_tree?

Because

*

*Tree doesn't describe how the interface is used. Set does.

*std::set does not provide sufficient operations to be used as a general purpose search tree. It only provides an interface to a particular application of a search tree: The representation of a set.

*Technically the standard doesn't specify that std::set is a binary search tree; although red-black BST may be the only data structure that can achieve the requirements imposed on std::set, and the interface has carefully been specified with that data structure in mind, the choice of internal data structure is an implementation detail.

*For same reason std::unordered_set isn't called std::hash_table.

std::unordered_set is a real set, but std::set is a binary search tree

std::unordered_set isn't any more or less "real" than std::set is. They are both sets with slightly different requirements and guarantees; One designed to be implementable using a tree, and another designed to be implementable using a hash table.
P.S. Tree and a hash table are not the only ways to represent a set. One internal data structure that can implement most - but not all - of std::set is a sorted vector. Especially for small sets, a sorted vector can be much faster than std::set.


text:
Q: Django Admin tabularInline very slow request I have Location app in my project. There are list of countries, their states and cities.
model.py
class Country(models.Model):
    class Meta:
        verbose_name = 'Country'
        verbose_name_plural = 'Countries'
        unique_together = ['name', 'iso2'],

    name = models.CharField(
        max_length=255,
        verbose_name=_('Country name'),
    )

    iso2 = models.CharField(
        max_length=2,
        null=True,
        blank=True,
        verbose_name=_('iso2'),
    )

    phone_code = models.CharField(
        max_length=15,
        null=True,
        blank=True,
        verbose_name=_('Phone code'),
    )

    def __str__(self):
        return self.name

class State(models.Model):
    name = models.CharField(
        max_length=100,
        verbose_name=_('State'),
    )

    country = models.ForeignKey(
        Country,
        on_delete=models.SET_NULL,
        verbose_name=_('Country'),
        related_name='states',
        related_query_name='states',
        null=True,
    )

    state_code = models.CharField(
        max_length=20,
        null=True,
        blank=True,
        verbose_name=_('State code'),
    )

    def __str__(self):
        return self.name

class City(models.Model):
    name = models.CharField(
        max_length=70,
        verbose_name=_('City name'),
    )

    state = models.ForeignKey(
        State,
        on_delete=models.SET_NULL,
        null=True,
        verbose_name=_('State'),
        related_name='cities',
        related_query_name='cities',
    )

    country = models.ForeignKey(
        Country,
        on_delete=models.SET_NULL,
        verbose_name=_('Country'),
        related_name='cities',
        related_query_name='cities',
        null=True,
    )

    def __str__(self):
        return self.name

I'm trying to get list of country cities in Django admin via Tabular inline, but when I click on any country it loads very slow (about 1 minute). How to optimize it?
When I did it in Shell - Country.objects.get(name='USA').cities.all()  it returns results less than 10ms
admin.py
from .models import Country, City

class CountryCitiesAdmin(admin.TabularInline):
    model = City

class CountryAdmin(admin.ModelAdmin):
    inlines = (CountryCitiesAdmin,)
    list_display = ('name', 'iso2', 'phone_code')
    search_fields = ('name', 'code', 'phone_code',)

admin.site.register(Country, CountryAdmin)

A: You may have to use the raw_id_fields property. What's happening is that it's pulling all of the possible values to populate the select html element. Setting raw_id_fields = ['country', 'state'] will make it an input that shows the ID of the instance instead.


text:
Q: Simulating continuous distribution using discrete distribution I have a continuous random variable $X$ (positive). I want to simulate its distribution with a discrete distribution and calculate $E[X]$ from that discrete distribution. So, the obvious approach is to divide the range of the random variable into step size of $h$; let the CDF values at the points $0,h,2h,\ldots,Nh$ be $P_0,P_1,P_2,\ldots,P_N$.
Thus, $\text{Prob}(0 < X \leq h)=P_1-P_0$, $\text{Prob}(h < X \leq 2h)=P2-P1$ and so on.
Now these probability masses are associated with a interval. We need to find a representative point of each interval, and here lays my problem.
For an interval $(a,b]$ which point should we take as the representative point? Leftmost point, rightmost point, the mid point?
Basically, given the following relation F'(t)=P(X<=t)=$1-(1-F(t))^{n}$ I need to find the expectation of X i.e E[X] where F(t) is CDF of some other random variable Y. The expression for F(t) is not known to me. I have only access to a black box that gives me a value of F(t) as output when I give a value of t as input. That's why the question of "approximating" the continuous distribution with a discrete distribution comes.
Another question is how to choose an appropriate h value (step size) given an error bound "epsilon" on the expected value. Is there any standard method already?

A: Thinking of extreme scenarios can be helpful. Say you use only one interval- you realize that extreme points make no sense. If you use the expectancy of each interval (under the continuous distribution), the law of total expectation will guarantee you have the right expectation. The midpoints are the solution if they are indeed the expectancy conditioning on the interval (such as uniform or symmetric distribution). [edited after @cardinal's and @whuber's comments]


text:
Q: Xamarin app crashing during apple review process I'm developing a Xamarin navigation app for a local walking route, the app seems to work fine on any physical device I try it on, also distribution using the Testflight system seems fine. The android version is available on the app store and works.
However when I submit the IOS app for review, the app always seems to crash when the Apple employee presses the "Get started" button in my app.
Pressing get started switches the app to the gps navigation page and starts the navigation, which is why I'm asuming something goes wrong here: MapPage.xaml.cs
I have tried different linker settings, because I think that might be the issue, sadly I can not try to disable the linker entirely, because it makes the size of the executable exceed the app store limit.
The project is public: https://github.com/jelknab/FamilieWandelPad
Attached is a symbolicated crash log:
{"app_name":"FamilieWandelPad.iOS","timestamp":"2020-08-10 08:53:31.00 -0700","app_version":"0.14","slice_uuid":"e437ebf3-5228-3f83-a108-2c7f00b4b448","adam_id":1514972762,"build_version":"1.0","bundleID":"net.metzlar.FamilieWandelpadKaag","share_with_app_devs":0,"is_first_party":0,"bug_type":"109","os_version":"iPhone OS 13.6 (17G68)","incident_id":"C77FD17E-9438-41F0-A783-2636FB288B00","name":"FamilieWandelPad.iOS"}
Incident Identifier: C77FD17E-9438-41F0-A783-2636FB288B00
CrashReporter Key:   36c14055bb17c6d0db3f456869338332b769d45e
Hardware Model:      xxx
Process:             FamilieWandelPad.iOS [828]
Path:                /private/var/containers/Bundle/Application/A1901BEC-027C-4052-94C1-4EB07B10BE24/FamilieWandelPad.iOS.app/FamilieWandelPad.iOS
Identifier:          net.metzlar.FamilieWandelpadKaag
Version:             1.0 (0.14)
AppStoreTools:       11E707
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [2]
Coalition:           net.metzlar.FamilieWandelpadKaag [761]

Date/Time:           2020-08-10 08:53:31.2876 -0700
Launch Time:         2020-08-10 08:53:21.4905 -0700
OS Version:          iPhone OS 13.6 (17G68)
Release Type:        User
Baseband Version:    n/a
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Thread 0 name:  tid_507  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x000000019776cd88 0x197747000 + 155016
1   libsystem_pthread.dylib         0x00000001976851e8 0x197683000 + 8680
2   libsystem_c.dylib               0x00000001975d89b0 0x197566000 + 469424
3   libsystem_c.dylib               0x00000001975d8940 0x197566000 + 469312
4   FamilieWandelPad.iOS            0x0000000102fc281c xamarin_initialize.cold.1 + 0
5   FamilieWandelPad.iOS            0x0000000102fba000 xamarin_printf + 42655744 (runtime.m:2472)
6   FamilieWandelPad.iOS            0x0000000102ed27a8 mono_invoke_unhandled_exception_hook + 41707432 (exception.c:1299)
7   FamilieWandelPad.iOS            0x0000000102e73dbc mono_handle_exception_internal + 41319868 (mini-exceptions.c:2783)
8   FamilieWandelPad.iOS            0x0000000102e74568 mono_resume_unwind + 41321832 (mini-exceptions.c:3532)
9   FamilieWandelPad.iOS            0x0000000102e69c20 mono_arm_resume_unwind + 41278496 (exceptions-arm64.c:421)
10  FamilieWandelPad.iOS            0x0000000100838768 llvm_resume_unwind_trampoline + 168
11  FamilieWandelPad.iOS            0x00000001018159fc Xamarin_iOS_UIKit_UIApplication_Main_string___intptr_intptr + 17865212 (UIApplication.cs:0)
12  FamilieWandelPad.iOS            0x000000010073f100 FamilieWandelPad_iOS_FamilieWandelPad_iOS_Application_Main_string__ + 56
13  FamilieWandelPad.iOS            0x000000010080f440 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 272
14  FamilieWandelPad.iOS            0x0000000102e84104 mono_jit_runtime_invoke + 41386244 (mini-runtime.c:3165)
15  FamilieWandelPad.iOS            0x0000000102f1c444 mono_runtime_invoke_checked + 42009668 (object.c:3220)
16  FamilieWandelPad.iOS            0x0000000102f2153c mono_runtime_exec_main_checked + 42030396 (object.c:5284)
17  FamilieWandelPad.iOS            0x0000000102e69630 mono_jit_exec + 41276976 (driver.c:1328)
18  FamilieWandelPad.iOS            0x0000000102fc0cc8 xamarin_main + 42683592 (monotouch-main.m:0)
19  FamilieWandelPad.iOS            0x000000010073d704 main + 202500 (main.m:178)
20  libdyld.dylib                   0x00000001977778f0 0x197776000 + 6384

Thread 1:
0   libsystem_pthread.dylib         0x0000000197691738 0x197683000 + 59192

Thread 2:
0   libsystem_pthread.dylib         0x0000000197691738 0x197683000 + 59192

Thread 3:
0   libsystem_pthread.dylib         0x0000000197691738 0x197683000 + 59192

Thread 4:
0   libsystem_pthread.dylib         0x0000000197691738 0x197683000 + 59192

Thread 5 name:  SGen worker
Thread 5:
0   libsystem_kernel.dylib          0x000000019776cb58 0x197747000 + 154456
1   libsystem_pthread.dylib         0x0000000197686ce4 0x197683000 + 15588
2   FamilieWandelPad.iOS            0x0000000102f97d20 thread_func + 42515744 (sgen-thread-pool.c:196)
3   libsystem_pthread.dylib         0x000000019768dd98 0x197683000 + 44440
4   libsystem_pthread.dylib         0x000000019769174c 0x197683000 + 59212

Thread 6 name:  Finalizer
Thread 6:
0   libsystem_kernel.dylib          0x000000019774b1d4 0x197747000 + 16852
1   FamilieWandelPad.iOS            0x0000000102ed494c finalizer_thread + 41716044 (gc.c:965)
2   FamilieWandelPad.iOS            0x0000000102f4e418 start_wrapper_internal + 42214424 (threads.c:1288)
3   FamilieWandelPad.iOS            0x0000000102f4e29c start_wrapper + 42214044 (threads.c:1309)
4   libsystem_pthread.dylib         0x000000019768dd98 0x197683000 + 44440
5   libsystem_pthread.dylib         0x000000019769174c 0x197683000 + 59212

Thread 7 name:  com.apple.uikit.eventfetch-thread
Thread 7:
0   libsystem_kernel.dylib          0x000000019774b198 0x197747000 + 16792
1   libsystem_kernel.dylib          0x000000019774a60c 0x197747000 + 13836
2   CoreFoundation                  0x00000001978f5328 0x19784d000 + 688936
3   CoreFoundation                  0x00000001978f035c 0x19784d000 + 668508
4   CoreFoundation                  0x00000001978efba8 0x19784d000 + 666536
5   Foundation                      0x0000000197c4101c 0x197c39000 + 32796
6   Foundation                      0x0000000197c40efc 0x197c39000 + 32508
7   UIKitCore                       0x000000019bace57c 0x19affd000 + 11343228
8   Foundation                      0x0000000197d6fe20 0x197c39000 + 1273376
9   libsystem_pthread.dylib         0x000000019768dd98 0x197683000 + 44440
10  libsystem_pthread.dylib         0x000000019769174c 0x197683000 + 59212

Thread 8 name:  tid_9e03
Thread 8:
0   libsystem_kernel.dylib          0x000000019776cb58 0x197747000 + 154456
1   libsystem_pthread.dylib         0x0000000197686ce4 0x197683000 + 15588
2   FamilieWandelPad.iOS            0x0000000102fa5d74 mono_os_cond_timedwait + 42573172 (mono-os-mutex.c:75)
3   FamilieWandelPad.iOS            0x0000000102fad1ac mono_thread_info_sleep + 42602924 (mono-threads.c:1672)
4   FamilieWandelPad.iOS            0x0000000102f45940 monitor_thread + 42178880 (threadpool-worker-default.c:728)
5   FamilieWandelPad.iOS            0x0000000102f4e418 start_wrapper_internal + 42214424 (threads.c:1288)
6   FamilieWandelPad.iOS            0x0000000102f4e29c start_wrapper + 42214044 (threads.c:1309)
7   libsystem_pthread.dylib         0x000000019768dd98 0x197683000 + 44440
8   libsystem_pthread.dylib         0x000000019769174c 0x197683000 + 59212

Thread 9 name:  Thread Pool Worker
Thread 9:
0   libsystem_kernel.dylib          0x000000019774b1ec 0x197747000 + 16876
1   FamilieWandelPad.iOS            0x0000000102f4620c worker_thread + 42181132 (threadpool-worker-default.c:490)
2   FamilieWandelPad.iOS            0x0000000102f4e418 start_wrapper_internal + 42214424 (threads.c:1288)
3   FamilieWandelPad.iOS            0x0000000102f4e29c start_wrapper + 42214044 (threads.c:1309)
4   libsystem_pthread.dylib         0x000000019768dd98 0x197683000 + 44440
5   libsystem_pthread.dylib         0x000000019769174c 0x197683000 + 59212

Thread 10 name:  Thread Pool Worker
Thread 10:
0   libsystem_kernel.dylib          0x000000019774b1ec 0x197747000 + 16876
1   FamilieWandelPad.iOS            0x0000000102f4620c worker_thread + 42181132 (threadpool-worker-default.c:490)
2   FamilieWandelPad.iOS            0x0000000102f4e418 start_wrapper_internal + 42214424 (threads.c:1288)
3   FamilieWandelPad.iOS            0x0000000102f4e29c start_wrapper + 42214044 (threads.c:1309)
4   libsystem_pthread.dylib         0x000000019768dd98 0x197683000 + 44440
5   libsystem_pthread.dylib         0x000000019769174c 0x197683000 + 59212

Thread 11 name:  Thread Pool Worker
Thread 11:
0   libsystem_kernel.dylib          0x000000019774b1ec 0x197747000 + 16876
1   FamilieWandelPad.iOS            0x0000000102f4620c worker_thread + 42181132 (threadpool-worker-default.c:490)
2   FamilieWandelPad.iOS            0x0000000102f4e418 start_wrapper_internal + 42214424 (threads.c:1288)
3   FamilieWandelPad.iOS            0x0000000102f4e29c start_wrapper + 42214044 (threads.c:1309)
4   libsystem_pthread.dylib         0x000000019768dd98 0x197683000 + 44440
5   libsystem_pthread.dylib         0x000000019769174c 0x197683000 + 59212

Thread 12 name:  Timer-Scheduler
Thread 12:
0   libsystem_kernel.dylib          0x000000019776cb58 0x197747000 + 154456
1   libsystem_pthread.dylib         0x0000000197686ce4 0x197683000 + 15588
2   FamilieWandelPad.iOS            0x0000000102fa5d9c mono_os_cond_timedwait + 42573212 (mono-os-mutex.c:32)
3   FamilieWandelPad.iOS            0x0000000102f55ecc mono_w32handle_timedwait_signal_handle + 42245836 (w32handle.c:767)
4   FamilieWandelPad.iOS            0x0000000102f55da4 mono_w32handle_wait_one + 42245540 (w32handle.c:895)
5   FamilieWandelPad.iOS            0x0000000102f55fc8 mono_w32handle_wait_multiple + 42246088 (w32handle.c:1002)
6   FamilieWandelPad.iOS            0x0000000102f4a49c ves_icall_System_Threading_WaitHandle_Wait_internal + 42198172 (threads.c:2313)
7   FamilieWandelPad.iOS            0x0000000102eea764 ves_icall_System_Threading_WaitHandle_Wait_internal_raw + 41805668 (icall-def.h:1100)
8   FamilieWandelPad.iOS            0x0000000100758cf8 wrapper_managed_to_native_System_Threading_WaitHandle_Wait_internal_intptr__int_bool_int + 120
9   FamilieWandelPad.iOS            0x0000000100956cd8 mscorlib_System_Threading_WaitHandle_WaitOneNative_System_Runtime_InteropServices_SafeHandle_uint_bool_bool + 2403544 (WaitHandle.cs:0)
10  FamilieWandelPad.iOS            0x0000000100956710 mscorlib_System_Threading_WaitHandle_InternalWaitOne_System_Runtime_InteropServices_SafeHandle_long_bool_bool + 2402064 (waithandle.cs:266)
11  FamilieWandelPad.iOS            0x00000001009566c0 mscorlib_System_Threading_WaitHandle_WaitOne_long_bool + 2401984 (waithandle.cs:0)
12  FamilieWandelPad.iOS            0x00000001009565a0 mscorlib_System_Threading_WaitHandle_WaitOne_int + 2401696 (waithandle.cs:0)
13  FamilieWandelPad.iOS            0x0000000100957fd4 mscorlib_System_Threading_Timer_Scheduler_SchedulerThread + 2408404 (Timer.cs:287)
14  FamilieWandelPad.iOS            0x0000000100951730 mscorlib_System_Threading_ThreadHelper_ThreadStart_Context_object + 2381616 (thread.cs:80)
15  FamilieWandelPad.iOS            0x000000010094fcc8 mscorlib_System_Threading_ExecutionContext_RunInternal_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 2374856 (executioncontext.cs:969)
16  FamilieWandelPad.iOS            0x000000010094faec mscorlib_System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object_bool + 2374380 (executioncontext.cs:911)
17  FamilieWandelPad.iOS            0x000000010094fa64 mscorlib_System_Threading_ExecutionContext_Run_System_Threading_ExecutionContext_System_Threading_ContextCallback_object + 2374244 (executioncontext.cs:900)
18  FamilieWandelPad.iOS            0x00000001009518b4 mscorlib_System_Threading_ThreadHelper_ThreadStart + 2382004 (thread.cs:111)
19  FamilieWandelPad.iOS            0x000000010080f440 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 272
20  FamilieWandelPad.iOS            0x0000000102e84104 mono_jit_runtime_invoke + 41386244 (mini-runtime.c:3165)
21  FamilieWandelPad.iOS            0x0000000102f1c444 mono_runtime_invoke_checked + 42009668 (object.c:3220)
22  FamilieWandelPad.iOS            0x0000000102f2106c mono_runtime_delegate_try_invoke + 42029164 (object.c:4437)
23  FamilieWandelPad.iOS            0x0000000102f4e510 start_wrapper_internal + 42214672 (threads.c:1257)
24  FamilieWandelPad.iOS            0x0000000102f4e29c start_wrapper + 42214044 (threads.c:1309)
25  libsystem_pthread.dylib         0x000000019768dd98 0x197683000 + 44440
26  libsystem_pthread.dylib         0x000000019769174c 0x197683000 + 59212

Thread 13 name:  Thread Pool Worker
Thread 13:
0   libsystem_kernel.dylib          0x000000019774b1ec 0x197747000 + 16876
1   FamilieWandelPad.iOS            0x0000000102f4620c worker_thread + 42181132 (threadpool-worker-default.c:490)
2   FamilieWandelPad.iOS            0x0000000102f4e418 start_wrapper_internal + 42214424 (threads.c:1288)
3   FamilieWandelPad.iOS            0x0000000102f4e29c start_wrapper + 42214044 (threads.c:1309)
4   libsystem_pthread.dylib         0x000000019768dd98 0x197683000 + 44440
5   libsystem_pthread.dylib         0x000000019769174c 0x197683000 + 59212

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000000   x5: 0x0000000000989680   x6: 0x0000000000000036   x7: 0xffffffffffffffec
    x8: 0x000000010b711840   x9: 0x922ca237905ebebe  x10: 0x00000000000003e8  x11: 0x0000000000bf3d01
   x12: 0x0000000119908000  x13: 0x0000000000004009  x14: 0x0000000119904000  x15: 0x0000000000003fff
   x16: 0x0000000000000148  x17: 0x0000000000000a2f  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000000000507  x21: 0x000000016f6f2570  x22: 0x000000010b711920  x23: 0x000000010c81d550
   x24: 0x00000001198fb2c8  x25: 0x000000010d056e68  x26: 0x000000010c80e000  x27: 0x0000000000000003
   x28: 0x000000010080f43f   fp: 0x000000016f6f1780   lr: 0x00000001976851e8
    sp: 0x000000016f6f1760   pc: 0x000000019776cd88 cpsr: 0x40000000
   esr: 0x56000080  Address size fault

Added appcenter bug tracking as per suggestion, this seems to be the problem:
{
  "length": 0,
  "offset": 0,
  "id": "32ed9f52-8113-4d5d-914a-17302e3680a6",
  "exception": {
    "type": "Plugin.Geolocator.Abstractions.GeolocationException",
    "message": "A geolocation error occured: Unauthorized",
    "stackTrace": "  at Plugin.Geolocator.GeolocatorImplementation.GetPositionAsync (System.Nullable`1[T] timeout, System.Nullable`1[T] cancelToken, System.Boolean includeHeading) <0x105434cbc + 0x00a48> in <a535528283564881a0f1e27c648d0f3b#ff4393fe8a06b7a3c4b6d831f1f7e640>:0 \n  at FamilieWandelPad.navigation.Navigator.StartNavigation () <0x1043e3dc0 + 0x003ab> in <7715b699a0204ede8c0f571ecfcdf8e7#ff4393fe8a06b7a3c4b6d831f1f7e640>:0 ",
    "wrapperSdkName": "appcenter.xamarin"
  },
  "properties": {
    "permission status": "False"
  },
  "appId": "87a72e54-a7d2-4e81-bf84-c85239d780b2",
  "installId": "91F4842B-2F6B-4602-B99A-4297B12DA0B6",
  "isTestMessage": false,
  "timestamp": "2020-09-24T11:23:00.277Z",
  "sid": "4db62a61-3233-4ca0-ba96-4fb37256f471",
  "device": {
    "sdkName": "appcenter.ios",
    "sdkVersion": "3.3.3",
    "wrapperSdkVersion": "3.4.1",
    "wrapperSdkName": "appcenter.xamarin",
    "model": "iPad7,3",
    "oemName": "Apple",
    "osName": "iOS",
    "osVersion": "12.3",
    "osBuild": "16F156",
    "locale": "zh-Hans_CN",
    "timeZoneOffset": -420,
    "screenSize": "1668x2224",
    "appVersion": "0.16",
    "appBuild": "1.0",
    "appNamespace": "net.metzlar.FamilieWandelpadKaag",
    "wrapperRuntimeVersion": "12.6.0"
  }
}

For some reason the app reaches this point without having location permissions, even through the user should not be able to. Sadly I can not really see what they are doing to achieve this, but none of my testflight users are able to bypass the permissions.
Any help would be greatly appreciated.

A: I found the issue by adding appcenter issue tracking. The problem still persist on apple review devices, but has now passed review by try-catching the issue and not doing anything with it. The app works fine on any other devices.


text:
Q: JSON parse double quotes in string literal I am having problem parsing quotes in string literal.
var lit = '{"foo":"test \"1\"","bar":"test 2"}';

In console, this gives an error 'Uncaught exception'.
I am expecting:
Object {foo: "test "1"", bar: "test 2"}

Here is my fiddle https://jsfiddle.net/bruceradtke/kor8amm5/4/
It works ok if I assign stringify result to variable and then
parse that variable.  But not if I use string literal as above.
Thanks.
My code:
var myobject = {};
myobject.foo = "test \"1\"";
myobject.bar = "test 2";

var sresult = JSON.stringify(myobject);
console.log('stringify=' + sresult);
// OK
var thaw = JSON.parse(sresult);
console.log( thaw);

var lit = '{"foo":"test \"1\"","bar":"test 2"}';
console.log(lit);
// Broken
var thaw2 = JSON.parse(lit);

A: Remember that you are escaping two string literals: one for declaring the property and one for declaring the variable (lit). So you need to escape your escape character: "test \\"1\\""

var lit = '{"foo":"test \\"1\\"","bar":"test 2"}';
console.log(lit);

var thaw2 = JSON.parse(lit);


text:
Q: How can I replace HTML content using XSLT? I would like to remove a certain text from an HTML page using XSLT. The text I would like to remove is
OLD TEXT
. I'm trying to remove it by replacing the text with an empty string but I don't get it to work.
When calling my string-replace-all function with "
OLD TEXT
" text as input I get the following error:
The value of the attribute "select" associated with an element type "xsl:with-param" must not contain the '<' character.

When calling my string-replace-all function with just "OLD TEXT" as input the text gets replaced but the output
is no longer HTML, it's just plain text without the HTML tags.
How could I do to replace
OLD TEXT
 and still get the output in HTML format?
My code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <xsl:output method="html" />

   <xsl:template name="string-replace-all">
       <xsl:param name="text" />
       <xsl:param name="replace" />
       <xsl:param name="by" />
       <xsl:choose>
           <xsl:when test="$text = '' or $replace = ''or not($replace)" >

               <xsl:copy-of select="$text" />
           </xsl:when>
           <xsl:when test="contains($text, $replace)">
               <xsl:copy-of select="substring-before($text,$replace)" />
               <xsl:copy-of select="$by" />
               <xsl:call-template name="string-replace-all">
                   <xsl:with-param name="text" select="substring-after($text,$replace)" />
                   <xsl:with-param name="replace" select="$replace" />
                   <xsl:with-param name="by" select="$by" />
               </xsl:call-template>
           </xsl:when>
           <xsl:otherwise>
               <xsl:copy-of select="$text" />
           </xsl:otherwise>
       </xsl:choose>
   </xsl:template>

   <xsl:variable name="updatedHtml">
    <xsl:call-template name="string-replace-all">
      <xsl:with-param name="text" select="//div[@id='mainContent']" />
      <xsl:with-param name="replace" select="'OLD TEXT'" />
      <xsl:with-param name="by" select="''" />
    </xsl:call-template>
  </xsl:variable>

    <xsl:template match="//div[@id='mainContent']">
        <xsl:copy-of select="$updatedHtml" />
    </xsl:template>

</xsl:stylesheet>

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <title>Test page</title>

Header one

Some text

OLD TEXT

Some information about the old text

        More text

Another header

        Some information with strong text.

Another header again

        Some information with strong text.


text:
Q: Not able to get New-F5Item cmdlet I am creating a pool in F5.
i came across the below link which gives a function of creating a Pool.
(https://www.powershellgallery.com/packages/f5-ltm/1.4.154/Content/Public%5CNew-Pool.ps1)
All the things are fine. i have installed F5-LTM module for powershell also.
Install-Module -Name F5-LTM -RequiredVersion 1.4.280

I am not able to see the "New-F5Item" cmdlts.
Can you please let me know about this cmdlet.
Thank you

A: If you look at the file list in PSGallery, you'll notice that the package contains the script file Private\New-F5Item.ps1, indicating that New-F5Item is probably not exported by the module.
When a command is not exported, it can only be discovered/called from other functions in the same module - which is why you don't see it when doing Get-Command or similar.


text:
Q: TypeError: Cannot read property 'map' of undefined in react-hooks I'm a beginner. Thank you in advance for sharing your knowledge.
This error did not appear originally.
But even though they used the same code, it is now appearing.
What's the reason?
Although the data received through Api has the form of an array, the 'map' method does not work.
I read the other same question but I couldn't solve this problem.
This error bothered me for a day. Let me know what I have to do.
import React, { useState, useEffect } from "react";
import axios from "axios";
import styled from "styled-components";

const MyModal = ({ onClose, selectedItem }) => {
  const [data, setData] = useState([]);
  let id = selectedItem;
  let url = `https://www.thecocktaildb.com/api/json/v1/1/lookup.php?i=${id}`;
  useEffect(() => {
    axios
      .get(url)
      .then((res) => {
        setData(res.data.drinks);
      })
      .catch((error) => {
        console.log(error);
      });
  }, [url]);
  return (
    <MyModals onClick={onClose}>
      <Wrapper>
        <button onClick={onClose}>X</button>
        {data.map((result) => {  This is the part of the problem.
          return (
            <Container>
              <Image>

              </Image>
              <About>
                <Name>{result.strDrink}</Name>
            </Container>
          );
        })}
      </Wrapper>
    </MyModals>
  );
};

export default MyModal;

Likewise, this file has the same problem. Errors appear and then appear.
import React, { useState, useEffect } from "react";
import styled from "styled-components";
import Portal from "../Components/Portal";
import Modal from "../Components/Modal";

const Search = () => {
  const [searchTerm, setSearchTerm] = useState("a");
  const [cocktails, setCocktails] = useState([]);
  const [open, setOpen] = useState(false);
  const [selectedItem, setSelectedItem] = useState("");

  const handleOpen = (idDrink) => {
    setSelectedItem(idDrink);
    setOpen(true);
    console.log("open");
  };

  const handleClose = () => {
    setOpen(false);
    console.log("close");
  };
  useEffect(() => {
    const getDrinks = async () => {
      try {
        const response = await fetch(
          `https://www.thecocktaildb.com/api/json/v1/1/search.php?s=${searchTerm}`
        );
        const data = await response.json();
        setCocktails(data);
      } catch (error) {
        console.log(error);
      }
    };
    getDrinks();
    console.log("useEffect");
  }, [searchTerm]);

  return (

      <SearchForm setSearchTerm={setSearchTerm} />
      <Wrapper className="cocktail-list">
        {cocktails &&
          cocktails.drinks.map(({ idDrink, strDrink, strDrinkThumb }) => (
            <Container
              className="cocktail"
              onClick={() => {
                handleOpen(idDrink);
              }}
            >

                <img src={`${strDrinkThumb}`} alt={`${strDrink}`} />

              <Name key={`${idDrink}`}>{`${strDrink}`}</Name>
            </Container>
          ))}
      </Wrapper>
      {open && (
        <Portal>
          <Modal selectedItem={`${selectedItem}`} onClose={handleClose} />
        </Portal>
      )}

  );
};

export default Search;

Is there a problem with the part where I receive the Api data?
import React from "react";
import styled from "styled-components";
import { useState, useEffect } from "react";
import Search from "./Search";
import Modal from "../Components/Modal";
import Portal from "../Components/Portal";

const Main = () => {
  const url = "https://www.thecocktaildb.com/api/json/v1/1/random.php";
  const [data, setData] = useState([]);
  const [open, setOpen] = useState(false);
  const [selectedItem, setSelectedItem] = useState("");

  useEffect(() => {
    const fetchUrl = async () => {
      try {
        const response = await fetch(url);
        const json = await response.json();
        setData(json);
      } catch (error) {
        console.log(error);
      }
    };
    console.log("useEffect");
    fetchUrl();
  }, []);

  const handleOpen = (idDrink) => {
    setSelectedItem(idDrink);
    setOpen(true);
    console.log("open");
  };
  const handleClose = () => {
    setOpen(false);
    console.log("close");
  };

  return (
    <Wrapper className="main">
      {data &&
        data.drinks.map(({ idDrink, strDrink, strDrinkThumb }) => (
          <>
            <Container
              onClick={() => {
                handleOpen(idDrink);
                console.log(handleOpen(idDrink));
              }}
            >
              <img src={`${strDrinkThumb}`} alt={`${strDrink}`} />
              <div key={`${idDrink}`}>{`${strDrink}`}

            </Container>
            {open && (
              <Portal>
                <Modal selectedItem={`${selectedItem}`} onClose={handleClose} />
              </Portal>
            )}
          </>
        ))}
      <Search />
    </Wrapper>
  );
};
export default Main;

The error occurred in all files that wrote the 'map' method.
I really don't know what the problem is. Help me!

A: This has occurred because your map() called before the data come from API. So I will suggest first complete the API call and let the data came properly. Then you should map. You can use-
{data && data.map((result) => {  This will solve ur problem
      return (
        <Container>
          <Image>

          </Image>
          <About>
            <Name>{result.strDrink}</Name>
        </Container>
      );
    })}

A: Make sure of your data from API is a valid Array, you can check it with Array.isArray().
Code could be like this:
{Array.isArray(data) &&
  data.map(result => (
    <Container>
      <Image>

      </Image>
      <About />
      <Name>{result.strDrink}</Name>
    </Container>
  ))}


text:
Q: Show $f(x):=x^p$, where $p \ge 0$, is continuous For p being an integer, the result follows immediately from the Algebraic Limit Theorem and Sequential Criterion. If p is not an integer, however, I cannot use these results. I have tried solving from first principles given $|x-a|<\delta$ but I can't see how to simplify $|x^p-a^p|$. Any hints?

A: You know that the function $x \mapsto e^x$ is continuous on $\mathbb{R}$. Hence for $a \in \mathbb{R}^{*+}$, for all $\epsilon>0$, it exists $\eta>0$ so that $\left|x-a\right|<\eta$ implies $\left|e^{x}-e^{a}\right|<\epsilon$.
Then
$$
\left|x^{p}-a^{p}\right|=\left|e^{p \ln\left(x\right)}-e^{p \ln\left(a\right)}\right|<\epsilon
$$

A: A bit more:
For $x>0$, the function
a)$\exp(x)$, defined and continous on $\mathbb{R}$.
b) $\log(x)$, defined and continous on $\mathbb{R^+_{\star}}.$
Consider  $p>0$, given.
$f(x) = x^p := \exp(p\log(x)).$
$f$ being the composition of 2 continuous functions is continuous on $ \mathbb{R^+_{\star}}.$
The problem :
Show that $f(x)=x^p$ is continuous at $x= a >0.$
$\epsilon,$ $ \delta$ proof.
Plan:
1) Show that $p\log(x)$ is continous at $x=a.$
2) Show that $\exp(y)$ is continous at $y= p\log(a)$.
3) Along the lines of user layman's comment show that the composition of the $2$ functions is continuos.
Note :$\exp$ and $\log $ are base $e$ above.
Comments welcome.


text:
Q: Drawing fancy arrows in Matplotlib Here is a figure I clipped from Lorena A. Barba group
http://i4.tietuku.com/229231358fba454f.png
I just curious about the red arrow mixing with white dot shown on the figure.
Can matplotlib has the function to draw this kind of arrow(I think it's "canyon style")
Maybe this one is more clear:
http://i4.tietuku.com/88a340147ca388c6.png
clipped from  James Bagrow's lab here

A: I do not know if it's possible. And looking at the Gallery (http://matplotlib.org/gallery.html), it does not seem easily available.
But maybe what plt.xkcd() does provides some clue on how to go about.
Here is the source code of pyplot.py: https://github.com/matplotlib/matplotlib/blob/12e08785fcb0b1a6bce946de689a3f84b67731f7/lib/matplotlib/pyplot.py
calling plt.xkcd() just change some rcParams and namely 'path.sketch' gives the randomness of the line. So, with similar approach you could experiment with those rcParams to come up with a brush stroke like style...
There are a bunch of parameters to play with. (Customizing matplotlib, http://matplotlib.org/users/customizing.html)


text:
Q: ListFragment onItemClickListener not working I'm using the tabbed layout (with swipe).
Here I have 3 tabs with controlled by a SectionsPagerAdapter. Each tab is a ListFragment.
Now I want to get an event fired when one of the items in the list is clicked. I would like a listener for each tab.
Here's the code now (Which isn't working, event is not fired).
public class NyhederFragment extends ListFragment {
     public static final String ARG_SECTION_NUMBER = "section_number";
     private static final String TAG="NyhederFragment";
     private List<Item> newsItems;
     private ArrayList newsHeadlines;
     private ArrayAdapter adapter;
     private BroadcastReceiver updateReciever;

public NyhederFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    ListView newsList = new ListView(getActivity());
    newsList.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    newsList.setId(R.id.list);
    DatabaseHelper dbConn = new DatabaseHelper(getActivity());

    newsItems = dbConn.getAllItemsFromNews();
    newsHeadlines = new ArrayList();
    for(Item i : newsItems){
        newsHeadlines.add(i.getTitle());
    }

    adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, newsHeadlines);

    setListAdapter(adapter);

    newsList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                  int position, long id) {
            Log.i("debug", "single click");
        }
    });

    dbConn.close();

    getActivity().registerReceiver(updateReciever, new IntentFilter("ArticlesUpdated"));
    return newsList;
}
}

What is it, I'm doing wrong?
Thanks a lot in advance!

A: If you are using ListFragment then you can simply use its override method onListItemClick()
@Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
    }

A: It is due to custom list item. The default focus is with custom list item (button/textview). It causes this issue.
Please add android:descendantFocusability="blocksDescendants" in root layout of list element.
Hope this will help someone.

A: change setListAdapter(adapter); to newsList.setAdapter(adapter);

A: If you wanted to create or re-use or an existing handler that implements AdapterView.OnItemClickListener, rather than implementing onListItemClick() within the ListFragment, you can do so by getting a reference to the ListView of the ListFragment and setting its listener. In your ListFragment.onResume() you could do:
@Override
public void onResume() {
    super.onResume();
    ListView listView = getListView();
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d("TAG", "Stop touching me");
        }
    });
}

In my case, I can use the same listener from an Activity with a ListView, a ListActivity or a ListFragment, e.g.
listView.setOnItemClickListener(new MyListViewOnClickListener(getActivity()));


text:
Q: unix: move files and keep folder structure Linux 2.6.18-194.el5 x86_64

I have two folders with files with the same structure:
I would like to move all files from FTP_UPD to FTP keeping folder structure.
FTP_UPD
├── cat1
│   ├── und3
│   └── und4
└── cat2
    ├── und1
    └── und2

FTP
├── cat1
│   ├── und3
│   └── und4
└── cat2
    ├── und1
    └── und2

I tried with
rsync -a --progress --remove-source-files FTP_UPD FTP

but I get error:
rsync: --remove-source-files: unknown option
rsync error: syntax or usage error (code 1) at main.c(1231) [client=2.6.8]

Maybe any other options?
Please help me with this.

A: Use this:
mv FTP_UPD FTP
This will simply move the folder. You could also call rename instead of move.
If you want to keep the old FTP_UPD folder with its contents:
cp -r FTP_UPD FTP
-r parameter causes recursive copying (copying everything that is inside FTP_UPD). This can also be read from man cp.


text:
Q: Why can't I install bcrypt? I've a problem: when I try to install some Gem with the command "bundle install", I recive this output:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby2.1 -r ./siteconf20141210-5447-g6skes.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.1.0/gems/bcrypt-3.1.7 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/bcrypt-3.1.7/gem_make.out
An error occurred while installing bcrypt (3.1.7), and Bundler cannot continue.
Make sure that `gem install bcrypt -v '3.1.7'` succeeds before bundling.

Why? How can i solve it?

A: In recent versions bcrypt-ruby seems to use the GMP library.
Something like this should help:
sudo aptitude install libgmp-dev

Do not forget to install all the stuff for development:
sudo aptitude install build-essential


text:
Q: AsyncTask passing custom objects [I have a custom parcelable object Vehicle]
I have looked at AsyncTask but it wasn't too clear on this topic:
I would like to pass a String(which is the Vehicle ID of the Vehicle) into an AsyncTask, then in doInBackground() I have a method
mRemoteInterface.getTrackHistory();

which gives me an ArrayList. I would like to then, in onPostExecute() start an activity where both the Vehicle ID and ArrayList are extras.
This is an outline of what I wan't to be able to do. The issue is that I don't understand passing objects INTO the asynctask, and then from doInBackground() to onPostExecute() and from onPostExecute() back to the original execute call.
getTrackHistory.execute(WHAT SHOULD GO HERE?);
private class getTrackHistory extends
AsyncTask<String, Integer, Boolean **WHAT SHOULD GO HERE?**> {

    @Override
    protected Boolean doInBackground(
            String... params) {
        try {
            String vehicleID = params[0];
            listVehicleHistory = (ArrayList<Vehicle>) mRemoteInterface.getVehicleHistory(vehicleID);
        } catch (Exception e) {

            e.printStackTrace();
        }

    }

    @Override
    protected void onProgressUpdate(Integer... progress) {

    }

    @Override
    protected void onPostExecute(Boolean worked) {

        super.onPostExecute(worked);

        Intent intent = new Intent(MainActivity.this,VehicleInfo.class);

        intent.putExtra("Vehicle ID", toReturn);
        intent.putParcelableArrayListExtra("VehicleHistory", listVehicleHistory);

        startActivity(intent);
    }

}

A: You can pass the string to the constructor of asynctask or to doInbackground
   new getTrackHistory(mystringvalue).execute();

Then in the constructor
  private class getTrackHistory extends AsyncTask<String, Integer, Boolean> {

  String value;
  public getTrackHistory(String mystring) {
      value = mystring;
  }

Edit:
You can also pass value to doInbackground()
   new TheTask().execute("mystring");
   class TheTask extends AsyncTask <String,Void,Void> {
     @Override
     protected void onPreExecute() {
       super.onPreExecute();
     }
     @Override
     protected void onPostExecute(Void result) {
      super.onPostExecute(result);
     }
     @Override
     protected Void doInBackground(String... params) {
      String value = params[0];
     return null;
     }
   }

To the question in the comment
  new getTrackHistory(mystringvalue,ActivityName.this).execute();

In the Constructor
  String value;
  TheInterface listener;
  public getTrackHistory(String mystring,Context context) {
      value= mystring;
      listener = (TheInterface) context;
  }

Interface
public interface TheInterface {

public void theMethod(ArrayList<String> result); // your result type

}

Then
In your doInbackground return the result. I am assuming its ArrayList of type String. Change the arraylist to what suits your requirement.
In your onPostExecute
if (listener != null) {
  listener.theMethod(result); // result is the ArrayList<String>
  // result returned in doInbackground
  // result of doInbackground computation is a parameter to onPostExecute
}

In your activity class implement the interface
  public class ActivityName implements getTrackHistory.TheInterface

Then
 @Override
 public void theMethod(ArrayList<String> result) { // change the type of result according yo your requirement
 // use the arraylist here
 }

Similar post using interface
Android Parse JSON stuck on get task.

A: Common approach to this is to pass your arguments/objects to constructor of your AsyncTask, store as member and then reference from doInBackground(). For example:
private class getTrackHistory extends AsyncTask<String, Integer, Boolean> {

    Vehicle mVehicle;

    public getTrackHistory( Vehicle v) {
       mVehicle = v;
    }

    @Override
    protected Boolean doInBackground() {

          // use mVehicle member here

    }
}

A: An Asynctask is just a class like any other, use a constructor, or populate the instantiated object through a setter, public members, etc.


text:
Q: Eclipse crashes with a GC overhead limit exceeded error It's the first time I am using Proguard, I've noticed that if you add many custom rules to proguard-project.txt it takes obviously much more time for building. That's cause Eclipse to crash reporting a GC overhead limit exceeded and then I have to force the shut down of java because the editor continues to pop out error and alert dialogs. Is there any way to avoid these continuous crashes on Eclipse and so fix the problem reported here too?

A: Fixed, I read all the others forum posts about the problem but no one said how to fix it on Eclipse. I found the fix here

EDIT: in case the link becomes dead, here's what you can do. Edit "eclipse.ini", and set something like that:
-XX:MaxPermSize=1024m
-Xms512m
-Xmx1024m

A: Remove all errors and warnings from your layouts.
Make sure you are running the eclipse in admin mode (windows users)
Go to your eclipse folder location -> open eclipse.ini file then make sure to match following.
-Dosgi.requiredJavaVersion=1.6-Xms512m-Xmx1024m

this may help you a little bit.
and
Change Target SDK in your manifest to 18 for the time being to avoid the crashes. Issue is with android-19. Wait for another update before switching back.


text:
Q: Convert SQL Query to Hive Query Can some one assist me to convert this SQL query into hive to get same output ?
Below is the query
select count(email),
       case substring_index(email,"@",-1)
           when 'gmail.com'      then 'GMAIL'
           when 'googlemail.com' then 'GMAIL'
           when 'yahoo.com'      then 'YAHOO'
           when 'ymail.com'      then 'YAHOO'
            else 'OTHER'
       END as DOMAIN
   from DATA1 group by 2;

A: select count(email),
       case split(email,'@')[1]
           when 'gmail.com'      then 'GMAIL'
           when 'googlemail.com' then 'GMAIL'
           when 'yahoo.com'      then 'YAHOO'
           when 'ymail.com'      then 'YAHOO'
            else 'OTHER'
       end as DOMAIN
   from DATA1
  group by
    case substring_index(email,"@",-1)
       when 'gmail.com'      then 'GMAIL'
       when 'googlemail.com' then 'GMAIL'
       when 'yahoo.com'      then 'YAHOO'
       when 'ymail.com'      then 'YAHOO'
       else 'OTHER'
     end;

Read about group by position syntax and apply accordingly to your hive version if you want group by 2 to work.


text:
Q: How to implement elasticsearch custom similarity plugin? I need to override Lucene Default Similarity Class which is used by Elasticsearch for indexing and searching. On searching net, I found some similar implementations which are doing similar things. My difficulty is that I have no idea of how to actually implement this in my code. I found some resources:
https://github.com/tlrx/elasticsearch-custom-similarity-provider
curl -XPOST 'http://host:port/tweeter/' -d '
{
  "settings": {
    "similarity": {
      "index": {
        "type": "org.elasticsearch.index.similarity.CustomSimilarityProvider"
      },
      "search": {
        "type": "org.elasticsearch.index.similarity.CustomSimilarityProvider"
      }
    }
  }
}'

I'm not able to understand how can i use this line directly during indexing so that my default similarity changes to this custom similarity.
org.elasticsearch.index.similarity.CustomSimilarityProvider
Can anyone please tell me how I can do this ? I tried running the same thing on my machine but it's not working for me. Do I need to modify this line or path ?
Thanks in advance.

A: The link that your posted https://github.com/tlrx/elasticsearch-custom-similarity-provider is for older version of elasticsearch.
Based on the elasticsearch taste plugin https://github.com/codelibs/elasticsearch-taste, I made a simple custom similarity plugin for version 2.1.1 with detailed explanations of all the steps
https://github.com/stefansavev/elasticsearch-custom-similarity-example. I kept it simple to only three java files and one config file. I hope you find it useful.

A: The json that you posted is the one that creates an index, using the create index api. In the same request you can provide settings, mappings and so on for that index. Among the settings, you can register a custom similarity.
Once you created the index you need to actually index documents into it using the index api.
Also, since 0.90 you can also configure a custom similarity per field through the mappings.


text:
Q: How to combine two lists in one list? using notepad++ regex? I have a list of textfile such as below example:
username1
username2
username3

I want a regex that can make it like following example:
username1:username1
username2:username2
username3:username3

etc..
I've tried many regex with failed attempts.
hopefully somebody can help me..
thank you in advance.
regards.

A: Just click Ctrl + H to open the replace window, and follow the attached picture.