问:
How do you reference a bitmap on the stage in actionscript?
How do you reference a bitmap on the stage in flash using actionscript 3?

I have a bitmap on the stage in flash and at the end of the movie I would like to swap it out for the next in the sequence before the movie loops. in my library i have 3 images, exported for actionscript, with the class name img1/img2/img3. here is how my layers in flash are set out.

```<code>layer 5 : mask2:MovieClip
layer 4 : img2:Bitmap
layer 3 : mask1:MovieClip
layer 2 : img1:Bitmap
layer 1 : background:Bitmap
</code>```

at the end of the movie I would like to swap img1 with img2, so the movie loops seamlessly, then ideally swap img2 (on layer 4) with img3 and so on until I get to the end of my images.

but I can not find out how to reference the images that have already been put on the stage (in design time), any one have any idea of how to do this?

The end movie will hopefully load images dynamically from the web server (I have the code for this bit) and display them as well as img1/img2/img3.

Any help would be appreciated.

EDIT:

@81bronco , I tried this but the instance name is greyed out for graphics, it will only allow me to do it with movieclips and buttons. I half got it to work by turning them into moveclips, and clearing the images in the moveclip out before adding a new one (using something simpler to what vanhornRF suggested), but for some odd reason when the mask kicks in the images I cleared out come back for the mask animation.

答:
Hey Re0sless, when you remove those items from the stage do they have any event listeners attached to them, any timers or loaders? Any of those things can make an object stick around in flash's memory and not remove properly. Also on top of just removing the item, perhaps try nulling it as well? Sometimes that helps in clearing out its references so it can be properly destroyed.

Of course it could also be something silly like removing the item at one instance doesn't remove the item from future frames as well, but I really don't think that's the case.

Body:
How do you reference a bitmap on the stage in flash using actionscript 3?

I have a bitmap on the stage in flash and at the end of the movie I would like to swap it out for the next in the sequence before the movie loops. in my library i have 3 images, exported for actionscript, with the class name img1/img2/img3. here is how my layers in flash are set out.

layer 5 : mask2:MovieClip
layer 4 : img2:Bitmap
layer 3 : mask1:MovieClip
layer 2 : img1:Bitmap
layer 1 : background:Bitmap

at the end of the movie I would like to swap img1 with img2, so the movie loops seamlessly, then ideally swap img2 (on layer 4) with img3 and so on until I get to the end of my images.

but I can not find out how to reference the images that have already been put on the stage (in design time), any one have any idea of how to do this?

The end movie will hopefully load images dynamically from the web server (I have the code for this bit) and display them as well as img1/img2/img3.

Any help would be appreciated.

EDIT:

@81bronco , I tried this but the instance name is greyed out for graphics, it will only allow me to do it with movieclips and buttons. I half got it to work by turning them into moveclips, and clearing the images in the moveclip out before adding a new one (using something simpler to what vanhornRF suggested), but for some odd reason when the mask kicks in the images I cleared out come back for the mask animation.

OwnerDisplayName: vanhornRF


来源: stackexchange

问:
asp.net web application compile and deployed on x64 vs x86
My web application crashes almost once a week due to not enought memory error. Although server has 8gb of memory and it's server 2003 x64. And almost 5gb is always free.

I compile my application with Any CPU option in studio 2008.

My laptop that i use to build this has 32 bit vista.

Is my web application running under x86 or x64?

if not running under 64bit then Will i get more memory for my web application if i compile differently? Is there any advantage with going 64 bit in .net or .net itself is limited to use specific amount of memory?

答:
If you're running out of memory in a web application, chances are you're doing something wrong. That might mean you've got leaky legacy COM objects, or you're abusing the Cache or Session, or you've got a circular reference or memory leak.

Recompiling/running as x64 could postpone the out of memory error but it won't change it.

If you compiled it on x86 but used the AnyCPU option, and deployed it to an unmodified IIS6 instance on Windows 2003, it's running as x86. You can test this assumption by looking in the Taskman on the Windows Server 2003 machine. If there is a *32 by the w3wp.exe then you're running 32-bit.

OwnerDisplayName: mamu

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: Scott Hanselman


问:
Form Element Missing from DOM in IE7
Why doesn't IE7 load <form> tags into the DOM? It is causing issues with CSS that I had applied to a class on the form tag. I solved the issue by wrapping the form tag with a div, and applying the styles to that, but I wanted to see if anyone could offer a technical explanation of what IE is doing with this tag when I use the following code;

```<code><form class="contact"> ... <form>
</code>```

Causes issues in IE7, as well as

```<code><div class="contact"><form class="contact"> ... <form></div>
</code>```

I had to use

```<code><div class="contact"><form> ... <form></div>
</code>```

To solve my issue, but some minor inconsistencies remain. This question isn't about my layout issue, but just in case you are wondering, the CSS I was using is;

```<code>html {
    background: #113333;
    margin: 0;
    min-height: 100%;
}
body {
    background: #ccc;
    width: 960px;
    margin: 10px auto;
    padding: 10px;
}

div { background: green; }

.contact {
    display: inline-block;
    zoom: 1;
    *display: inline;
}

fieldset {
    float: left;
}
</code>```

Also the page this relates to (content may change) is here.

So, what is IE7 doing with code like this?

答: I documented this bug here. You basically need  or you can't style form elements in IE pre 8/9.

Title: Form Element Missing from DOM in IE7

Body:
Why doesn't IE7 load <form> tags into the DOM? It is causing issues with CSS that I had applied to a class on the form tag. I solved the issue by wrapping the form tag with a div, and applying the styles to that, but I wanted to see if anyone could offer a technical explanation of what IE is doing with this tag when I use the following code;

<form class="contact"> ... <form>

Causes issues in IE7, as well as

<form class="contact"> ... <form>

I had to use

<form> ... <form>

To solve my issue, but some minor inconsistencies remain. This question isn't about my layout issue, but just in case you are wondering, the CSS I was using is;

html {
    background: #113333;
    margin: 0;
    min-height: 100%;
}
body {
    background: #ccc;
    width: 960px;
    margin: 10px auto;
    padding: 10px;
}

div { background: green; }

.contact {
    display: inline-block;
    zoom: 1;
    *display: inline;
}

fieldset {
    float: left;
}

Also the page this relates to (content may change) is here.

So, what is IE7 doing with code like this?

Body: I documented this bug here. You basically need <body> or you can't style form elements in IE pre 8/9.

ContentLicense: CC BY-SA 3.0


问:
Android App POST-ing to PHP Laravel Server
I have an android app that I've set to POST some data to my PHP Laravel server, however I get a 405 error and I don't know why( trying to POST via Postman works just fine)

This is my android code:

```<code> String URL_POST = "http://192.168.2.102/device/id";
 btnGoi.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            InsertSV();
        }

    });

private void InsertSV() {

    StringRequest stringRequest = new StringRequest(Request.Method.POST, URL_POST, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {

            Toast.makeText(getApplication(), response, Toast.LENGTH_SHORT).show();

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(IdDeviceActivity.this, error + "", Toast.LENGTH_SHORT).show();
        }
    }
    ) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {

            Map<String, String> params = new HashMap<String, String>();
            String Id = edtId.getText().toString();
            params.put("ID", Id);

            return params;
        }
    };

    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringRequest);
}
</code>```

And this is my PHP Laravel one(I am using xampp to start it):

```<code>public function checkDeviceId(Request $request){

    $id = $request->input('ID');
    $code=LicenceCodes::where('device_id',$id)->first();
    if($code==null){
        return response('Wrong device id.'.$id, 405)
            ->header('Content-Type', 'text/plain');
    }
    else
    {
        return response('Device added'.$id, 200)
            ->header('Content-Type', 'text/plain');
    }
</code>```

And my routing:

```<code>Route::post('/device/id', 'DeviceController@checkDeviceId');
</code>```

Knowing that it's working just fine with Postman, I think there might be an android problem? Or I'm not passing the parameter properly, I'm really not sure....

EDIT: However, I've tried to POST to a simple php file in my xampp folder and for that it works fine

LATER LATER EDIT: I see that I get 405 Method Not allowed on Postman aswell, however I still get the good response in body and that's why I was fooled. How should I fix the 405 error ?

答: Found it. Had to switch some status error codes and it works fine now.</p>

Body:
I have an android app that I've set to POST some data to my PHP Laravel server, however I get a 405 error and I don't know why( trying to POST via Postman works just fine)

This is my android code:

 String URL_POST = "http://192.168.2.102/device/id";
 btnGoi.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {

            InsertSV();
        }

    });

private void InsertSV() {

    StringRequest stringRequest = new StringRequest(Request.Method.POST, URL_POST, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {

            Toast.makeText(getApplication(), response, Toast.LENGTH_SHORT).show();

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(IdDeviceActivity.this, error + "", Toast.LENGTH_SHORT).show();
        }
    }
    ) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {

            Map<String, String> params = new HashMap<String, String>();
            String Id = edtId.getText().toString();
            params.put("ID", Id);

            return params;
        }
    };

    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringRequest);
}

And this is my PHP Laravel one(I am using xampp to start it):

public function checkDeviceId(Request $request){

    $id = $request->input('ID');
    $code=LicenceCodes::where('device_id',$id)->first();
    if($code==null){
        return response('Wrong device id.'.$id, 405)
            ->header('Content-Type', 'text/plain');
    }
    else
    {
        return response('Device added'.$id, 200)
            ->header('Content-Type', 'text/plain');
    }

And my routing:

Route::post('/device/id', 'DeviceController@checkDeviceId');

Knowing that it's working just fine with Postman, I think there might be an android problem? Or I'm not passing the parameter properly, I'm really not sure....

EDIT: However, I've tried to POST to a simple php file in my xampp folder and for that it works fine

LATER LATER EDIT: I see that I get 405 Method Not allowed on Postman aswell, however I still get the good response in body and that's why I was fooled. How should I fix the 405 error ?


问:
Access parent window's Grid from User Control
In my MainWindow VM i open the Views from my UserControls like this.
Usercontrol1 is the name of the View made in Xaml.
In my ViewModel of my MainWindow:

```<code>   private static Grid _myMainGrid;

    public static Grid MyMainGrid
    {
        get { return _myMainGrid; }
        set { _myMainGrid = value; }
    }

    private void OpenUserControl(UserControl myUS)
    {
        if (MyMainGrid.Children.Count > 0)
        {
            MyMainGrid.Children.RemoveAt(0);
        }
        Grid.SetColumn(myUS, 1);
        Grid.SetRow(myUS, 0);
        MyMainGrid.Children.Add(myUS);
    }
    private void FindGrid(object obj)
    {
        var myGrd = obj as Grid;
        if (myGrd != null)
        {
            MyMainGrid = myGrd;
        }
    }
</code>```

The command binding to the Button executes this.

```<code>private void ExecuteCMD_OpenUserControl1(object obj)
    {
        FindGrid(obj);
        Usercontrol1 _ucItem = new Usercontrol1();
        OpenUserControl(_ucItem);
    }
</code>```

Now i want to open Usercontrol2 replacing Usercontrol1 in MyMainGrid from my MainWindow by pressing a button in Usercontrol1. So i have to access the parent Window.

Tried using this methode but can't get it to work in my case.

答:
I don't fully understand the structure of your application and there are most probably better ways of doing whatever you are trying to do, but you could get a reference to any open window in your application using the Application.Current.Windows property if that's your main issue:

```<code>var mainWindow = Application.Current.Windows.OfType<MainWindow>().FirstOrDefault();
</code>```

Inside a loaded UserControl, you should also be able to get a reference to the parent window of this UserControl like this:

```<code>var mainWindow = Window.GetWindow(this) as MainWindow;
</code>```

Body:
In my MainWindow VM i open the Views from my UserControls like this.
Usercontrol1 is the name of the View made in Xaml.
In my ViewModel of my MainWindow:

   private static Grid _myMainGrid;

    public static Grid MyMainGrid
    {
        get { return _myMainGrid; }
        set { _myMainGrid = value; }
    }

    private void OpenUserControl(UserControl myUS)
    {
        if (MyMainGrid.Children.Count > 0)
        {
            MyMainGrid.Children.RemoveAt(0);
        }
        Grid.SetColumn(myUS, 1);
        Grid.SetRow(myUS, 0);
        MyMainGrid.Children.Add(myUS);
    }
    private void FindGrid(object obj)
    {
        var myGrd = obj as Grid;
        if (myGrd != null)
        {
            MyMainGrid = myGrd;
        }
    }

The command binding to the Button executes this.

private void ExecuteCMD_OpenUserControl1(object obj)
    {
        FindGrid(obj);
        Usercontrol1 _ucItem = new Usercontrol1();
        OpenUserControl(_ucItem);
    }

Now i want to open Usercontrol2 replacing Usercontrol1 in MyMainGrid from my MainWindow by pressing a button in Usercontrol1. So i have to access the parent Window.

Tried using this methode but can't get it to work in my case.

Body:
I don't fully understand the structure of your application and there are most probably better ways of doing whatever you are trying to do, but you could get a reference to any open window in your application using the Application.Current.Windows property if that's your main issue:

var mainWindow = Application.Current.Windows.OfType<MainWindow>().FirstOrDefault();

Inside a loaded UserControl, you should also be able to get a reference to the parent window of this UserControl like this:

var mainWindow = Window.GetWindow(this) as MainWindow;


问:
Internal error when trying to use any composer functionality
I'm using composer in a ZF2 PHP project in Zend Studio 10.6. I recently tried to add a depency to the project, and I received an "internal error". Since then, whenever I try to use any function, I receive the same error:

Error msg

"An internal error occurred during: "Package Details".
For input string: "if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME""

The search function when I try to add a depency also does no longer find any packages, even though I have a repository installed.

I'm very grateful for any suggestions!

答: I know this is old, but it's a simple fix. This error basically means that ZS/Eclipse cannot find the composer.phar file. Ensure it is referenced properly in your system path, or within the IDE and 'Update Dependencies' will work just fine.</p>


问:
undefined parse transformation "lager_transformation" ejabberd 17.01
i am trying to configure ejabberd module using in windows 8.1 following link
https://github.com/Mingism/ejabberd-stanza-ack
ejabberd version 17.01
erlang version 8.3
 this is the command i am using

erlc -I ${C:\Program%Files\ejabberd-17.01\lib\ejabberd-17.01\include} mod_stanza_ack.erl

i put mod_stanza_ack.erl also inside include folder but it gives lagger_transformation error. Is it a different version issue? this link also says that it is for ejabberd version 13.x. I think it can also work in latest version. What i am missing here?

答:
You don't have to move the file mod_stanza_ack.erl into an include directory, but put it in a working directory. Then start a command window in that directory and execute:

```<code>erlc -I "C:/Program Files/ejabberd-17.01/lib/ejabberd-17.01/src" mod_stanza_ack.erl
</code>```

Note you have to put the source path into "double quotes", and use "/" and not "\" for the path, even in window (at least it works like this, and i did not try to use double back slash "\", a single back slash escapes the next character!)

Note 2 the tested version 13 of ejabberd is 4 years old, You should be prepared to face some compatibility issues using an earlier one.

Edit

You need at least these 3 source files: logger.hrl, ejabberd.hrl, jlib.hrl they are included in ejabberd-stanza-ack.erl.  In the current ejabberd version (master branch), the header files (*.hrl) are in the include directory, as usual, but they doesn't content the definition of xmlel record which is used by ejabberd-stanza-ack.erl so you cannot use this version.

In the ejabberd 13, the header files are in the src directory - weird ! - , they include the necessary record definitions (at least at first glance...). So you should use this version. If you try to use a more recent one, you must verify that it is still using the xmlel record definition, and adapt the command line with the real location of the header files.

Body:
You don't have to move the file mod_stanza_ack.erl into an include directory, but put it in a working directory. Then start a command window in that directory and execute:

erlc -I "C:/Program Files/ejabberd-17.01/lib/ejabberd-17.01/src" mod_stanza_ack.erl

Note you have to put the source path into "double quotes", and use "/" and not "\" for the path, even in window (at least it works like this, and i did not try to use double back slash "\", a single back slash escapes the next character!)

Note 2 the tested version 13 of ejabberd is 4 years old, You should be prepared to face some compatibility issues using an earlier one.

Edit

You need at least these 3 source files: logger.hrl, ejabberd.hrl, jlib.hrl they are included in ejabberd-stanza-ack.erl.  In the current ejabberd version (master branch), the header files (*.hrl) are in the include directory, as usual, but they doesn't content the definition of xmlel record which is used by ejabberd-stanza-ack.erl so you cannot use this version.

In the ejabberd 13, the header files are in the src directory - weird ! - , they include the necessary record definitions (at least at first glance...). So you should use this version. If you try to use a more recent one, you must verify that it is still using the xmlel record definition, and adapt the command line with the real location of the header files.


问:
BotKit Slack Bot to Microsoft Teams Bot
I recently built a slack bot via the BotKit toolkit and now want to be able to expand from just slack to many other services. Basically, I was reading https://venturebeat.com/2016/11/02/how-bots-will-work-on-microsoft-teams/
and it states that

"The integration means Microsoft Bot Framework users will be able to make bots for Slack, and Botkit users will be able to bring their bots to additional platforms, like Telegram, Kik, Twilio, and Skype. (Before the change, Botkit was only able to make bots for Slack and Facebook Messenger.)"

However, it is not clear to me how this can be accomplished. Do you mind explaining this to me or pointing me in the right direction? From what I understand, it should be a simple process of having my slackbot basically run within Microsoft Teams or Skype or whatever service.

Thanks!

答:
The VentureBeat link for the Public Preview of Microsoft Teams was referring to the ability to use bots written for Slack (via BotKit or otherwise) within Microsoft Teams with little or no modification necessary. This capability is provided by Message.io. You can contact them for more information or look on their website.

Microsoft Teams also has a native bot platform - the Microsoft Bot Framework (which also supports Slack, Skype, Facebook, and several other chat platforms). BotKit does not yet support Bot Framework.

(@JasonSowers)[https://stackoverflow.com/users/3011564/jasonsowers] is correct - BotKit and Bot Framework are two different bot platforms; today Microsoft teams supports one via Message.io and one natively.

Title: BotKit Slack Bot to Microsoft Teams Bot


问:
Bitmap colors change while scrolling
I have a ListView that has a subtle gradient bitmap in the background of each item.  I noticed that when I scroll the list, the background gradient becomes banded and changes color.  The gradient is a dark gray and when it scrolls is becomes subtly green and banded.  It basically looks like the quality of the images greatly decreases as it scrolls.

Most of the time, as soon as it finishes scrolling, it returns to the normal quality.  Sometimes it actually stays poor quality even after scrolling stops.  On a Nexus One it almost always stays low quality after scrolling.

Is there a way to avoid this?

Note:  This is not the common ListView background problem discussed here: http://developer.android.com/resources/articles/listview-backgrounds.html

Here is an enlarged screen cap to show the difference.  On the left side is the background normally.  On the right half you can see what it looks like when it scrolls.

答: You need to add android:cacheColorHint="#0000" to your ListView in xml.

Title: Bitmap colors change while scrolling


问:
Parallel query of SQLite database in R
I have a large database (~100Gb) from which I need to pull every entry,
perform some comparisons on it, and then store the results of those comparisons. I have attempted to run parallel queries within a single R sessions without any success. I can just run multiple R sessions all at once but I am looking for a better approach. Here is what I attempted:

```<code>library(RSQLite)
library(data.table)
library(foreach)
library(doMC)

#---------
# SETUP
#---------

#connect to db
db <- dbConnect(SQLite(), dbname="genes_drug_combos.sqlite")

#---------
# QUERY
#---------
# 856086 combos = 1309 * 109 * 6

registerDoMC(8)

#I would run 6 seperate R sessions (one for each i)
res_list <- foreach(i=1:6) %dopar% {

  a <- i*109-108
  b <- i*109

  pb  <- txtProgressBar(min=a, max=b, style=3)
  res <- list()

  for (j in a:b) {

    #get preds for drug combos
    statement   <- paste("SELECT * from combo_tstats WHERE rowid BETWEEN", (j*1309)-1308, "AND", j*1309)
    combo_preds <- dbGetQuery(db, statement)

    #here I do some stuff to the result returned from the query
    combo_names <- combo_preds$drug_combo
    combo_preds <- as.data.frame(t(combo_preds[,-1]))

    colnames(combo_preds)  <- combo_names

    #get top drug combos
    top_combos <- get_top_drugs(query_genes, drug_info=combo_preds, es=T)

    #update progress and store result
    setTxtProgressBar(pb, j)
    res[[ length(res)+1 ]] <- top_combos
  }
  #bind results together
  res <- rbindlist(res)
}
</code>```

I dont get any errors but only one core spins up. In contrast, if I run multiple R sessions, all my cores go at it. What am I doing wrong?

答:
Some things I have learned while accessing concurrently with RSQLite the same file SQLite database:

1. Make sure each worker has its own DB connection.

```<code>  parallel::clusterEvalQ(cl = cl, {
    db.conn <- RSQLite::dbConnect(RSQLite::SQLite(), "./export/models.sqlite");
    RSQLite::dbClearResult(RSQLite::dbSendQuery(db.conn, "PRAGMA busy_timeout=5000;"));
  })
</code>```

2. Use PRAGMA busy_timeout=5000;

By default this is set to 0, and chances are that you will end up with a "database is locked" error each time your worker tries to write to the DB while it is locked. Previous code sets this PRAGMA in each worker connection. Note that SELECT operations are never locked, only INSERT/DELETE/UPDATE.

3. Use PRAGMA journal_mode=WAL;

This only has to be set once and stays on by default forever. It will add two (more or less permanent) files to the DB. It will improve concurrent read/write performance. Read more here.

With the above settings I have not experienced this issue.

Title: Parallel query of SQLite database in R

Body:
I have a large database (~100Gb) from which I need to pull every entry,
perform some comparisons on it, and then store the results of those comparisons. I have attempted to run parallel queries within a single R sessions without any success. I can just run multiple R sessions all at once but I am looking for a better approach. Here is what I attempted:

library(RSQLite)
library(data.table)
library(foreach)
library(doMC)

#---------
# SETUP
#---------

#connect to db
db <- dbConnect(SQLite(), dbname="genes_drug_combos.sqlite")

#---------
# QUERY
#---------
# 856086 combos = 1309 * 109 * 6

registerDoMC(8)

#I would run 6 seperate R sessions (one for each i)
res_list <- foreach(i=1:6) %dopar% {

  a <- i*109-108
  b <- i*109

  pb  <- txtProgressBar(min=a, max=b, style=3)
  res <- list()

  for (j in a:b) {

    #get preds for drug combos
    statement   <- paste("SELECT * from combo_tstats WHERE rowid BETWEEN", (j*1309)-1308, "AND", j*1309)
    combo_preds <- dbGetQuery(db, statement)

    #here I do some stuff to the result returned from the query
    combo_names <- combo_preds$drug_combo
    combo_preds <- as.data.frame(t(combo_preds[,-1]))

    colnames(combo_preds)  <- combo_names

    #get top drug combos
    top_combos <- get_top_drugs(query_genes, drug_info=combo_preds, es=T)

    #update progress and store result
    setTxtProgressBar(pb, j)
    res[[ length(res)+1 ]] <- top_combos
  }
  #bind results together
  res <- rbindlist(res)
}

I dont get any errors but only one core spins up. In contrast, if I run multiple R sessions, all my cores go at it. What am I doing wrong?

Body:
Some things I have learned while accessing concurrently with RSQLite the same file SQLite database:

1. Make sure each worker has its own DB connection.

  parallel::clusterEvalQ(cl = cl, {
    db.conn <- RSQLite::dbConnect(RSQLite::SQLite(), "./export/models.sqlite");
    RSQLite::dbClearResult(RSQLite::dbSendQuery(db.conn, "PRAGMA busy_timeout=5000;"));
  })

2. Use PRAGMA busy_timeout=5000;

By default this is set to 0, and chances are that you will end up with a "database is locked" error each time your worker tries to write to the DB while it is locked. Previous code sets this PRAGMA in each worker connection. Note that SELECT operations are never locked, only INSERT/DELETE/UPDATE.

3. Use PRAGMA journal_mode=WAL;

This only has to be set once and stays on by default forever. It will add two (more or less permanent) files to the DB. It will improve concurrent read/write performance. Read more here.

With the above settings I have not experienced this issue.


问:
JQuery .addClass() not applying styles defined in JQuery
It's quite a simple question, but I'm (trying) to write a JQuery plugin, and I want to use only JQuery. The problem is, I have some styles set for the .active divs (via JQuery), and on clicking a
 it's given a class active - I know this, because I checked in the developer tools - but it's not given the styles. I tried hardcoding the class onto the
, and it worked fine. I also tried hardcoding the styles in CSS instead of JQuery, and again, it worked. Is there a way of updating the JQuery - onclick of the
 - so that the styles are applied when the
 is clicked?

$('div.active').css({
  'border-style':'solid',
 'border-width':'1px',
 'border-color':'black',
});
$('div').on('click',function(){
   $('div').removeClass('active');
    $(this).addClass('active');
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="div1">div 1</div>
<div class="div2">div 2</div>
<div class="div3">div 3</div>
<div class="div4">div 4</div></code>```

JSFiddle

Also, can you explain why this isn't working for me?

Thanks

答:
$('div.active') selects all
 elements which have the class .active on them, in the exact time of its execution. This means, when the page is loaded, but there are no elements having the class .active on them when the page is loaded, so no element will be styled. The properties are not automatically added afterwards, when there is an element matching the previous selection.

If you want to add styles to your page, you need to add a ');
```

<p>I would, however, not add stylesheets programmatically. Try to add the styles to your stylesheet file and only switch classes to make changes programmatically.</p>

<hr>

<p>Here is working example:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$('head').append('');
$('div').on('click',function(){
   $('div').removeClass('active');
    $(this).addClass('active');
});</code>```

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

div 1

div 2

div 3

div 4
```

Body:
It's quite a simple question, but I'm (trying) to write a JQuery plugin, and I want to use only JQuery. The problem is, I have some styles set for the .active divs (via JQuery), and on clicking a
 it's given a class active - I know this, because I checked in the developer tools - but it's not given the styles. I tried hardcoding the class onto the
, and it worked fine. I also tried hardcoding the styles in CSS instead of JQuery, and again, it worked. Is there a way of updating the JQuery - onclick of the
 - so that the styles are applied when the
 is clicked?

$('div.active').css({
  'border-style':'solid',
 'border-width':'1px',
 'border-color':'black',
});
$('div').on('click',function(){
   $('div').removeClass('active');
    $(this).addClass('active');
});

div 1

div 2

div 3

div 4

JSFiddle

Also, can you explain why this isn't working for me?

Thanks

Body:
$('div.active') selects all <div> elements which have the class .active on them, in the exact time of its execution. This means, when the page is loaded, but there are no elements having the class .active on them when the page is loaded, so no element will be styled. The properties are not automatically added afterwards, when there is an element matching the previous selection.

If you want to add styles to your page, you need to add a <style> attribute to the DOM. You can do it like this:

$('head').append('<style>div.active { border: 1px solid black; }</style>');

I would, however, not add stylesheets programmatically. Try to add the styles to your stylesheet file and only switch classes to make changes programmatically.

Here is working example:

$('head').append('<style>div.active { border: 1px solid black; }</style>');
$('div').on('click',function(){
   $('div').removeClass('active');
    $(this).addClass('active');
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="div1">div 1</div>
<div class="div2">div 2</div>
<div class="div3">div 3</div>
<div class="div4">div 4</div>


答:
```<code>$('div.active').css({
  'border-style':'solid',
    'border-width':'1px',
    'border-color':'black',
});
</code>```

The above logic puts inline styles on any div element that has the active class, -at that point in time-, in the DOM.

```<code>$('div').on('click',function(){
    $('div').removeClass('active');
    $(this).addClass('active');
});
</code>```

The above logic simply shifts around the active class on elements.  It does not automatically move inline styles.

Title: JQuery .addClass() not applying styles defined in JQuery

Body:
$('div.active').css({
  'border-style':'solid',
    'border-width':'1px',
    'border-color':'black',
});

The above logic puts inline styles on any div element that has the active class, -at that point in time-, in the DOM.

$('div').on('click',function(){
    $('div').removeClass('active');
    $(this).addClass('active');
});

The above logic simply shifts around the active class on elements.  It does not automatically move inline styles.


问:
Laravel 5.4 - Update an existing record
I'm struggling to update an existing record through an Eloquent Model in Laravel 5.4

I have for creating a record that works perfectly fine, I took it and modified it to try and update the record:

```<code>public function commitEdit ($char_edit_id)
    {

    $edited_character = \DB::table('characters')->where('char_id', $char_edit_id)->first();

    $edited_character->campaign_id = 1;

    $edited_character->character_name = request('characterName');

    $edited_character->Race = request('race');

    $edited_character->Sub_Race = request('subRaceField');

    $edited_character->Class = request('class');

    $edited_character->Level = request('level');

    $edited_character->Strength = request('strength');

    $edited_character->Dexterity = request('dexterity');

    $edited_character->Constitution = request('constitution');

    $edited_character->Intelligence = request('intelligence');

    $edited_character->Wisdom = request('wisdom');

    $edited_character->Charisma = request('charisma');

    $levelVar = request('level');

    if ($levelVar >= 4) {
    $edited_character->Proficiency = 2;
    } else if ($levelVar >= 8) {
    $edited_character->Proficiency = 3;
    }

    $edited_character->Trained_Skills = request('skillsField');

    $edited_character->Languages = request('languagesField');

    $edited_character->Hit_Die = 1;

    $edited_character->max_HP = request('max-hp');

    $edited_character->Alignment = request('alignment');

    $edited_character->Armor_Class = request('armor-class');

    $edited_character->Initiative = request('initiative');

    $edited_character->Speed = request('speed');

    $edited_character->Background = request('background');

    $edited_character->update();

    return redirect('./characters');
</code>```

That gives this error:
Call to undefined method stdClass::update()

I have tried using save() but I get the same error with save() instead of update()

Thanks in advance c:

答:
You can try this way:</p>

```<code>public function commitEdit ($char_edit_id)
{
    $edited_character = Characters::find($char_edit_id);
    $edited_character->character_name = request('characterName');

    $edited_character->Race = request('race');

    $edited_character->Sub_Race = request('subRaceField');

    $edited_character->Class = request('class');

    $edited_character->Level = request('level');

    $edited_character->Strength = request('strength');

    $edited_character->Dexterity = request('dexterity');

    $edited_character->Constitution = request('constitution');

    $edited_character->Intelligence = request('intelligence');

    $edited_character->Wisdom = request('wisdom');

    $edited_character->Charisma = request('charisma');

    $levelVar = request('level');

    if ($levelVar >= 4) {
    $edited_character->Proficiency = 2;
    } else if ($levelVar >= 8) {
    $edited_character->Proficiency = 3;
    }

    $edited_character->Trained_Skills = request('skillsField');

    $edited_character->Languages = request('languagesField');

    $edited_character->Hit_Die = 1;

    $edited_character->max_HP = request('max-hp');

    $edited_character->Alignment = request('alignment');

    $edited_character->Armor_Class = request('armor-class');

    $edited_character->Initiative = request('initiative');

    $edited_character->Speed = request('speed');

    $edited_character->Background = request('background');

    if($edited_character->save()){
        return redirect('./characters');
     }else{
         // show error message
       }
}
</code>```

Title: Laravel 5.4 - Update an existing record

Body:
I'm struggling to update an existing record through an Eloquent Model in Laravel 5.4

I have for creating a record that works perfectly fine, I took it and modified it to try and update the record:

public function commitEdit ($char_edit_id)
    {

    $edited_character = \DB::table('characters')->where('char_id', $char_edit_id)->first();

    $edited_character->campaign_id = 1;

    $edited_character->character_name = request('characterName');

    $edited_character->Race = request('race');

    $edited_character->Sub_Race = request('subRaceField');

    $edited_character->Class = request('class');

    $edited_character->Level = request('level');

    $edited_character->Strength = request('strength');

    $edited_character->Dexterity = request('dexterity');

    $edited_character->Constitution = request('constitution');

    $edited_character->Intelligence = request('intelligence');

    $edited_character->Wisdom = request('wisdom');

    $edited_character->Charisma = request('charisma');

    $levelVar = request('level');

    if ($levelVar >= 4) {
    $edited_character->Proficiency = 2;
    } else if ($levelVar >= 8) {
    $edited_character->Proficiency = 3;
    }

    $edited_character->Trained_Skills = request('skillsField');

    $edited_character->Languages = request('languagesField');

    $edited_character->Hit_Die = 1;

    $edited_character->max_HP = request('max-hp');

    $edited_character->Alignment = request('alignment');

    $edited_character->Armor_Class = request('armor-class');

    $edited_character->Initiative = request('initiative');

    $edited_character->Speed = request('speed');

    $edited_character->Background = request('background');

    $edited_character->update();

    return redirect('./characters');

That gives this error:
Call to undefined method stdClass::update()

I have tried using save() but I get the same error with save() instead of update()

Thanks in advance c:

Body:
You can try this way:

public function commitEdit ($char_edit_id)
{
    $edited_character = Characters::find($char_edit_id);
    $edited_character->character_name = request('characterName');

    $edited_character->Race = request('race');

    $edited_character->Sub_Race = request('subRaceField');

    $edited_character->Class = request('class');

    $edited_character->Level = request('level');

    $edited_character->Strength = request('strength');

    $edited_character->Dexterity = request('dexterity');

    $edited_character->Constitution = request('constitution');

    $edited_character->Intelligence = request('intelligence');

    $edited_character->Wisdom = request('wisdom');

    $edited_character->Charisma = request('charisma');

    $levelVar = request('level');

    if ($levelVar >= 4) {
    $edited_character->Proficiency = 2;
    } else if ($levelVar >= 8) {
    $edited_character->Proficiency = 3;
    }

    $edited_character->Trained_Skills = request('skillsField');

    $edited_character->Languages = request('languagesField');

    $edited_character->Hit_Die = 1;

    $edited_character->max_HP = request('max-hp');

    $edited_character->Alignment = request('alignment');

    $edited_character->Armor_Class = request('armor-class');

    $edited_character->Initiative = request('initiative');

    $edited_character->Speed = request('speed');

    $edited_character->Background = request('background');

    if($edited_character->save()){
        return redirect('./characters');
     }else{
         // show error message
       }
}


问:
NSDateFormatter's init method is deprecated?
Per

http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html

The init method of NSDateFormatter is "Available in iPhone OS 2.0 through iPhone OS 3.2", and therefore not in 4.0.  Now, it certainly works, but this seems odd.  Is this is a mistake or is there some other way to create a NSDateFormatter?

答:
Like falconcreek said here, Apple is just clearing the docs.

That means that originally, - (id) init has been redeclared in the NSDateFormatter header file. That was unnecessary and somebody just removed it later. The documentation is probably generated automatically and didn't picked up that it was only the redecleration that was deprecated.

In short, use init as you wish with NSDateFormatter!


问:
MySQL connection ('max_user_connections')
I can not access my database. I'm getting the following error:

```<code> User 'myuser' has exceeded the 'max_user_connections' resource (current value: 5)
</code>```

In my PHP code every open connection is closed next. And, as I know, when PHP script finishes, the connection is closed automatically.

Is there any way to restart the server or close all connections remotely?

答:
This should work on linux for restarting your mysql server

sudo /etc/init.d/mysql restart

Body:
I can not access my database. I'm getting the following error:

 User 'myuser' has exceeded the 'max_user_connections' resource (current value: 5)

In my PHP code every open connection is closed next. And, as I know, when PHP script finishes, the connection is closed automatically.

Is there any way to restart the server or close all connections remotely?


问:
Tinymce custom plugin
A client asked me to make a plugin to insert phone links, I know this can be done through the link plugin but he wants one specifically designed to do this. I already have the plugin with the popup window where you can insert the data you need, here is the code, what I want is to add the same functionality that has the link plugin so when the user clicks over the linked text the content can be edited inside the window manager of my plugin.

This is the code i have so far:

```<code>tinymce.PluginManager.add('phonelink', function(editor, url) {
// Add a button that opens a window
  tinymce.DOM.loadCSS(url + '/css/phonelink.css');
  editor.addButton('phonelink', {
    text: false,
    icon: 'phonelink',
    onclick: function() {
      // Open window
      editor.windowManager.open({
        title: 'Enlace teléfono',
        body: [
          {type: 'textbox', name: 'phone', label: 'Teléfono'},
          {type: 'textbox', name: 'showtext', label: 'Texto a mostrar'},
          {type: 'textbox', name: 'title', label: 'Título'}
        ],
        onsubmit: function(e) {
          // Insert content when the window form is submitted
          editor.insertContent('<a title="' + e.data.title + '" href="tel:+34' + e.data.phone + '">' + e.data.showtext + '</a>');
        }
      });
    }
  });

  // Adds a menu item to the tools menu
  editor.addMenuItem('phonelink', {
    text: 'Teléfono',
    context: 'tools',
    onclick: function() {
      // Open window with a specific url
      editor.windowManager.open({
          title: 'Enlace teléfono',
          body: [
            {type: 'textbox', name: 'phone', label: 'Teléfono'},
            {type: 'textbox', name: 'showtext', label: 'Texto a mostrar'},
            {type: 'textbox', name: 'title', label: 'Título'}
          ],
          onsubmit: function(e) {
            // Insert content when the window form is submitted
            editor.insertContent('<a title="' + e.data.title + '" href="tel:+34' + e.data.phone + '">' + e.data.showtext + '</a>');
          }
      });
    }
  });
});
</code>```

答:
I finally solved it, if anyone is interested this is how i did it:</p>

```<code>tinymce.PluginManager.add('phonelink', function(editor, url) {
    // Add a button that opens a window
    var linkText = "";
    var linkTitle = "";
    var link = "";
    tinymce.DOM.loadCSS(url + '/css/phonelink.css');
    editor.addButton('phonelink', {
        text: false,
        icon: 'phonelink',
        onpostrender: updateOnSelect,
        onclick: onClickPhoneButton
    });
    // Adds a menu item to the tools menu
    editor.addMenuItem('phonelink', {
        text: 'Teléfono',
        context: 'tools',
        onclick: onClickPhoneButton,
        onpostrender: updateOnSelect,
    });
    function onClickPhoneButton(){
        editor.windowManager.open({
            title: 'Enlace teléfono',
            body: [
                {type: 'textbox', name: 'phone', label: 'Teléfono', value: link},
                {type: 'textbox', name: 'showtext', label: 'Texto a mostrar', value: linkText},
                {type: 'textbox', name: 'title', label: 'Título', value: linkTitle}
            ],
            onsubmit: function(e) {
                // Insert content when the window form is submitted
                var hrefLink = '<a title="' + e.data.title + '" href="tel:+34' + e.data.phone + '">' + e.data.showtext + '</a>';
                if(link !== ''){
                    editor.setContent(hrefLink);
                }else{
                    editor.insertContent(hrefLink);
                }
            }
        });
    }
    function updateOnSelect() {
        var btn = this;
        editor.on('NodeChange', function (e) {
            var node = editor.selection.getNode();
            var isTelLink = node.href !== undefined && node.href.indexOf('tel:+') !== -1
            btn.active(isTelLink);
            if(isTelLink){
                link = node.href;
                link = link.replace("tel:+34", "");
                linkTitle = node.title;
                linkText = node.text;
            }
        });
    }
});
</code>```

Title: Tinymce custom plugin

Body:
A client asked me to make a plugin to insert phone links, I know this can be done through the link plugin but he wants one specifically designed to do this. I already have the plugin with the popup window where you can insert the data you need, here is the code, what I want is to add the same functionality that has the link plugin so when the user clicks over the linked text the content can be edited inside the window manager of my plugin.

This is the code i have so far:

tinymce.PluginManager.add('phonelink', function(editor, url) {
// Add a button that opens a window
  tinymce.DOM.loadCSS(url + '/css/phonelink.css');
  editor.addButton('phonelink', {
    text: false,
    icon: 'phonelink',
    onclick: function() {
      // Open window
      editor.windowManager.open({
        title: 'Enlace teléfono',
        body: [
          {type: 'textbox', name: 'phone', label: 'Teléfono'},
          {type: 'textbox', name: 'showtext', label: 'Texto a mostrar'},
          {type: 'textbox', name: 'title', label: 'Título'}
        ],
        onsubmit: function(e) {
          // Insert content when the window form is submitted
          editor.insertContent('' + e.data.showtext + '');
        }
      });
    }
  });

  // Adds a menu item to the tools menu
  editor.addMenuItem('phonelink', {
    text: 'Teléfono',
    context: 'tools',
    onclick: function() {
      // Open window with a specific url
      editor.windowManager.open({
          title: 'Enlace teléfono',
          body: [
            {type: 'textbox', name: 'phone', label: 'Teléfono'},
            {type: 'textbox', name: 'showtext', label: 'Texto a mostrar'},
            {type: 'textbox', name: 'title', label: 'Título'}
          ],
          onsubmit: function(e) {
            // Insert content when the window form is submitted
            editor.insertContent('' + e.data.showtext + '');
          }
      });
    }
  });
});

Body:
I finally solved it, if anyone is interested this is how i did it:

tinymce.PluginManager.add('phonelink', function(editor, url) {
    // Add a button that opens a window
    var linkText = "";
    var linkTitle = "";
    var link = "";
    tinymce.DOM.loadCSS(url + '/css/phonelink.css');
    editor.addButton('phonelink', {
        text: false,
        icon: 'phonelink',
        onpostrender: updateOnSelect,
        onclick: onClickPhoneButton
    });
    // Adds a menu item to the tools menu
    editor.addMenuItem('phonelink', {
        text: 'Teléfono',
        context: 'tools',
        onclick: onClickPhoneButton,
        onpostrender: updateOnSelect,
    });
    function onClickPhoneButton(){
        editor.windowManager.open({
            title: 'Enlace teléfono',
            body: [
                {type: 'textbox', name: 'phone', label: 'Teléfono', value: link},
                {type: 'textbox', name: 'showtext', label: 'Texto a mostrar', value: linkText},
                {type: 'textbox', name: 'title', label: 'Título', value: linkTitle}
            ],
            onsubmit: function(e) {
                // Insert content when the window form is submitted
                var hrefLink = '<a title="' + e.data.title + '" href="tel:+34' + e.data.phone + '">' + e.data.showtext + '</a>';
                if(link !== ''){
                    editor.setContent(hrefLink);
                }else{
                    editor.insertContent(hrefLink);
                }
            }
        });
    }
    function updateOnSelect() {
        var btn = this;
        editor.on('NodeChange', function (e) {
            var node = editor.selection.getNode();
            var isTelLink = node.href !== undefined && node.href.indexOf('tel:+') !== -1
            btn.active(isTelLink);
            if(isTelLink){
                link = node.href;
                link = link.replace("tel:+34", "");
                linkTitle = node.title;
                linkText = node.text;
            }
        });
    }
});


问:
Yahoo Finance URL not working
I have been using the following URL to fetch historical data from yahoo finance for quite some time now but it stopped working as of yesterday.

https://ichart.finance.yahoo.com/table.csv?s=SPY

When browsing to this site it says:

Will be right back...

Thank you for your patience.

Our engineers are working quickly to resolve the issue.

However, since this issue is still existing since yesterday I am starting to think that they discontinued this service?

My SO search only pointed me to this topic, which was related to https though...

Is anyone else experiencing this issue?
How can I resolve this problem? Do they offer a different access to their historical data?

答:
Python

I used this code to get cookie (copied from fix-yahoo-finance):

```<code>def get_yahoo_crumb_cookie():
    """Get Yahoo crumb cookie value."""
    res = requests.get('https://finance.yahoo.com/quote/SPY/history')
    yahoo_cookie = res.cookies['B']
    yahoo_crumb = None
    pattern = re.compile('.*"CrumbStore":\{"crumb":"(?P<crumb>[^"]+)"\}')
    for line in res.text.splitlines():
        m = pattern.match(line)
        if m is not None:
            yahoo_crumb = m.groupdict()['crumb']
    return yahoo_cookie, yahoo_crumb
</code>```

then this code to get response:

```<code>cookie, crumb = get_yahoo_crumb_cookie()
params = {
    'symbol': stock.symbol,
    'period1': 0,
    'period2': int(time.time()),
    'interval': '1d',
    'crumb': crumb,
}
url_price = 'https://query1.finance.yahoo.com/v7/finance/download/{symbol}'

response = requests.get(url_price, params=params, cookies={'B': cookie})
</code>```

This looks nice as well http://blog.bradlucas.com/posts/2017-06-03-yahoo-finance-quote-download-python/

Title: Yahoo Finance URL not working

Body:
Python

I used this code to get cookie (copied from fix-yahoo-finance):

def get_yahoo_crumb_cookie():
    """Get Yahoo crumb cookie value."""
    res = requests.get('https://finance.yahoo.com/quote/SPY/history')
    yahoo_cookie = res.cookies['B']
    yahoo_crumb = None
    pattern = re.compile('.*"CrumbStore":\{"crumb":"(?P<crumb>[^"]+)"\}')
    for line in res.text.splitlines():
        m = pattern.match(line)
        if m is not None:
            yahoo_crumb = m.groupdict()['crumb']
    return yahoo_cookie, yahoo_crumb

then this code to get response:

cookie, crumb = get_yahoo_crumb_cookie()
params = {
    'symbol': stock.symbol,
    'period1': 0,
    'period2': int(time.time()),
    'interval': '1d',
    'crumb': crumb,
}
url_price = 'https://query1.finance.yahoo.com/v7/finance/download/{symbol}'

response = requests.get(url_price, params=params, cookies={'B': cookie})

This looks nice as well http://blog.bradlucas.com/posts/2017-06-03-yahoo-finance-quote-download-python/


答:
In MySQL configuration file, set

```<code>max_connections=200
</code>```

5 is too low.  You will need to restart the server. If you can't restart, make this setting in the config file and execute this in the workbench

```<code>set global max_connections=200
</code>```

Title: MySQL connection ('max_user_connections')

Body:
In MySQL configuration file, set

max_connections=200

5 is too low.  You will need to restart the server. If you can't restart, make this setting in the config file and execute this in the workbench

set global max_connections=200


问:
Can we get report content in Json format using java BO sdk?
I want to retrieve the content of a BI report in Json format, Is it possible with Java BO sdk?

If so can any one give me some examples how to retrieve content in Json?

答:
The short answer is no, you can't get Json natively with the SDK. You can, however export a Webi and Crystal report to XML, which you can then convert in Json.

A more complete answer would require to know which version of BO you are using, an whether you need to export WebI report, Crystal or Crystal for Enterprise reports. This will more or less dictate which SDK you will use for that, however going forward SAP is pushing hard with the RESTful services API, so that may be the one you should look to utilize.


问:
Can't Use "Vendored Framework" CocoaPod Inside Workspace Playground
I've created a sample project illustrating my issue here.

In summary, I'm trying to use a "vendored framework" CocoaPod inside a workspace playground. I think this is possible but requires a bit of fiddling with project settings, and I can't quite figure out what to change.

To observe the issue in the sample project, do the following:

Open CocoaPods-Test/CocoaPods-Test.xcworkspace in Xcode.

Pods should be installed and committed in the repository, but can run pod install if necessary.

Note that the CocoaPods-Test target builds and runs successfully, importing PromiseKit and TwilioChatClient pods.

Navigate to Playground.playground within the workspace.

Note that the playground executes fine while importing PromiseKit but if TwilioChatClient is imported, playground execution fails with "no such module 'TwilioChatClient'".

After reading the following resources:

https://github.com/CocoaPods/CocoaPods/issues/5334

https://github.com/CocoaPods/CocoaPods/issues/5215

https://github.com/CocoaPods/CocoaPods/issues/5563

https://github.com/CocoaPods/swift/issues/3

https://github.com/CocoaPods/CocoaPods/issues/4135

https://github.com/CocoaPods/CocoaPods/issues/2240

https://github.com/CocoaPods/CocoaPods/issues/6669#issuecomment-300188519

https://guides.cocoapods.org/using/troubleshooting.html

https://www.objc.io/issues/6-build-tools/cocoapods-under-the-hood/

I think the issue is probably related to the fact that TwilioChatClient is a "vendored framework" (see its podspec), which means a pod target is not created for it. After reading the above resources, I feel like a solution is within reach, but I can't quite figure it out.

While the sample project here illustrates what I think is the underlying issue, the issue that prompted me to create this example project is just a small bit more complicated.

In my project, I create a framework target containing all my app's code (so it can be imported into my app and also into my playgrounds using app resources). This framework then has pod dependencies, including PromiseKit and TwilioChatClient. The execution error in the playground is different ("Couldn't lookup symbols" instead of "no such module"), as I am not importing the CocoaPods module directly but my framework which uses the pod framework.

I suspect if I can solve the "no such module" issue, it will help me solve my "couldn't lookup symbols" issue.

Finally, this seems like a good opportunity to make an open source contribution others don't seem to have wanted to do (see discussion here). Tangentially, I'd love to contribute but just don't feel like I understand what exactly is going on with CocoaPods, the Xcode build process, etc., after reading about it a bit (e.g. here and here). Any references to help understand the Xcode build process and what CocoaPods is doing under the hood are appreciated. It seems like the resources I've found are either "a very high level overview" (which I get), or "digging through the source code", with not a whole lot in between.

答:
If you must have this work, I came up with a workaround by creating a framework target inside the Pods project which is named the same as the vendor framework, and uses all its headers publicly, using the framework as a sole dependency. I have forked your GH example and linked it here.

It's not the most elegant solution, but it will help you out in a pinch.

UPDATE
Build "fake" framework first, then build app target, then go to playground.


问:
.NET and Python interop via IronPython
I'm trying to make some of my Python scripts callable from .NET. I've found out that IronPython is a good tool to accomplish this. So I've tried to use it, but now I have the following questions:

How can I install packages to IronPython? My existing Python code uses them, so I need to get them installed. I've tried to follow this guide to install pip, but got Process is terminated due to StackOverflowException. and haven't found a way to solve the issue.

Assuming I'll be able to install packages, is it still true that packages with C/C++ bindings cannot be used in IronPython? Because on the FAQ page is written that NumPy and SciPy can't be installed, but the page seems to be rather old.

What about accessing Python code from other .NET code? The documentation page says that I have to use the DLR Hosting APIs, because assemblies compiled from IronPython are not CLS-compliant. But I can't get an idea how to make it work with packages.

Maybe there is another way to call Python code from .NET?

Thanks in advance.

答:
OK, I think I've figured things out.

The problem with pip was due to the fact that I've tried to use ipy64. Using ipy has solved the problem.

Yes, today it is impossible to use packages with C/C++ bindings.

Lets assume that pip and requests are installed using ipy -X:Frames -m ensurepip and ipy -X:Frames -m pip install requests (more info about pip in IronPython can be found here). requests can be used using the DLR Hosting APIs in the following way:

```<code>var engine = IronPython.Hosting.Python.CreateEngine(new Dictionary<string, object> {{"Frames", true}});
var searchPaths = engine.GetSearchPaths();
searchPaths.Add(@"C:\Program Files (x86)\IronPython 2.7\Lib");
searchPaths.Add(@"C:\Program Files (x86)\IronPython 2.7\Lib\site-packages");
engine.SetSearchPaths(searchPaths);
engine.CreateScriptSourceFromString("import requests; r = requests.get('http://www.google.com/'); print r.status_code").Execute();
</code>```

More info about hosting Python can be found in the IronPython documentation file (default location is C:\Program Files (x86)\IronPython 2.7\Doc\IronPython.chm) under the Hosting IronPython section.

As denfromufa has suggested one can use Python for .NET to call CPython code from .NET.

Title: .NET and Python interop via IronPython

Body:
OK, I think I've figured things out.

The problem with pip was due to the fact that I've tried to use ipy64. Using ipy has solved the problem.

Yes, today it is impossible to use packages with C/C++ bindings.

Lets assume that pip and requests are installed using ipy -X:Frames -m ensurepip and ipy -X:Frames -m pip install requests (more info about pip in IronPython can be found here). requests can be used using the DLR Hosting APIs in the following way:

var engine = IronPython.Hosting.Python.CreateEngine(new Dictionary<string, object> {{"Frames", true}});
var searchPaths = engine.GetSearchPaths();
searchPaths.Add(@"C:\Program Files (x86)\IronPython 2.7\Lib");
searchPaths.Add(@"C:\Program Files (x86)\IronPython 2.7\Lib\site-packages");
engine.SetSearchPaths(searchPaths);
engine.CreateScriptSourceFromString("import requests; r = requests.get('http://www.google.com/'); print r.status_code").Execute();

More info about hosting Python can be found in the IronPython documentation file (default location is C:\Program Files (x86)\IronPython 2.7\Doc\IronPython.chm) under the Hosting IronPython section.

As denfromufa has suggested one can use Python for .NET to call CPython code from .NET.

ContentLicense: CC BY-SA 4.0


问:
How to use run a keyword if testcasename is equal to abc in robotframework
I know how can we use run keyword if specific condition is met but i want to run a keyword if testcasename matches.

```<code>run keyword if testcase=abc.robot
</code>```

does anyone know how can we achieve that.

答:
Robot framework provides several automatic variables -- variables that are set automatically by the framework. One such variable is ${TEST_NAME}.

In the following example, only the log statement in the second test will run:

```<code>*** Test Cases ***
Example 1
    run keyword if  "${TEST_NAME}" == "Example 2"
    ...   log  this is example 2?

Example 2
    run keyword if  '${TEST_NAME}' == "Example 2"
    ...  log  this is example 2!
</code>```

Body:
I know how can we use run keyword if specific condition is met but i want to run a keyword if testcasename matches.

run keyword if testcase=abc.robot

does anyone know how can we achieve that.

Body:
Robot framework provides several automatic variables -- variables that are set automatically by the framework. One such variable is ${TEST_NAME}.

In the following example, only the log statement in the second test will run:

*** Test Cases ***
Example 1
    run keyword if  "${TEST_NAME}" == "Example 2"
    ...   log  this is example 2?

Example 2
    run keyword if  '${TEST_NAME}' == "Example 2"
    ...  log  this is example 2!


问:
Upgrading Tier (Sku) via Set-AzureRmAnalysisServicesServer not working
I want to upscale and downscale my Azure Analysis Services with PowerShell (Automation Runbook), but changing the Tier (Sku) doesn't seem to work. However there are no errors. Any suggestions?

```<code># PowerShell code
# Connect to a connection to get TenantId and SubscriptionId
$Connection = Get-AutomationConnection -Name "AzureRunAsConnection"
$TenantId = $Connection.TenantId
$SubscriptionId = $Connection.SubscriptionId

# Get the service principal credentials connected to the automation account.
$null = $SPCredential = Get-AutomationPSCredential -Name "SSISJoost"

# Login to Azure ($null is to prevent output, since Out-Null doesn't work in Azure)
Write-Output "Login to Azure using automation account 'SSISJoost'."
$null = Login-AzureRmAccount -TenantId $TenantId -SubscriptionId $SubscriptionId -Credential $SPCredential

# Select the correct subscription
Write-Output "Selecting subscription '$($SubscriptionId)'."
$null = Select-AzureRmSubscription -SubscriptionID $SubscriptionId

# Get variable values
$ResourceGroupName = Get-AutomationVariable -Name 'ResourceGroupName'
$AnalysisServerName = Get-AutomationVariable -Name 'AnalysisServerName'

# Get old status (for testing/logging purpose only)
$OldAsSetting = Get-AzureRmAnalysisServicesServer -ResourceGroupName $ResourceGroupName -Name $AnalysisServerName

try
{
    # changing tier
    Write-Output "Upgrade $($AnalysisServerName) to S1. Current tier: $($OldAsSetting.Sku.Name)"
    Set-AzureRmAnalysisServicesServer -ResourceGroupName $ResourceGroupName -Name $AnalysisServerName -Sku "S1"
}
catch
{
        Write-Error -Message $_.Exception
        throw $_.Exception
}

Write-Output "Done"

# Get new status (for testing/logging purpose only)
$NewAsSetting = Get-AzureRmAnalysisServicesServer -ResourceGroupName $ResourceGroupName -Name $AnalysisServerName
Write-Output "New tier: $($NewAsSetting.Sku.Name)"
</code>```

using Set-AzureRmAnalysisServicesServer

答:
There was a little bug in the PowerShell AzureRM.AnalysisServices module. It has been fixed in 0.4.0 (Thursday, June 08 2017)

Now the code finally works: http://microsoft-bitools.blogspot.com/2017/06/schedule-upscaledownscale-azure.html

Body:
I want to upscale and downscale my Azure Analysis Services with PowerShell (Automation Runbook), but changing the Tier (Sku) doesn't seem to work. However there are no errors. Any suggestions?

# PowerShell code
# Connect to a connection to get TenantId and SubscriptionId
$Connection = Get-AutomationConnection -Name "AzureRunAsConnection"
$TenantId = $Connection.TenantId
$SubscriptionId = $Connection.SubscriptionId

# Get the service principal credentials connected to the automation account.
$null = $SPCredential = Get-AutomationPSCredential -Name "SSISJoost"

# Login to Azure ($null is to prevent output, since Out-Null doesn't work in Azure)
Write-Output "Login to Azure using automation account 'SSISJoost'."
$null = Login-AzureRmAccount -TenantId $TenantId -SubscriptionId $SubscriptionId -Credential $SPCredential

# Select the correct subscription
Write-Output "Selecting subscription '$($SubscriptionId)'."
$null = Select-AzureRmSubscription -SubscriptionID $SubscriptionId

# Get variable values
$ResourceGroupName = Get-AutomationVariable -Name 'ResourceGroupName'
$AnalysisServerName = Get-AutomationVariable -Name 'AnalysisServerName'

# Get old status (for testing/logging purpose only)
$OldAsSetting = Get-AzureRmAnalysisServicesServer -ResourceGroupName $ResourceGroupName -Name $AnalysisServerName

try
{
    # changing tier
    Write-Output "Upgrade $($AnalysisServerName) to S1. Current tier: $($OldAsSetting.Sku.Name)"
    Set-AzureRmAnalysisServicesServer -ResourceGroupName $ResourceGroupName -Name $AnalysisServerName -Sku "S1"
}
catch
{
        Write-Error -Message $_.Exception
        throw $_.Exception
}

Write-Output "Done"

# Get new status (for testing/logging purpose only)
$NewAsSetting = Get-AzureRmAnalysisServicesServer -ResourceGroupName $ResourceGroupName -Name $AnalysisServerName
Write-Output "New tier: $($NewAsSetting.Sku.Name)"

using Set-AzureRmAnalysisServicesServer


问:
Javascript append to url if not null
I want to append the values if they are not null to the link. It doesn't allow the if in the string, so what should i do instead?     </p>

```<code>    var age = $('#age').val();
    var fn = $('#fn').val();
    var ln = $('#ln').val();
    var city = $('#city').val();
    var country = $('#country').val();

    var link = "https://mysre.com/articles/index.php?title=man-sets-biggest-pizza-record" if(age !=null){ "&age=" + age + } "&fn=" + fn + "&ln=" + ln + "&city=" + city + "&country=" + country;
</code>```

答:
There are a number of ways to solve this.

The most obvious is just to build your link piece by piece.

```<code>var a = 1;
var b = null;
var c = 5;

var str = '';
if (a) {
  str += a + '&';
}

if (b) {
  str += b + '&';
}

// ... and so on
</code>```

A much cleaner solution I prefer is to actually put everything into an array or object, then build your string from that.

```<code>var data = {
    a: 1,
    b: null,
    c: 5
};

var str = 'http://myarray.com/?' +
  Object.keys(data)
    .filter(function (key) { return data[key] })
    .map(function (key) { return key + '=' + data[key] }).join('&');
</code>```

Object.keys(data) will give you an array like ['a', 'b', 'c'] (the keys from the object).

filter() will go through and build a new array from any values that return a truthful value. In this case, the resulting array would be ['a', 'c'] ('b' got removed because it's value is null, which is a falsey value).

map() will then loop through each of those, and then build a new array from the returned value of each call. That would look like this: ['a=1', 'c=5'].

Finally, join('&') will join all the values in the array into one string: a=1&c=5, which we can just add to the rest of the string.

Another option would be to use ternary operators in the string (a ? a : ''), but this doesn't scale well with lots of values.

Title: Javascript append to url if not null

Body:
I want to append the values if they are not null to the link. It doesn't allow the if in the string, so what should i do instead?

    var age = $('#age').val();
    var fn = $('#fn').val();
    var ln = $('#ln').val();
    var city = $('#city').val();
    var country = $('#country').val();

    var link = "https://mysre.com/articles/index.php?title=man-sets-biggest-pizza-record" if(age !=null){ "&age=" + age + } "&fn=" + fn + "&ln=" + ln + "&city=" + city + "&country=" + country;

Body:
There are a number of ways to solve this.

The most obvious is just to build your link piece by piece.

var a = 1;
var b = null;
var c = 5;

var str = '';
if (a) {
  str += a + '&';
}

if (b) {
  str += b + '&';
}

// ... and so on

A much cleaner solution I prefer is to actually put everything into an array or object, then build your string from that.

var data = {
    a: 1,
    b: null,
    c: 5
};

var str = 'http://myarray.com/?' +
  Object.keys(data)
    .filter(function (key) { return data[key] })
    .map(function (key) { return key + '=' + data[key] }).join('&');

Object.keys(data) will give you an array like ['a', 'b', 'c'] (the keys from the object).

filter() will go through and build a new array from any values that return a truthful value. In this case, the resulting array would be ['a', 'c'] ('b' got removed because it's value is null, which is a falsey value).

map() will then loop through each of those, and then build a new array from the returned value of each call. That would look like this: ['a=1', 'c=5'].

Finally, join('&') will join all the values in the array into one string: a=1&c=5, which we can just add to the rest of the string.

Another option would be to use ternary operators in the string (a ? a : ''), but this doesn't scale well with lots of values.


问:
Mobile App Authentication
I have created a mobile app that uses my web api (so I own both the app and the api). To do this, I have used oauth2 user credentials grant - as per: https://bshaffer.github.io/oauth2-server-php-docs/grant-types/user-credentials/

This allows a user to login to the app using there normal website credentials (username / password). The app then receives a bearer token from the website, this bearer token is used to interact with the web api.

My question is, how do I limit my web api so that ONLY my app can use it? At this moment, others could develop other apps that use my api as the app itself isnt authorized (its just using the username/password of the website users).

Do apps get given a unique id by the play store / iOS when published? that I can use to authenticate the app making the api requests?

Any help appreciated.

Cheers,
Ollie

答:
Because anything on the client side is intrinsically compromised, we must look deeper into what determines the authenticity of a client. The most obvious, of course, would be the client secret. However, since this is a client-side app, that's a non-starter because anyone with reasonable know-how could inspect the source to find it.

However, what many people overlook is that a client also has a specific, unique redirect URI that is determined when it is configured. Thus, if you register your redirect URI with the platform (iOS, Android, etc.), then only your client will be capable of successfully completing the flow.

Unfortunately, that's not enough to prevent truly dedicated attackers. If an attacker manages to get an app installed on the client's device and registers the redirect URI, it could intercept the authorization tokens and partake in the flow:

```<code>+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
| End Device (e.g., Smartphone)  |
|                                |
| +-------------+   +----------+ | (6) Access Token  +----------+
| |Legitimate   |   | Malicious|<--------------------|          |
| |OAuth 2.0 App|   | App      |-------------------->|          |
| +-------------+   +----------+ | (5) Authorization |          |
|        |    ^          ^       |        Grant      |          |
|        |     \         |       |                   |          |
|        |      \   (4)  |       |                   |          |
|    (1) |       \  Authz|       |                   |          |
|   Authz|        \ Code |       |                   |  Authz   |
| Request|         \     |       |                   |  Server  |
|        |          \    |       |                   |          |
|        |           \   |       |                   |          |
|        v            \  |       |                   |          |
| +----------------------------+ |                   |          |
| |                            | | (3) Authz Code    |          |
| |     Operating System/      |<--------------------|          |
| |         Browser            |-------------------->|          |
| |                            | | (2) Authz Request |          |
| +----------------------------+ |                   +----------+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
</code>```

Thus, RFC 7636 sets forth the Proof Key for Code Exchange by OAuth Public Clients (PKCE, or "pixy") extension to the OAuth2 framework. Essentially, PKCE works by letting the client tell the authorization server know how to associate the code with a particular set of materials, like proof of possession but reduced in scope.

The client sends an additional two parameters when requesting an authorization code: a code challenge, and a code challenge method. The code challenge is formed from a cryptographically random string called the code verifier. The code verifier, along with the code challenge method, is used to bind the issued authorization code to the authorization request.

```<code>                                             +-------------------+
                                             |   Authz Server    |
   +--------+                                | +---------------+ |
   |        |--(A)- Authorization Request ---->|               | |
   |        |       + t(code_verifier), t_m  | | Authorization | |
   |        |                                | |    Endpoint   | |
   |        |<-(B)---- Authorization Code -----|               | |
   |        |                                | +---------------+ |
   | Client |                                |                   |
   |        |                                | +---------------+ |
   |        |--(C)-- Access Token Request ---->|               | |
   |        |          + code_verifier       | |    Token      | |
   |        |                                | |   Endpoint    | |
   |        |<-(D)------ Access Token ---------|               | |
   +--------+                                | +---------------+ |
                                             +-------------------+
</code>```

Most OAuth2 providers implement the PKCE flow, and there are plenty of online resources that go into more detail. Start with the RFC, and if you need clarification check out some other resources:

http://lutando.net/2016/12/how-does-proof-key-for-code-exchange-pkce-by-oauth-work/

Title: Mobile App Authentication

Body:
Because anything on the client side is intrinsically compromised, we must look deeper into what determines the authenticity of a client. The most obvious, of course, would be the client secret. However, since this is a client-side app, that's a non-starter because anyone with reasonable know-how could inspect the source to find it.

However, what many people overlook is that a client also has a specific, unique redirect URI that is determined when it is configured. Thus, if you register your redirect URI with the platform (iOS, Android, etc.), then only your client will be capable of successfully completing the flow.

Unfortunately, that's not enough to prevent truly dedicated attackers. If an attacker manages to get an app installed on the client's device and registers the redirect URI, it could intercept the authorization tokens and partake in the flow:

+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
| End Device (e.g., Smartphone)  |
|                                |
| +-------------+   +----------+ | (6) Access Token  +----------+
| |Legitimate   |   | Malicious|<--------------------|          |
| |OAuth 2.0 App|   | App      |-------------------->|          |
| +-------------+   +----------+ | (5) Authorization |          |
|        |    ^          ^       |        Grant      |          |
|        |     \         |       |                   |          |
|        |      \   (4)  |       |                   |          |
|    (1) |       \  Authz|       |                   |          |
|   Authz|        \ Code |       |                   |  Authz   |
| Request|         \     |       |                   |  Server  |
|        |          \    |       |                   |          |
|        |           \   |       |                   |          |
|        v            \  |       |                   |          |
| +----------------------------+ |                   |          |
| |                            | | (3) Authz Code    |          |
| |     Operating System/      |<--------------------|          |
| |         Browser            |-------------------->|          |
| |                            | | (2) Authz Request |          |
| +----------------------------+ |                   +----------+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+

Thus, RFC 7636 sets forth the Proof Key for Code Exchange by OAuth Public Clients (PKCE, or "pixy") extension to the OAuth2 framework. Essentially, PKCE works by letting the client tell the authorization server know how to associate the code with a particular set of materials, like proof of possession but reduced in scope.

The client sends an additional two parameters when requesting an authorization code: a code challenge, and a code challenge method. The code challenge is formed from a cryptographically random string called the code verifier. The code verifier, along with the code challenge method, is used to bind the issued authorization code to the authorization request.

                                             +-------------------+
                                             |   Authz Server    |
   +--------+                                | +---------------+ |
   |        |--(A)- Authorization Request ---->|               | |
   |        |       + t(code_verifier), t_m  | | Authorization | |
   |        |                                | |    Endpoint   | |
   |        |<-(B)---- Authorization Code -----|               | |
   |        |                                | +---------------+ |
   | Client |                                |                   |
   |        |                                | +---------------+ |
   |        |--(C)-- Access Token Request ---->|               | |
   |        |          + code_verifier       | |    Token      | |
   |        |                                | |   Endpoint    | |
   |        |<-(D)------ Access Token ---------|               | |
   +--------+                                | +---------------+ |
                                             +-------------------+

Most OAuth2 providers implement the PKCE flow, and there are plenty of online resources that go into more detail. Start with the RFC, and if you need clarification check out some other resources:

http://lutando.net/2016/12/how-does-proof-key-for-code-exchange-pkce-by-oauth-work/


答: Run Keyword If    '${TEST_NAME}'=='<your_test_name>'   <Keyword>   <args>

Title: How to use run a keyword if testcasename is equal to abc in robotframework


问:
Sending the HL message from dot net application to mirth connect
I want  to connect Mirth  application to our dot net application  to  send HL7 message.I am using windows 7 32 Bit  and mirth v 3.4.2.8129 .  I have connected the mirth application  using TCP and Port Number but when we send the data to mirth connect then its not visible in  mirth connect  and also does not show any error in connectivity Please tell me required setting to be done in Mirth connect and our Dot net application</p>

答: When sending TCP/IP messages make sure your message contains the proper HL7 Transports otherwise Mirth might think the message isn't complete and is listening for more data. Make sure the message has a vertical tab (0x0B) before the MSH Segment followed by a trailing field separator (0x1C) and carriage return (0x0D) after the last segment.</p>


问:
Cannot resolve com.google.firebase:firebase-core:10.2.6
I'm trying to add Firebase support for my app

i added classpath 'com.google.gms:google-services:3.1.0'

to project level gradle file and added

```<code>    compile 'com.google.firebase:firebase-auth:10.2.6'
</code>```

and

```<code>apply plugin: 'com.google.gms.google-services'
</code>```

when i sync i get

when i try to clean the project i get

```<code>    Error:A problem occurred configuring project ':app'.
</code>```

Could not resolve all dependencies for configuration ':app:_debugCompile'.
  Could not find com.google.firebase:firebase-auth:10.2.6.
       Searched in the following locations:
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           https://jcenter.bintray.com/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           https://jcenter.bintray.com/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
  Could not find com.google.firebase:firebase-core:10.2.6.
       Searched in the following locations:
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.pom
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.jar
           https://jcenter.bintray.com/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.pom
           https://jcenter.bintray.com/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.jar

Could not find com.google.firebase:firebase-auth:10.2.6.
       Searched in the following locations:
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           https://jcenter.bintray.com/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           https://jcenter.bintray.com/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar

i have updated google play services to latest version and it's still not working.
i tried invalidate cache & restart..

how do i solve this?
thanks for any help.

答:
In Android Studio, the "Google Play services" developer tools component version 40 will get you access to Firebase and Play dependencies version 10.2.6.  At this moment, there is now also version 41 that makes version 11.0.0 of the dependencies available.

Please check your versions and try again.

Body:
I'm trying to add Firebase support for my app

i added classpath 'com.google.gms:google-services:3.1.0'

to project level gradle file and added

    compile 'com.google.firebase:firebase-auth:10.2.6'

and

apply plugin: 'com.google.gms.google-services'

when i sync i get

when i try to clean the project i get

    Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'.
  Could not find com.google.firebase:firebase-auth:10.2.6.
       Searched in the following locations:
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           https://jcenter.bintray.com/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           https://jcenter.bintray.com/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
  Could not find com.google.firebase:firebase-core:10.2.6.
       Searched in the following locations:
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.pom
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.jar
           https://jcenter.bintray.com/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.pom
           https://jcenter.bintray.com/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-core/10.2.6/firebase-core-10.2.6.jar

Could not find com.google.firebase:firebase-auth:10.2.6.
       Searched in the following locations:
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           https://jcenter.bintray.com/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           https://jcenter.bintray.com/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/android/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.pom
           file:/C:/Users/Adi/sdk/extras/google/m2repository/com/google/firebase/firebase-auth/10.2.6/firebase-auth-10.2.6.jar

i have updated google play services to latest version and it's still not working.
i tried invalidate cache & restart..

how do i solve this?
thanks for any help.


问:
RedirectMatch syntax to simplify these entries
I'm looking to prune down my redirects when dealing with old sub-folders and possible iterations people are linking to. Right now, I'm doing this:

```<code>RedirectMatch 301 (?i)/old-sub-folder/index.html$ https://www.website.com/new-place/
RedirectMatch 301 (?i)/old-sub-folder/$ https://www.website.com/new-place/
RedirectMatch 301 (?i)/old-sub-folder$ https://www.website.com/new-place/
</code>```

So it's the same page, but if I don't add each version here one will go to a 404 page. Is there a way to combine this into one line?

答:
According to Apache - Regular Expression (Regex),

Apache uses Perl Compatible Regular Expressions provided by the PCRE library.

This means, you can build a regular expression with the common prefix /old-sub-folder and an optional trailing part (?:/|/index.html)?, e.g.

```<code>RedirectMatch 301 (?i)/old-sub-folder(?:/|/index.html)?$ https://www.website.com/new-place/
</code>```

Although, I'm not sure, if this is really an improvement. Having three separate simple regular expressions might be more readable (and maintainable) than one more complex expression.

Body:
I'm looking to prune down my redirects when dealing with old sub-folders and possible iterations people are linking to. Right now, I'm doing this:

RedirectMatch 301 (?i)/old-sub-folder/index.html$ https://www.website.com/new-place/
RedirectMatch 301 (?i)/old-sub-folder/$ https://www.website.com/new-place/
RedirectMatch 301 (?i)/old-sub-folder$ https://www.website.com/new-place/

So it's the same page, but if I don't add each version here one will go to a 404 page. Is there a way to combine this into one line?

Body:
According to Apache - Regular Expression (Regex),

Apache uses Perl Compatible Regular Expressions provided by the PCRE library.

This means, you can build a regular expression with the common prefix /old-sub-folder and an optional trailing part (?:/|/index.html)?, e.g.

RedirectMatch 301 (?i)/old-sub-folder(?:/|/index.html)?$ https://www.website.com/new-place/

Although, I'm not sure, if this is really an improvement. Having three separate simple regular expressions might be more readable (and maintainable) than one more complex expression.


问:
laravel database pass data blade
I'm new to Laravel and trying to figure out why one of my pages is not pulling data from the database. Running locally using a setup based on the project in Laracasts. I'm on Laravel 5.4 running PHP 7 and MySQL on OS X Sierra.

I'm getting this error: Undefined Variable: hashtags (in my hashtags.blade.php file)

I have this code hashtags.blade.php, designed to pull entries from a database:

```<code><h2>Your Hashtags</h2>

    <table>
        <tr>
            <th>Hashtag</th>
            <th>List Name</th>
            <th>List Members Added</th>
        </tr>

    @foreach($hashtags as $hashtag)

        <tr>
            <td>{{ $hashtag -> tagname }}</td>
            <td>{{ $hashtag -> listname }}</td>
            <td>Count</td>
        </tr>

    @endforeach

    </table>
</code>```

In my web.php routes file:

```<code>Route::get('/hashtags', function () {

    $hashtags = DB::table('hashtags')->get();
    return view('hashtags');
});
</code>```

I have the database connected through the .env file and the overall connection in Laravel seems to be working, just not on this page. I was under the impression that the code in web.php defines the variable $hashtags and passes it to hashtags.blade.php. Apparently I'm missing something here.

I searched and found some other questions about passing data to the blade files, but nothing quite like this issue. Thanks!

答:
You need pass variable to template. Try:

```<code>return view('hashtags', [
    'hashtags' => $hashtags
]);
</code>```

or

```<code>return view('hashtags', compact('hashtags'));
</code>```

Title: laravel database pass data blade

Body:
I'm new to Laravel and trying to figure out why one of my pages is not pulling data from the database. Running locally using a setup based on the project in Laracasts. I'm on Laravel 5.4 running PHP 7 and MySQL on OS X Sierra.

I'm getting this error: Undefined Variable: hashtags (in my hashtags.blade.php file)

I have this code hashtags.blade.php, designed to pull entries from a database:

Your Hashtags

            Hashtag
            List Name
            List Members Added

    @foreach($hashtags as $hashtag)

            {{ $hashtag -> tagname }}
            {{ $hashtag -> listname }}
            Count

    @endforeach

In my web.php routes file:

Route::get('/hashtags', function () {

    $hashtags = DB::table('hashtags')->get();
    return view('hashtags');
});

I have the database connected through the .env file and the overall connection in Laravel seems to be working, just not on this page. I was under the impression that the code in web.php defines the variable $hashtags and passes it to hashtags.blade.php. Apparently I'm missing something here.

I searched and found some other questions about passing data to the blade files, but nothing quite like this issue. Thanks!

Body:
You need pass variable to template. Try:

return view('hashtags', [
    'hashtags' => $hashtags
]);

or

return view('hashtags', compact('hashtags'));