RStudio cannot find fonts to be used in plotting

I’m attempting to plot a simple density plot in RStudio. The plot itself shows up, but with no text and this error message:

50: In doTryCatch(return(expr), name, parentenv, handler) :
no font could be found for family "Arial"

I’ve tried Googling the answer and several people seem to have had the same problem, without any solutions being found.

I’m running RStudio (version 1.0.153) on a MacBook Pro (High Sierra, 10.13.3)

Here’s the full code I am running:

lim <- vector()
xn <- vector()
for (j in 1:1000) {
  ek <- rexp(10000,1)
  i <- 1:10000
  xn <- 1/sqrt(i) * sum(ek) - sqrt(i)
  lim[j] <- xn[10000]
}

plot(density(lim))

I’ve already tried changing fonts (Helvetica doesn’t work either) and resetting the graphics with dev.off().

How do I fetch comments with Laravel Pagination that are not redundant?

My main problem:

If user writes a comment and then decides to load more comments, he will get to see at least one redundant comment.

Causation:

Via Laravel Pagination the script loads via Axios the last 10 items. After adding one comment and fetching again the next 10 items, the “order” is shifted of one element. Thus, getting one repeated element.


Tries to fix it:

First Try:
I tried with Array.prototype.includes() or Lodash Includes:

 data(){
    return { items: [] };
 }
 ...
 addWithoutRedudancy(newItems){
    for(let item of newItems){
        if( ! _.includes( this.items, item ) ) this.items.push(item);
    }
 }

Occurring problems:

  1. Even though I seemingly have two of the same objects, I get in my console false if I check:

    $vm0.items[10] == $vm0.items[11] //False even though objects look the same, and actually are (looking to all properties)

    That is a huge problem, because Includes can’t find the redundant Object! I’ve no clue why these objects are saved differently. Perhaps because I fetch them over axios on two different timings?

  2. But even if it would work, after the user wrote for example 8 new comments, he would get only 2 new comments from the pagination (controller) back, but should get of course the next 10 comments.

Second Try

/**
 * Fetch all relevant comments.
 *
 * @param string $username
 * @param Selllink $selllink
 */
public function index($username, $selllink)
{
    //Route::prefix('/{username}/{selllink}
    //Sellink gets the model of sell and loads all comments to that sell.
    //get me the latest first (we want to see the current comments)
    //take only 10 coments with paginatation

    return $selllink->sell->comments()
                ->latest()
                ->offset($addedCommentsNumber??) //that can't work...
                ->paginate(10);
}

Occurring problems:
I cannot really offset the whole table. I need to offset the paginated ones and add the missing ones again.


Conclusion

There must be a much better way to do this. But I just don’t know how.


More details explanation (if needed):

I have a Vue Comment Component that fetches the data from my CommentController with Pagination:

methods: {
        fetch(){
            axios.get(this.url()).then(this.refresh);
        },
        url() {
            this.page++;
            return `${location.pathname}/comments?page=${this.page}`;
        },
        refresh({data}){
            this.dataSet = data;
            this.addWithoutRedudancy(data.data);
        },
}

If the users want to get more Comments, they just click on the “load more” button and I’m getting the comments loaded

Grails 3.3.1 and reloading beans with properties defined in resources.groovy

I have a class in src/main/groovy (ApiService.groovy). I am defining this as a spring bean in resources.groovy as I have multiple implementations.

There is a single property for this bean:

apiService(ApiService) {
    server = '${server.address}'
}

Properties are defined in an external properties file.

All is fine when the application is first started.

However, if I change the file ApiService.groovy, the server property is null after ApiService gets reloaded.

I am using the following when starting the app with run-app:

-reloading -Ddisable.auto.recompile=false

I have also tried running Application.groovy, running the Gradle task bootRun and numerous other options for reloading but to no avail.

I have also tried using constructor based args instead, using resources.xml instead of resources.groovy but the same outcome.

Also, just for testing, I used the @Value annotation for the server property in the class itself and all was fine after a reload.

I’m running within Intellij but get the same behaviour running from the command line.

Maybe this shouldn’t actually work but any suggestions/advice would be greatly appreciated to save me spending any more time on it.

optimize my query mysql – PHP

I have this query that takes more than 10 seconds,
The most bulky table is requetes, the clause where depends on filter:

SELECT SQL_CALC_FOUND_ROWS
  requetes.id AS thread_id,
  requetes.id AS thread_id2,  
  CONCAT_WS("/", SUBSTR(requetes.id, 5, 2), SUBSTR(requetes.id, 3, 2), SUBSTR(requetes.id, 1, 2)) AS thread_create_date, 
  DATE_FORMAT(create_date, "%d/%m/%Y %H:%i") AS create_date, 
  IF(UNIX_TIMESTAMP(requetes.date_objectif_requete) = 0, NULL, DATE_FORMAT(requetes.date_objectif_requete, "%d/%m/%Y %H:%i:%S")) AS thread_target_date,
  IF(UNIX_TIMESTAMP(requetes.date_objectif_requete) = 0, NULL, DATE_FORMAT(requetes.date_objectif_requete, "%Y%m%d")) AS int_thread_target_date,

  requetes.prenom AS customer_first_name,
  requetes.nom AS customer_last_name,
  requetes.subject AS subject_action,
  requetes.ident_e AS code_customer,
  CONCAT_WS(" ", UPPER(requetes.nom), requetes.prenom, requetes.pseudo) AS complete_customer_name,
  requetes.type_rs AS type_rs,
  themes_sous.id AS thread_type_id,
  requetes.cp AS zip_code,
  requetes.libelle_pc_origine AS libelle_pc_origine,
  themes_sous.libelle AS thread_type_label,
  themes_sous.action_page AS thread_type_target_url,
  agents.prenom AS user_first_name,
  agents.nom AS user_last_name,
  req_agent.id_agent AS code_user,
  CONCAT_WS(" ", UPPER(agents.nom), agents.prenom) AS complete_user_name,
  (1 - statut_inverse) AS done,
  archive AS archived,
  num_messages,
  themes.libelle AS libelle_categ

  FROM requetes
  LEFT OUTER JOIN themes_sous
  ON requetes.id_ss_theme = themes_sous.id
  LEFT OUTER JOIN req_agent
  ON requetes.id = req_agent.id_requete
  LEFT OUTER JOIN agents
  ON req_agent.id_agent = agents.id
  LEFT OUTER JOIN themes
  ON themes.id = themes_sous.id_theme  
  WHERE requetes.client_identifier=4
  AND themes_sous.client_identifier=4
  AND requetes.statut_inverse = 1 AND DATE_FORMAT(requetes.date_objectif_requete, "%Y%m%d") <> 20171215 AND NOT (DATE_FORMAT(requetes.date_objectif_requete, "%Y%m%d") > 20171215) AND ( req_agent.id_agent_origine = "5087050" )  AND requetes.date_objectif_requete IS NOT NULL AND requetes.date_objectif_requete <> "0000-00-00 00:00:00" 
  ORDER BY requetes.id LIMIT 0, 25;

The explain of this query is :
explain of the query

config of the most bulky table

thanks for your help

One touch on EditText inside TextInputLayout generate two or more events

I have one EditText inside a TextInputLayout:

    <android.support.design.widget.TextInputLayout
    android:id="@+id/inputLayoutDoB"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/stepViewIndicator"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"
    app:errorTextAppearance="@style/Text.Appearance.App.ErrorText"
    android:textColorHint="@color/colorAccentLight">

    <android.support.v7.widget.AppCompatEditText
        android:id="@+id/inputDoB"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableStart="@drawable/ic_profile_calendar"
        android:drawablePadding="@dimen/form_drawable_margin"
        android:hint="@string/strHintDoB"
        android:textSize="@dimen/input_text"
        android:inputType="date"
        android:textColor="@android:color/white"/>

</android.support.design.widget.TextInputLayout>

My RelativeLayout is designed to prevent disable view autofocus:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorAccent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:focusableInTouchMode="true">

Now, I need to manage touch gesture on the above EditText, to popup a simple AlertDialog:

inputDoB = findViewById(R.id.inputDoB);
// *** PREVENT SOFT KEYBOARD APPEARANCE
inputDoB.setInputType(InputType.TYPE_NULL);
inputDoB.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {

            AlertDialog alertDialog = new 
            AlertDialog.Builder(ProfileActivity_Step1.this).create();
            alertDialog.setTitle("Alert");
            alertDialog.setMessage("Alert message to be shown");
            alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            alertDialog.show();
            return false;
        }
    });

All seem to work fine, but when I click/touch the EditText, TWO or MORE AlertDialog appear.

Is this behavior related to the EditText container (TextInputLayout)?
If yes, how can I address this issue?

Any idea?

Many thanks for your support

How is the training accuracy in Keras determined for every epoch?

I am training a model in Keras with as follows:

model.fit(Xtrn, ytrn batch_size=16, epochs=50, verbose=1, shuffle=True,
          callbacks=[model_checkpoint], validation_data=(Xval, yval))

The fitting output looks as follows:

enter image description here

As shown in the model.fit I have a batch size of 16 and a total of 8000 training samples as shown in the output. So from my understanding, training takes place every 16 batches. Which also means training is ran 500 times for a single epoch (i.e., 8000/16 =500)

So let’s take the training accuracy printed in the output for Epoch 1/50, which in this case is 0.9381. I would like to know how is this training accuracy of 0.9381 derived.

Is it the:

i) the mean training accuracy taken as the average from the 500 times training is performed for every batch ?

OR,

ii) is it the best (or max) training accuracy from out of the 500 instances the training procedure is ran?

Testing Phoenix controllers that are in nested folders

I have an elixir umbrella application which contains a phoenix app and an elixir app. The app is working as expected but I am having an issue testing one of the controllers.

The tests in the file will not run when I run the tests. It looks like they are somehow being skipped in the testing process.

The controller file looks something like…

defmodule AppName.File.Path.NameOfController do
  def index(conn, params) do
    render(conn, "index.html")
  end
end

The test file is fairly simple as well and looks something like…

defmodule AppName.File.Path.NameOfControllerTest do
  test "GET /"the_url/I/want", %{conn: conn} do
    conn = get conn, some_path(conn, :index)
    assert html_response(conn, 200) =~ "Some html"
  end
end

All the tests in my project run with the exception on this one file. I thought that it might have something to do with the file path but I cannot see any reason why this would effect the test. I can also go to the endpoint when I run the application.

Any help would be appreciated. Thanks in advance.

model_function on backpack CRUD

Since I want my data to be encrypted in my database, how can I get this to be done using a model_function? I’ve manually encrypted prior to trying to do this and attempting to show the decrypted result on my edit page but to no avail?

I’ve currently got the following code for my controller:

$this->crud->addField([
    'name' => 'password',
    'label' => 'Password',
    'model_function' => 'decryptPassword'
]);

And this for my model:

public function decryptPassword() {
    return decrypt($this->password);
}

how to change the default location of s3 bucket for aws log rotation?

Is it possible to change the S3 log bucket. I know the default location is similar to the below.

s3://elasticbeanstalk-us-east-1-0123456789012/resources/environments/logs/publish/e-mpcwnwheky/i-0a1fd158

But I want to point to a different location.

I checked the publishlogs under /etc/cron.d/publishlogs, it has the below path.

10,30,50 * * * * root publishLogs.py –de-dupe –conf-path ‘/opt/elasticbeanstalk/tasks/publishlogs.d/*’ –location-prefix resources/environments/logs/publish/ –num-concurrent 2

Please let me know if there is a way to change it to preferred s3 location.

Also , how to send only specific logs from httpd to S3 and not it should not send awslogs along with that.

Thanks in Advance!

How do I release Adobe Flex objects referenced via ObjectInput:readObject()

I am seeing a list of objects in an ArrayCollection that have one reference that I can’t seem to get rid of – in the application profiler the Allocation trace shows that the referencing method is ObjectInput:readObject(). I have removed all other references to the objects by nulling out various things along the way, but I can’t figure out what is triggering this one – I suspect it has something to do with a remote object, but I’m not sure. The full allocation trace is below:

ObjectInput.readObject()
    mx.collections:ArrayList:readExternal()
    mx.collections:ArrayCollection:readExternal()
    ObjectInput:readObject()
    mx.messaging.messages:AbstractMessage:readExternal()
    mx.messaging.messages:AsyncMessage:readExternal()
    mx.messaging.messages:AcknolwedgeMessage:readExternal()

Does anyone know of a way to get rid of that reference? Where it might be coming from?