Wednesday, July 14, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


File cache busting/revviing of angular static assets

Posted: 14 Jul 2021 07:56 AM PDT

Hi i need to aply file revving to cache the files under the assets folder in my angular 12 project. This process is already being aplied by angular build process by specifying the "outputHashing": "all" option. But this option only filters the polyfills, .css, etc. generated files. It does not filter the files under /assets. Is there a way to do this using the angular build process or an external library.

Can`t read file from AWS S3 in Heroku project

Posted: 14 Jul 2021 07:56 AM PDT

I have deployed my python telegram bot on Heroku. Bot have to use Nemo ML model, because of my model was too large I store it on AWS S3 by this instruction: https://devcenter.heroku.com/articles/s3. I tried to read model by link from AWS:

import nemo.collections.asr as nemo_asr

quartznet=nemo_asr.models.EncDecCTCModel.restore_from(restore_path="http://s3.amazonaws.com/dataforgolosbot/QuartzNet15x5_golos.nemo")

but i got this error:

2021-07-14T14:41:02.019040+00:00 app[worker.1]: Traceback (most recent call last): 2021-07-14T14:41:02.019051+00:00 app[worker.1]: File "/app/main.py", line 4, in 2021-07-14T14:41:02.019209+00:00 app[worker.1]: quartznet = nemo_asr.models.EncDecCTCModel.restore_from(restore_path="http://s3.amazonaws.com/dataforgolosbot/QuartzNet15x5_golos.nemo") 2021-07-14T14:41:02.019215+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nemo/core/classes/modelPT.py", line 474, in restore_from 2021-07-14T14:41:02.019469+00:00 app[worker.1]: raise FileNotFoundError(f"Can't find {restore_path}") 2021-07-14T14:41:02.019528+00:00 app[worker.1]: FileNotFoundError: Can't find http://s3.amazonaws.com/dataforgolosbot/QuartzNet15x5_golos.nemo 2021-07-14T14:41:03.220793+00:00 heroku[worker.1]: Process exited with status 1 2021-07-14T14:41:03.350467+00:00 heroku[worker.1]: State changed from up to crashed

What should I use redux-saga or redux-thunk in 2021?

Posted: 14 Jul 2021 07:56 AM PDT

Which one should I use? For more context I use redux-toolkit. Advices to help understand which tool fits better are appreciated

Auto-Update Enterprise (intern) Apps

Posted: 14 Jul 2021 07:56 AM PDT

So, is there a realiable way to update enterprise/intern apps remotelly? I work in a company that spreads across my state, including some areas that the access is dificult, so I can't send someone to locally update the app everytime there's a new release.

I'm working with Android/Java at the moment, and we also use Azure DevOps to store the repositories. I tryied App Center from Microsoft but didn't understood if that could help me update my app or not. Also, we don't want to publish the application to the PlayStore and make it public. Unless, of course, if that's the only way.

Thank you for your time reading this, I will keep searching something related to this and also share here any solution that I can find.

ReactJS: Creating a "dynamic" render of Row and Col

Posted: 14 Jul 2021 07:56 AM PDT

I have an array of object with "id", "name", "value" that I pass to a component and it divided in row and col in this way:

export const RenderDetailRow = props => {    const columns = [];    props.content.forEach((content, idx) => {      columns.push(        <div className="col-sm py-3" key={`item_${idx}`}>          <b>{content.name + ': '}</b>          <Input type="text" name={content.name} id={content.id} readOnly value={content.value} />        </div>      );        if ((idx + 1) % props.display[0].number === 0) {        columns.push(<div className="w-100"></div>);      }    });      return (      <div className="row" style={{ margin: 30 }}>        {columns}      </div>    );  };  

I have two kind of problem, the first:

  1. Each child in a list should have a unique "key" prop.

I have inserted the key but I have this error.

  1. If the number of field is odd I have a long Input, it is possible to create a empty field o something like this?

Problem2

For example Date and Created By has every one 1/2 of the space, while Last Modified has 2/2. How can I do?

Thank you

Relations orWhereDoesntHave dont work, how to fix?

Posted: 14 Jul 2021 07:55 AM PDT

There is a relations "shop" with "setting_limits". Need select all the products that fall under all the settings. The store can set the sales settings, or it can not set, then you need to show all the products of this store.

 ->whereHas('shop', function ($query) {                          $query->whereHas('setting_limits', function ($query) {                              $query->where(function ($q) {                                  $q->where('type', '=' ,'sell_selected_countries')                                      ->where('county_id', '=', 4);                              })                                  ->orWhere(function ($q) {                                      $q->where('type', '=' , 'sale_certain_countries')                                          ->where('county_id', '!=', 4);                                  })                                  ->orWhere(function ($q) {                                      $q->where('type',  '=' ,'sale_certain_areas')                                          ->where('area_id', '!=', 5);                                  })                                  ->orWhere(function ($q) {                                      $q->where('type', '=' , 'sell_selected_areas')                                          ->where('area_id', '=', 5);                                  });                          })->orWhereDoesntHave('setting_limits');                      })  I tried this, it don't work, she does not see the products of the store that have no sales limit.  

Is there any way to convert symbol names into function names?

Posted: 14 Jul 2021 07:56 AM PDT

For example callq 401400 <_ZNSaIcEC1Ev@plt> I want to know the name of this function

My compiler is g++

HttpClient calling Endpoint with Boundry

Posted: 14 Jul 2021 07:55 AM PDT

I need to call an endpoint that requires the Request Header and Request Boday with Content-type and content-length and some other property as well which need to End with BOUNDRY.

Request Header

POST https://www.API-URL.com/ HTTP/1.1

Host: www.API-URL.com

Content-type: multipart/mixed; boundary=BOUNDARY

Content-length: 1034

Request Body

--BOUNDARY

Content-type: application/x-www-form-urlencoded

Content-length: 141

AppVersion=1.0&AcceptLicenseAgreement=Yes&ResponseType=application/x-x-pld&VersionNumber=xxx&UserId=xxxx&Password=xxxxx

--BOUNDARY

Content-type: application/x-x-binary

Content-length: 6

020020 // This the string Data which i need to post

--BOUNDARY--

How can I implement a call to this endpoint by using HttpClient?

Thanks in advance

What toolkit in Python can achieve the effect as shown in the figure

Posted: 14 Jul 2021 07:57 AM PDT

I'd like to draw a three-dimensional trajectory that can show the attitude of the plane as shown in the figure. What toolkit in Python I should learn?

enter image description here

How can i write this method ( API PHP )

Posted: 14 Jul 2021 07:57 AM PDT

Hello i problem with one task I have to write a connection method to Car API. Data are protected so i have to use api_key to get them

$url= "localhost:8000";      $apikey= 'my_api_key';      $headers = array(          'Authorization: '.$apikey      );      $ch = curl_init($url);   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);    $response = curl_exec($ch);  $result = json_decode($response);      

kotlin idiomatic way to make it simpler when pass in a nullable mutableMap

Posted: 14 Jul 2021 07:56 AM PDT

converting from java to kotlin

java code

public void logEvent(String eventName, @Nullable Map<String, String> customParams) {          if (customParams == null) {              customParams = new HashMap<>();          }          customParams.put(OTHER_REQUIRED_KEY, OTHER_REQUIRED_VALUE);          service.doLogEvent(eventName, customParams);      }  

kotlin code

    fun logEvent(eventName: String, customParams: Map<String, String>?) {          var customParamsMap = HashMap<String, String>()          if (customParams != null) {              customParamsMap.putAll(customParams)          }          customParamsMap[OTHER_REQUIRED_KEY] = OTHER_REQUIRED_VALUE          service.doLogEvent(eventName, customParamsMap)      }  

the kotlin code will create the temp map regardless if the passed in map is null or not.

is there a better way to avoid this map creation?

cannot read property 'grass' of undefined

Posted: 14 Jul 2021 07:56 AM PDT

Goal: the long array will have the values of this.token.grass in it.

module.exports = {      render: function() {        },      keyDown: function(k) {        },      level: [          [this.token./** Error Here **/grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass],          [this.token.grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass],          [this.token.grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass],          [this.token.grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass],          [this.token.grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass],          [this.token.grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass],          [this.token.grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass],          [this.token.grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass],          [this.token.grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass],          [this.token.grass, this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass,this.token.grass]      ],      NonCollidable: "$$$NonCollidable\\Main",      Collidable: "$$$Colldiable\\Main",      token: {          grass: {RenderToken: "\x1b[32m#\x1b[89m\x1b[0m", TokenType: this.NonCollidable}      }  }  

Error:

TypeError: Cannot read property 'grass' of undefined      at Object.<anonymous> (C:\Users\#\Desktop\libraries\unnamed\main.js:10:21)      at Module._compile (internal/modules/cjs/loader.js:1063:30)      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)      at Module.load (internal/modules/cjs/loader.js:928:32)      at Function.Module._load (internal/modules/cjs/loader.js:769:14)      at Module.require (internal/modules/cjs/loader.js:952:19)      at require (internal/modules/cjs/helpers.js:88:18)      at Object.pointer (C:\Users\#\Desktop\libraries\unnamed\context.js:4:76)      at ReadStream.<anonymous> (C:\Users\#\Desktop\libraries\unnamed\io.js:13:25)      at ReadStream.emit (events.js:315:20)  

Honestly, I haven't tried anything. I thought that maybe this in that context was referring to the parent array, but I don't know how to fix that either.

The code is above.

Ask constraint questions when creating image objects in Chrome Browser

Posted: 14 Jul 2021 07:57 AM PDT

I tried to create an image object by uploading an image file of 170MB Chrome Browser.

However, the error as below is occurring.

enter image description here

What's the cause?

Is there a size constraint on creating an image object?

const loadFromFile = (file: File) => {     return new Promise((resolve, reject) => {      const reader = new CustomFileReader()      reader.onload = () => resolve(reader.result)      reader.onerror = (e) => reject(e)      reader.readAsDataURL(file)    })  }    const createImage = (dataUrl) => {    return new Promise((resolve, reject) => {      const img = new Image()      img.onload = () => resolve(img)      img.onerror = (error) => {        console.log('image load error', e)        reject(e)      }      img.src = dataUrl    })  }    const load = async (file: File) => {     const dataUrl = await loadFromFile(file)     const image = await createImage(dataUrl)  }    

This is the image used for the test: https://upload.wikimedia.org/wikipedia/commons/thumb/6/68/La_crucifixi%C3%B3n%2C_by_Juan_de_Flandes%2C_from_Prado_in_Google_Earth.jpg/2560px-La_crucifixi%C3%B3n%2C_by_Juan_de_Flandes%2C_from_Prado_in_Google_Earth.jpg

I want to centre the unity camera to the top right corner

Posted: 14 Jul 2021 07:56 AM PDT

I created this code to move the camera half its width right and half its height up to make the top right the new centre, it did not work, where did I go wrong?

Camera.main.transform.position=Camera.main.ViewportToWorldPoint(new Vector2((float)0.5,(float)0.5));  

This is 2d mode by the way.

Taking month and year from column and showing last date of the month and year

Posted: 14 Jul 2021 07:55 AM PDT

So i have 2 column Year and Month and I want to take the month and the year to show in the new column and showing the last date of the month

Example : Year column = 2019, 2020, 2021 Month Column = Jan, Feb, Mar

i want the result : 31-01-2019, 29-02-2019, etc

Store text based columns data into array C++

Posted: 14 Jul 2021 07:56 AM PDT

I'm trying to store data from a text file into an array in order to use it afterwards. The problem is when there is a header for each data, how can skip a line in the middle of the text or to take it separately?

#include <iostream>  #include <fstream>        main() {      double tab[100][6] = {0};      int  i =0, j;     std::string name = "test.txt";  //   std::cout << "Enter filename: ";  //   std::cin >> name;       std::fstream file;     std::string word;     file.open(name.c_str());     std::getline(file,word); // skip the first line     while(file >> word) { //take word and print        std::cout << word << std::endl;        for(int j=0; j<=5; j++){        tab[i][j] = stoi(word);        }        i++;     }     file.close();     // displaying     for(int j = 0; j<= 40;j++){      std::cout << tab[i][0] << "\t" <<  tab[i][1] << "\t" << tab[i][2] << "\t" << tab[i][3] << "\t" << tab[i][4] << "\t" << tab[i][5];     }  }  

test.txt file

18407022  2018-07-05 00:04:02  MHAM  EIDW  42  S1REB  RYR5GW  3726  JNEIE  837B  Datum  RYR  IFR  Undefined  1  1  2018-07-05  00:15:38  2018-07-05  00:22:56  111  extended  0.0  113416.9  479798.5  -0.2  3.6  0.0  4.0  113395.2  479785.0  1.2  9.3  25.5  8.0  113352.2  479758.7  1.2  16.0  75.9  12.0  113284.9  479717.4  0.5  23.6  154.9  16.0  113189.9  479659.1  -0.5  32.2  266.3  20.0  113064.3  479582.1  -0.9  41.7  413.7  24.0  112904.9  479483.9  -0.3  52.1  600.9  18407022  2018-07-05  00:12:14  MHAM  EIDW  42  S1REB  RYR5GW  3726  JNEIE  837B  Datum  RYR  IFR  Undefined  1  1  2018-07-05  00:30:38  2018-07-05  00:42:56  111  extended  0.0  145431.6  480046.3  4533.3  180.4  0.0  4.0  144747.1  480268.2  4493.4  179.5  719.5  8.0  144059.0  480468.7  4452.0  179.0  1436.2  12.0  143368.6  480655.3  4409.8  178.7  2151.4  16.0  142677.0  480835.6  4367.6  178.6  2866.1  20.0  141985.8  481017.2  4326.1  178.8  3580.9  24.0  141295.9  481207.3  4286.1  179.0  4296.4  

Find the inverse of a pair of multi-index values in pandas dataframe

Posted: 14 Jul 2021 07:56 AM PDT

I have a dataframe with two index columns source and target. I would like to detect inverse index values i.e for a pair of values (source, target), if there exists a pair of values (target, source) then assign True to a new column called oneway. The goal is to detect oneway roads. I have tried this from this post Detect presence of inverse pairs in two columns of a DataFrame

edges_gdf["oneway"] = edges_gdf.apply(              lambda x: not edges_gdf[                  (edges_gdf["source"] == x["target"]) &                  (edges_gdf["target"] == x["source"]) &                  (edges_gdf.index != x.name)].empty, axis=1)  

but it takes many second before achievement. And I don't want to use df.iterrorws() because I have more than 100k rows.

Is there any method to answer.

The dataframe header

enter image description here my need?

Checking Blocking with `poll()`

Posted: 14 Jul 2021 07:56 AM PDT

I want to check if a file descriptor would block on a certain event and I got the idea of using poll() with a 0 timeout:

int wouldblock(int fd, short event)  {    struct pollfd pfd;    pfd.fd = fd;    pfd.events = event;    return (poll(&pfd,1,0) == 0);  }    ...    if (wouldblock(0,POLLIN)) ...  ...    

Either the stream is available, and poll() should return 1, or it would block and the timeout will kick in returning 0. (Let's set aside error checking for a moment).

It works (at least "it works on my machine") but I wonder if I did miss anything? Maybe poll() is overkill and I'm stressing the system too much?

Create new column in DataFrame based on comparison against row values

Posted: 14 Jul 2021 07:57 AM PDT

I have a dataframe that looks something like this:

df = pd.DataFrame({'a1': [1,2,3,4],                 'des_2': ['a','b','a', 'd'],                 'des_4': ['a','c','c', 'd'],                 'des_1': ['a','b','c', 'd'],                 'des_3': ['a','b','c', 'a'],                 'a2': [1,2,3,4],                 'a3': [1,2,3,4]                 })  

And I want to create a new column that shows the number of adjacent repeats of the first value, taking into account only the columns with 'des_', ordered alphabetically.

In the first row, all occurences are equal to a, so the count adds up to 4. In the second row, des_1, des_2, and des_3 are equal to b, so the cound adds up to 3. And so on.

   a1  des_2  des_4  des_1  des_3  a2  a3  count  0  1   a      a      a      a      1   1   4  1  2   b      c      b      b      2   2   3  2  3   a      c      c      c      3   3   1  3  4   d      d      d      a      4   4   2  

I have a working code, but I feel it's not very pythonic:

cols_list = sorted(df.columns.tolist())  cols_list = list(filter(lambda x: 'des_' in x, cols_list))    new_df = df[cols_list]  lists = new_df.values.tolist()  occ_list = []  for lst in lists:      first_occurrence = lst[0]      counter = 0      for occurrence in lst:          if occurrence == first_occurrence:              counter += 1          else:              break      occ_list.append(counter)      counter = 0    df['count'] = occ_list  

Any idea how to reduce it?

Thanks!

Change value of variable and check whether the value have changed

Posted: 14 Jul 2021 07:56 AM PDT

I want to check whether the text element changes on x seconds and apply the for loop and conditional structure to verify if the change is applied. If the text is still not changed it will refresh the page and check again

Cypress.Commands.add('checkApprovedStatus', (targetData) =>{      cy.get('div[class^=ui-table-scrollable-body]').contains('tr', targetData).first().parent().within(function(){          cy.get('td').eq(10).children('span[class^=customer-badge]').then(($status) =>          {              //let currStatus = $status.text()              //cy.log(currStatus)                           for(let count = 0; count <= 5; count++)              {                  let currStatus = $status.text()                  cy.log(currStatus)                                    if (currStatus === 'approved')                  {                      //if (currStatus.contains('Approved', {matchCase:false}))                      //{                      cy.log("End to end testing completed. All checks have passed!!")                      break                      //}                   }                  else                  {                      cy.reload()                      cy.wait(5000)                      $status.trigger('change')                  }               }          })      })  })  

VSCode not adding closing brackets automatically with correct settings

Posted: 14 Jul 2021 07:56 AM PDT

My vscode editor is set to automatically add closing brackets/parenthesis but does not. It started a few days ago and I havent been able to fix it. Perhaps I pressed some strange shortcut on my keyboard and toggled something. Has anyone else experienced this?

my settings.json below...

{    "workbench.colorTheme": "Ayu Mirage",    "workbench.iconTheme": "material-icon-theme",    "workbench.tree.indent": 22,    "editor.formatOnSave": true,    "editor.fontFamily": "Lig Operator Mono",    "editor.fontWeight": "350",    "editor.fontLigatures": true,    "editor.tokenColorCustomizations": {      "textMateRules": [        {          "name": "Comment",          "scope": [            "comment",            "comment.block",            "comment.block.documentation",            "comment.line",            "comment.line.double-slash",            "punctuation.definition.comment",            "entity.name.type.class", //class names            "entity.other.attribute-name",            "constant", //String, Number, Boolean…, this, super            "storage.modifier", //static keyword            "storage.type.class.js" //class keyword          ],          "settings": {            "fontStyle": "italic"          }        },        {          "scope": [            //following will be excluded from italics (VSCode has some defaults for italics)            "invalid",            "keyword.operator",            "constant.numeric.css",            "keyword.other.unit.px.css",            "constant.numeric.decimal.js",            "constant.numeric.json"          ],          "settings": {            "fontStyle": ""          }        }      ]    },    "[jsonc]": {      "editor.defaultFormatter": "esbenp.prettier-vscode"    },    "git.enableSmartCommit": true,    "typescript.updateImportsOnFileMove.enabled": "always",    "prettier.printWidth": 120,    "C_Cpp.clang_format_fallbackStyle": "WebKit",    "javascript.updateImportsOnFileMove.enabled": "always",    "editor.minimap.enabled": false,    "emmet.showSuggestionsAsSnippets": true,    "emmet.triggerExpansionOnTab": true,    "editor.fontSize": 16,    "sync.gist": "361fa31dd8a2d2e1cd53dc746d2fee48",    "vim.easymotion": true,    "vim.useSystemClipboard": true,    "vim.useCtrlKeys": true,    "vim.insertModeKeyBindings": [      {        "before": ["j", "j"],        "after": ["<Esc>"]      }    ],    "vim.leader": "<space>",    "vim.easymotionMarkerFontFamily": "Operator Mono Book",    "vim.camelCaseMotion.enable": true,    "vim.debug.loggingLevelForConsole": "info",    "vim.startofline": false,    "files.associations": {      ".env.template": "dotenv"    },    "explorer.compactFolders": false,    "[html]": {      "editor.defaultFormatter": "esbenp.prettier-vscode"    },    "todo-tree.tree.showScanModeButton": false,    "[json]": {      "editor.defaultFormatter": "esbenp.prettier-vscode"    },    "telemetry.enableCrashReporter": false,    "telemetry.enableTelemetry": false,    "viceroy.config.lastVersion": "0.42.1",    "files.watcherExclude": {      "**/build/**": true,      "**/.git/objects/**": true,      "**/.git/subtree-cache/**": true,      "**/node_modules/**": true,      "**/.hg/store/**": true    },    "files.exclude": {      ".viceroy": true,      "apollo-overrides": true,      "release-info": true,      "src/*/build": false,      "build": true,      "env": true,      "packageInfo*": true,      ".bemol": true,      "**/.git": true,      "**/.svn": true,      "**/.hg": true,      "**/CVS": true,      "**/.DS_Store": true    },    "search.exclude": {      "env": true,      "src/*/build": true,      "build": true,      "**/node_modules": true,      "**/bower_components": true,      "**/*.code-search": true    },    "viceroy.config.internal.autoUpdate": "weekly",    "security.workspace.trust.untrustedFiles": "open",    "[typescriptreact]": {      "editor.defaultFormatter": "esbenp.prettier-vscode"    },    "[typescript]": {      "editor.defaultFormatter": "esbenp.prettier-vscode"    },    "editor.tabSize": 2  }  

Why is MLFLow unable to log metrics, artifacts while using MLFlow Project in Docker environment?

Posted: 14 Jul 2021 07:57 AM PDT

I am trying to store metrics and artifacts on host after running MLProject in a docker environment.I am expecting that when the experiment completes successfully, artifacts, metrics folders in mlruns/ folder should have values and be shown on mlflow ui but artifacts, metrics folders in mlruns/ folder are empty. mlflow ui is also not reflecting the new experiment.

/home/mlflow_demo/mlflow-demo.py -

import mlflow  from mlflow.tracking import MlflowClient  from random import random  import pickle    client = MlflowClient()  experiment_id = client.create_experiment(name='first experiment')  run = client.create_run(experiment_id=experiment_id)  for i in range(1000):  client.log_metric(run.info.run_id,"foo",random(),step=i)  with open("test.txt","w") as f:  f.write("This is an artifact file")  client.log_artifact(run.info.run_id,"test.txt")  client.set_terminated(run.info.run_id)  

/home/mlflow_demo/MLProject -

name: test-project  docker_env:   image: kusur/apex-pytorch-image:latest  entry_points:   main:    command: "python mlflow-demo.py"  

command (executed in /home/mlflow_demo): - mlflow run .

After running the above code, I get the following log -

2021/07/06 12:22:28 INFO mlflow.projects.docker: === Building docker image test-project ===  2021/07/06 12:22:28 INFO mlflow.projects.utils: === Created directory /home/mlflow_demo/mlruns/tmpwa8ydc5j for downloading remote URIs passed to arguments of type 'path' ===  2021/07/06 12:22:28 INFO mlflow.projects.backend.local: === Running command 'docker run --rm -v /home/mlflow_demo/mlruns:/mlflow/tmp/mlruns -v /home/mlflow_demo/mlruns/0/0978fdd89ba44bf7b49975ab84838e82/artifacts:/home/mlflow_demo/mlruns/0/0978fdd89ba44bf7b49975ab84838e82/artifacts -e MLFLOW_RUN_ID=0978fdd89ba44bf7b49975ab84838e82 -e MLFLOW_TRACKING_URI=file:///mlflow/tmp/mlruns -e MLFLOW_EXPERIMENT_ID=0 test-project:latest python mlflow-demo.py' in run with ID '0978fdd89ba44bf7b49975ab84838e82' ===    ...    2021/07/06 12:22:33 INFO mlflow.projects: === Run (ID '0978fdd89ba44bf7b49975ab84838e82') succeeded ===  

Still the folders mlruns/0/0978fdd89ba44bf7b49975ab84838e82/artifacts and mlruns/0/0978fdd89ba44bf7b49975ab84838e82/metrics are empty.

Can someone please provide the pointers. Please let me know if the question isn't well framed.

HTACCESS: Add FOLDER exceptions to RewriteEngine

Posted: 14 Jul 2021 07:56 AM PDT

I have a site that evaluates any URL against their database and redirects accordingly to a php content or a default 404 page.

To develop a beta site, and add other folder for different purposes, I'd like to add these folders

  • example.com/beta
  • example.com/products/
  • example.com/photos

as exceptions in the HTACCESS file. Meaning, the site should read/render the content that is in these folders! Instead of redirecting OR producing content based on the main index (sample.com/index.php). Right now I can't access any files in example.com/beta/

Used all the answers found in StackOverflow: Exclude one folder however, all the answers had the unfortunate effect of breaking the whole site instead of just adding exceptions OR sends me to the default 404 page (the "exception" folders ALREADY have index files, 404 should not happen)

Adding any of the following answers, just below the first RewriteEngine on didn't work:

...  <IfModule mod_rewrite.c>  RewriteEngine   On  RewriteRule !^beta($|/) http://www.example.com%{REQUEST_URI} [L,R=301]  ...  </IfModule>  

OR

...  <IfModule mod_rewrite.c>  RewriteEngine   On  RewriteRule ^(beta) - [L]  ...  </IfModule>  

OR

...  <IfModule mod_rewrite.c>  RewriteEngine   On    RewriteCond %{REQUEST_URI} !^/uploads/  RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]  ...  </IfModule>  

At this point I am scratching my head as to what rule am I writing wrong to make the folder exceptions work. Below is the complete (original htaccess) file

Original HTACCESS

<IfModule mod_headers.c>      Header unset ETag      FileETag None      <FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">          Header unset Last-Modified          Header set Expires "Fri, 21 Dec 2020 00:00:00 GMT"          Header set Cache-Control "public, no-transform"      </FilesMatch>  </IfModule>    <IfModule mod_rewrite.c>      RewriteEngine   On      RewriteCond %{QUERY_STRING} ^$      RewriteRule ^((.)?)$    index.php?p=home [L]        RewriteCond $1 /var/www/vhosts/mywebsite.com/httpdocs      RewriteRule ^(.+)$ / [L]        RewriteCond $1 !^(\#(.)*|\?(.)*|index\.php(.)*|content\/(.)*|css\/(.)*|picture_library\/(.)*|img\/(.)*|readme\.txt(.)*|favicon\.ico(.)*|robots\.txt(.)*|download\.php(.)*|admin\.php(.)*|\.htaccess\.back(.)*|\.htaccess(.)*|external\-export\.php(.)*|login\.php(.)*|cgi-bin\/(.)*|ioncube\/(.)*|test\/(.)*|sitemap\.xml(.)*|old\/(.)*|index\.php\?p\=404(.)*|C079CC0215D2E77B89B0F1837C8199B1\.txt(.)*|images\/(.)*|index\.html(.)*)      RewriteRule ^(.+)$ index.php?url=$1&%{QUERY_STRING} [L]      RewriteEngine On               RewriteCond %{HTTP_HOST} ^mywebsite\.com$ [NC]           RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301,L]             </IfModule>    <IfModule mod_deflate.c>      <FilesMatch "\.(js|css|ico|flv|jpg|jpeg|png|gif)$">          SetOutputFilter DEFLATE      </FilesMatch>  </IfModule>  

EmEditor v20.8 and v20.9 can't open some xml file

Posted: 14 Jul 2021 07:56 AM PDT

Both v20.8.0, v20.8.1 and v20.9.0 can't open some xml file over 0.5MB. The size is 512*1024=524288 Bytes exactly. The character code of these files is ANSI, but there are some multibyte characters in them. When I selected the files and right-clicked them with context menu in file explorer, the files with size under 524288 Bytes can be open normally, first choose encoding of course. But other files with size 524289 Bytes can't be open, the dialog choosing encoding flashed across. En, v20.7.2 and before does all well.

PIL.ImageTk.PhotoImage stored in RAM appears as black square on Tkinter

Posted: 14 Jul 2021 07:56 AM PDT

Ok so I'm trying to reproduce a raycaster with Python. All things done, now I've got a 512x512 matrix coded as 8-bit colors, that I try rendering through Tkinter.

Problem is, after doing a bit of conversion with Pillow, the image appears roughly half-sized, but most importantly as a black square. I'm sure it's some kind of misuse of a function, but i can't find which. Here's the code :

from PIL import Image, ImageTk  import tkinter as Tk  import matplotlib.pyplot as plt, numpy as np    fen = Tk.Tk()  img = plt.imread('BG0.png')  canvas = Tk.Canvas(fen, width = 512, height = 512)  canvas.pack()    def Up(event):     global img     i = np.finfo(img.dtype)     img = img.astype(np.float64)/i.max     img = 255 * img     img = img.astype(np.uint8)     img = ImageTk.PhotoImage(Image.fromarray(img))     canvas.create_image(0, 0, image = img, anchor = Tk.NW)    fen.bind_all('<Up>', Up)  fen.mainloop()  

And here's that famous image we're looking to show (but actually, any 512x512 image could do the trick i'd say), just put it in the same folder as this program: BG0.png

You just have to press the up arrow key on your keybord to have it render in the tkinter window.

What is the Linux C library equivalent of .Net `CharUnicodeInfo` Class

Posted: 14 Jul 2021 07:56 AM PDT

On Windows, you can obtain information about a Unicode character with class

CharUnicodeInfo

from the Dot-Net 5 API.

So for example, you can obtain the information that 0x0BEF, "TAMIL DIGIT NINE", belongs to character class DecimalDigitNumber via method CharUnicodeInfo.GetUnicodeCategory

(Although that method gives DecimalDigitNumber the correct category name is apparently Decimal_Number ... confusing)

If I am on Linux and have gcc, what do I call there?

How to use @apply directive of tailwind in any .scss file instead of only using it main tailwind file(in React)?

Posted: 14 Jul 2021 07:56 AM PDT

I am working in react with typescript and tailwindcss.

What I want is that instead of using @apply directive in main tailwind.css file (the file which conatins @tailwind base, @tailwind components, etc), I want to use it in any .scss file.

For example, in react whenever I create a component, I create a folder and an inside it I create a index.tsx file and a .scss file. I want to use @apply directive in that .scss file. In this way, it will be easy to work and debug because both the associated files will be inside the same folder. How can I achieve that ??

I have shown my basic folder structure below.

Folder structure:

src > components > Header > Header.tsx

import React from "react";  import styles from "./Header.module.scss";    interface Props {}    const Header: React.FC<Props> = (props) => {    return <div className={styles.headerTag}>Header part here</div>;  };    export default Header;  

src > components > Header > Header.module.scss

// what to import so that I can use tailwind like this    .headerTag {    @apply text-8xl font-bold bg-gray-500;  }    

Warning: 'sandbox' is not in the list of known options, but still passed to Electron/Chromium

Posted: 14 Jul 2021 07:56 AM PDT

I am using Linux Mint 20 and vscode 1.52.1.

My ~/.xsession-errors file shows Warning: 'sandbox' is not in the list of known options, but still passed to Electron/Chromium.

What is causing this error and what is the solution to it?

preg_split regex - need to split user input around mathematical operators

Posted: 14 Jul 2021 07:56 AM PDT

I need to split a given user string into an array based around mathematical operators. The symbols I need the string splitting around are:

+  -  /  *  ()  

However I would like to expand on the regex to include other operators I will be adding into my program. The regex I have so far is this:

"((\(|\d+.+|-|\*|\/\d+\|))"  

which when ran through regex101.com matches a given input string of: (30*30)/(9+8) with '30*30)/(9+8)

I would like the output to be similar to this:

[0] =   [1] = (  [2] = 30  [3] = *  [4] = 30  [5] = )    or:    [0] =    [1] = 4   [2] = *   [3] = 4  

depending on whether brackets are present in the user string or not.

I forgot to include current results of the current regex string: using http://www.phpliveregex.com/ to test preg-split with an input string of:

(30*30)+(9*8)  the result:  array(3  0 =>      1 =>      2 =>      )  

Simple web application filter doesn't filter request

Posted: 14 Jul 2021 07:56 AM PDT

Starting my way with STS and created a new basic "Hello World" Spring MVC project. I wanted to add a filter to my app so I created a filter (HelloWorldFilter.java) with the following doFilter method:

public void doFilter(ServletRequest request, ServletResponse response,              FilterChain chain) throws IOException, ServletException {          System.out.println("Entering Filter");          request.setAttribute("hello", "Hello World from HelloWorldFilter!");          chain.doFilter(request, response);          System.out.println("Exiting HelloWorldFilter");      }  

According to what I read it (my filter) should also be defined in the application context as a spring bean (Spring delegates it to my filter - from this manual )

So in my application context I have:

<bean id="helloWorldFilter" class="com.yl.mvc.filters.HelloWorldFilter"> </bean>  

My web.xml contains the following:

<filter>      <display-name>HelloWorldFilter</display-name>      <filter-name>HelloWorldFilter</filter-name>      <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>  </filter>  <filter-mapping>      <filter-name>HelloWorldFilter</filter-name>      <url-pattern>/*</url-pattern>  </filter-mapping>  

In my .jsp file I added:

<P><%=request.getAttribute("hello")%></P>  

But all I see in my web-page is null (I expected Hello World from HelloWorldFilter!). The filter doesn't even get invoked..

Am I missing something here?

Thanks in advance, Yogi

No comments:

Post a Comment