Tuesday, May 17, 2022

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


GhostScript.Net not working Visual Studio 2022

Posted: 17 May 2022 04:03 AM PDT

Hello everyone and thanks for the help in advance. I am using GhostScript.Net to convert Pdf files to Png images. This has worked perfectly fine using Visual Studio 2019. However, when I moved to VS 2022, Here is my code:

                using (var rasterizer = new GhostscriptRasterizer()) //create an instance for GhostscriptRasterizer              {                    string fileName = Path.GetFileNameWithoutExtension(inputFile);                    rasterizer.Open(inputFile); //opens the PDF file for rasterizing                  SendEmail sendEmail9 = new SendEmail("Page Count", rasterizer.PageCount.ToString(), "");                    //set the output image(png's) complete path                  var outputPNGPath = @"E:\out.png";                    //converts the PDF pages to png's                   var pdf2PNG = rasterizer.GetPage(100, 1);                    //save the png's                    pdf2PNG.Save(outputPNGPath, ImageFormat.Png);                }  

When attempting to save, I receive an error message "System.NullReferenceException: Object reference not set to an instance of an object". I have also tried the GhostScript.Net Fork without success. Any help would be appreciated.

Sort wp_object_term

Posted: 17 May 2022 04:04 AM PDT

for my site I want sort this Array ( [0] => WP_Term Object ( [term_id] => 288 [name] => -11.00 [slug] => 11-00 [term_group] => 0 [term_taxonomy_id] => 288 [taxonomy] => pa_sfera [description] => [parent] => 0 [count] => 1 [filter] => raw )

[1] => WP_Term Object      (          [term_id] => 287          [name] => -11.50          [slug] => 11-50          [term_group] => 0          [term_taxonomy_id] => 287          [taxonomy] => pa_sfera          [description] =>           [parent] => 0          [count] => 1          [filter] => raw      )    [2] => WP_Term Object      (          [term_id] => 286          [name] => -12.50          [slug] => 12-50          [term_group] => 0          [term_taxonomy_id] => 286          [taxonomy] => pa_sfera          [description] =>           [parent] => 0          [count] => 1          [filter] => raw      )    [3] => WP_Term Object      (          [term_id] => 285          [name] => -13.00          [slug] => 13-00          [term_group] => 0          [term_taxonomy_id] => 285          [taxonomy] => pa_sfera          [description] =>           [parent] => 0          [count] => 1          [filter] => raw      )    [4] => WP_Term Object      (          [term_id] => 292          [name] => +10          [slug] => 10          [term_group] => 0          [term_taxonomy_id] => 292          [taxonomy] => pa_sfera          [description] =>           [parent] => 0          [count] => 1          [filter] => raw      )    [5] => WP_Term Object      (          [term_id] => 284          [name] => +6.00          [slug] => 6-00          [term_group] => 0          [term_taxonomy_id] => 284          [taxonomy] => pa_sfera          [description] =>           [parent] => 0          [count] => 1          [filter] => raw      )    [6] => WP_Term Object      (          [term_id] => 289          [name] => 0 PLANO          [slug] => 0-plano          [term_group] => 0          [term_taxonomy_id] => 289          [taxonomy] => pa_sfera          [description] =>           [parent] => 0          [count] => 1          [filter] => raw      )  

)

I obtain this with $value->get_terms(); I would to sort by Name and I would like to get this order -13 -12.50 -11.00 0 PLANO +6.00 +10

thank you

TypeError: Cannot read properties of undefined (reading 'find')

Posted: 17 May 2022 04:03 AM PDT

I am new to node js. I need help.

There is a list of users on the account page and I want to update the balance value of a user in this list on the deposit page. When I send value from deposit url below, I get the error in the header. I tried post and put. I want to send value rather than update value

account.js

const express = require('express');  const router = express.Router();      let accounts = [];  exports.accounts = accounts;  let balance = 0;  exports.balance = balance;    // Create Account    router.post('/', (req, res, next) => {          let accountNumber = req.body.accountNumber      let currencyCode = req.body.currencyCode.toUpperCase()      let ownerName = req.body.ownerName      let accountType = req.body.accountType.toLowerCase()        let isExist = accounts.find(item => item.accountNumber == accountNumber)          if (currencyCode != "TRY" && currencyCode != "USD" && currencyCode != "EUR") {          res.send("Undefined currency code")        } else if (accountType != "individual" && accountType != "corporate") {          res.send("Undefined account type")        } else if (accountNumber.constructor != Number) {          res.send("Account number must be a numeric value")        } else if (isExist) {          res.send("Already have an account")          } else {          accounts.push({              accountNumber: accountNumber,              currencyCode: currencyCode,              ownerName: ownerName,              accountType: accountType,              balance          })          res.status(200).json({              message: "Succesfuly"          })      }    });    // Get Account Info    router.get('/:accountNumber', (req, res, next) => {        let accountNumber = req.params.accountNumber      let isExist = accounts.find(item => item.accountNumber == accountNumber)      let accountInfo = isExist          if (isExist) {          res.status(200).json({              accountInfo,            })      } else {          res.status(404).json({              message: "Not found"          })      }      });    module.exports = router;  

deposit.js

const express = require('express');  const { is } = require('express/lib/request');  const { accounts, balance } = require('./account');  const router = express.Router();    // Deposit         router.post('/', (req, res, next) => {                let accountNumber = req.body.accountNumber          let amount = req.body.amount                isExist = accounts.find(item => item.accountNumber == accountNumber)                accounts[isExist].balance += amount                return accounts[isExist]                  })                        module.exports = router;  

Why it doesn't navigate to createProfile screen after then persistLogin is completed?

Posted: 17 May 2022 04:02 AM PDT

What I'm trying to do is to navigate to screens that can be access after the user has authenticate using his credentials.

checkOtp.js

    const confirm = () => {        const userParams = {          phone: phone,          code: value,        };        axios          .post('urlApi', userParams)          .then((response) => {            navigation.navigate('MapScreen');            const result = response.data;            const userParams = result;            persistLogin({ ...userParams[0] });          })          .catch((error) => {            console.log('the error:', error.message);          });        const persistLogin = (userParams) => {      AsyncStorage.setItem('BeMySafetyCredentials', JSON.stringify(userParams))        .then(() => {          setStoredCredentials(userParams);        })        .catch((error) => {          console.log(error);        });    };      };    

App.js

  const checkLoginCredentials = () => {      AsyncStorage.getItem('BeMySafetyCredentials')        .then((result) => {          if (result !== null) {            setStoreCredentials(JSON.parse(result));          } else {            setStoreCredentials(null);          }        })        .catch((error) => console.log(error));    };        return (      <CredentialsContext.Provider        value={{ storeCredentials: storeCredentials, setStoreCredentials: setStoreCredentials }}      >        <RootStack />      </CredentialsContext.Provider>    );  

rootstack.js

return (      <CredentialsContext.Consumer>        {({ storeCredentials }) => (          <NavigationContainer>            <Stack.Navigator              initialRouteName="Welcome"            >              {storeCredentials != null ? (                <>                  <Stack.Screen name="MapScreen" component={MapScreen} />                </>              ) : (                <>                  <Stack.Screen name="Welcome" component={Welcome}/>                  <Stack.Screen name="OnBoarding" component={OnBoarding} />                  <Stack.Screen name="Signup" component={Signup} />                  <Stack.Screen name="OtpVerification" component={OtpVerification}/>                  </>              )}            </Stack.Navigator>          </NavigationContainer>        )}      </CredentialsContext.Consumer>    );  

The idea is when the user check the otp(for verification), the params are set to AsyncStorage, to keep the user logged in, but after the user checks the otp, it wont navigate to mapScreen screen.

Also I tried to put in .then method in axios post: navigation.navigate('MapScreen');, but it showed this error in my console:The action 'NAVIGATE' with payload {"name":"MapScreen"} was not handled by any navigator. Do you have a screen named 'MapScreen'? If you're trying to navigate to a screen in a nested navigator, see https://reactnavigation.org/docs/nesting-navigators#navigating-to-a-screen-in-a-nested-navigator.

How can I solve this error?

Angular and .net core project image update problem

Posted: 17 May 2022 04:03 AM PDT

I would like to update the image in a project I am involved in later, but it gives the error you see in the image. What is the reason for this?

enter image description here

Error Code; error: "{\"errors\":{\"photo\":[\"Error converting value \\\"C:\\\\fakepath\\\\big___Page_88f2fa9e-18f1-472b-85b2-cf88d4f5c371big___Page_2b84e9ea-e78f-4ffe-ac76-8c2d3fe8030cmanset-kirmizi-700x350-px.png\\\" to type 'Microsoft.AspNetCore.Http.IFormFile'. Path 'photo', line 1, position 324.\"]},\"type\":\"https://tools.ietf.org/html/rfc7231#section-6.5.1\",\"title\":\"One or more validation errors occurred.\",\"status\":400,\"traceId\":\"0HMHNUCP6V4NR:0000000B\"}"

Backend Code;

if (request.Photo != null)                  {                      var fileUpload = Core.Extensions.FileExtension.FileUpload(request.Photo, fileType: Core.Enums.FileType.Image);                      if (fileUpload != null)                      {                          isThereAnyUser.Photo = fileUpload.GuidName;                      }                  }                  _userRepository.Update(isThereAnyUser);  

Api Code;

   public async Task<IActionResult> Update([FromBody] UpdateUserCommand updateUser)          {              var result = await Mediator.Send(updateUser);              if (result.Success)              {                  return Ok(result.Message);              }                return BadRequest(result.Message);          }  

Angular Code;

updateUser() {      let userModel = Object.assign({}, this.userUpdateForm.value);      if (this.userUpdateForm.valid) {        this.userService.userUpdate(userModel).subscribe(data => {          this.alertfyService.warning(data);        })  

Angular Html;

  <input type="file" id="file" accept=".jpg,.png,.gif" multiple  (change)="uploadFile($event)"  class="form-control"formControlName="photo">        }    }    uploadFile(event: any) {      this.imageFiles = event.target.files;    }  

Angular userUpdate Code;

 userUpdate(user:UserDto): Observable<any> {      return this.httpClient.put(`https://localhost:6001/Admin/api/Users`,user,{ responseType: 'text' });    }  

Elementor Custom Widget (add_control) - How to get to this data inside my array ? (Background URL)

Posted: 17 May 2022 04:02 AM PDT

I have created a custom Elementor widget, which have a specific control for selecting an SVG icon for my slider.

Here is my code :

$this->add_control(              'arrows_icon_left',              [                  'label' => esc_html__( 'Arrow left' ),                  'type' => \Elementor\Controls_Manager::ICONS,                  'default' => [                      'value' => 'fas fa-chevron-left',                      'library' => 'solid',                  ],                  'selectors' => [                      '{{WRAPPER}} .swiper-button-prev' => 'background-image: url({{VALUE}});',                  ],              ]          );  

Everything is OK. The control and the widget work fine !

Except that I don't know how to access to the background URL path. :(

On my website, the css property display : background-image( Array() )

see the browser inspector

So, I have put this test

var_dump($settings[])  

And I get this now :

["arrows_icon_left"]=>    array(2) {      ["value"]=>      array(2) {        ["url"]=>        string(66) "//website.local/files/2021/04/check-mark.svg"        ["id"]=>        int(1128)      }      ["library"]=>      string(3) "svg"    }  

When I test :

var_dump($settings[arrows_icon_left][value][url])  

I access to the URL no problem.

So I've tried many ways to access to it like VALUE :

VALUE.url

VALUE.value.url

{{VALUE}}{{URL}}

{{VALUE}}{{VALUE}}{{URL}}

But nothing works. :(((

Could you help me please ?

Why onSubmit function not working in React?

Posted: 17 May 2022 04:03 AM PDT

This is my code on React

function Education() {      function onFormSubmit(){       console.log("Hello");    }      return (      <div>        <form onSubmit={onFormSubmit}>          <div>            <label>Level:</label>            <input type="text" name="level"></input>          </div>          <div>            <label>Institution:</label>            <input type="text" name="insti"></input>          </div>         <div>            <label>Address:</label>            <input type="text" name="address"></input>                <div>              <input type="submit"></input>          </div>        </form>      </div>    );  }  

When I submit this form "Hello" blinks on console for less than a seconds then disappears without showing any error. Any solution for this?

Split from list in python

Posted: 17 May 2022 04:03 AM PDT

In my list I have few items, i.e.,

List=['a/c/d/eww/d/df/rr/e.jpg', 'ss/dds/ert/eww/ees/err/err.jpg','fds/aaa/eww/err/dd.jpg']  

I want to keep only from 'eww' till last '/'

Modified_list=['eww/d/df/rr/', 'eww/ees/err/err.jpg','eww/err/']  

Oracle pl/sql Array

Posted: 17 May 2022 04:03 AM PDT

let's see if somebody can help me, I need to delete rows from different tables and I did think to do it using an array so i wrote this :

DECLARE  type mytype_a is table of varchar2(32) index by binary_integer;  mytype mytype_a;    BEGIN    mytype (mytype.count + 1) := 'MYTABLE';    for i in 1..mytype.count loop      DELETE  FROM mytype(i) where valid ='N';      end loop;  END;  

Trying to run this piece of code using sqldeveloper I get the ORA-00933 command not properly ended, if I put directly the table name it works, what am I doing wrong?

Thank you.

Not getting the layout I want with CSS Grid [closed]

Posted: 17 May 2022 04:04 AM PDT

I use grids to customise my html layout and it does not work as I want. I want my nav to take all available width.

Here is my code:

  header {    text-align: center;    grid-area: header;    border: solid;  }    #nav1 {    text-decoration: none;    border: solid;    background-color: green;    grid-area: MH;    width: 1fr;    text-align: center;  }    #nav2 {    text-decoration: none;    border: solid;    background-color: red;    grid-area: MC;    width: 1frs;    text-align: center;  }    #nav3 {    text-decoration: none;    border: solid;    background-color: yellow;    grid-area: start;    width: 1fr;    text-align: center;  }    footer {    grid-area: footer;    border: solid;    background-color: orange;    margin-top: 0px;    height: 100px;  }    main {    text-decoration: none;    border: solid;    background-color: gray;    grid-area: main;    height: 500px;    color: #ff00eb;    border-color: black;  }    aside {    width: 0.5fr;    border: solid;    background-color: purple;    grid-area: aside;  }    #big-container,  nav {    display: grid;    grid-template-columns: 1fr 1fr 1fr;    grid-template-rows: auto;    grid-template-areas: 'header header header' 'MH MC start' 'main main aside' 'footer footer footer ';    grid-gap: 0px;    padding: 0px;
<!-- detta är min header-->  <header>    <h1></h1>  </header>    <div id="big-container">      <nav>      <a href="Mitt-hus-(6)/index.html" id="nav1"> mitt hus</a>      <a href="kalender/calender.html" id="nav2"> min calender</a>      <a href="index2.0.html" id="nav3">main</a>    </nav>      <main>        main    </main>        <aside>      aside    </aside>        <footer>      footer    </footer>  </div>

org/apache/commons/compress/archivers/tar/TarArchiveInputStream

Posted: 17 May 2022 04:02 AM PDT

I am getting

Exception in thread "main" java.lang.NoClassDefFoundError:org/apache/commons/compress/archivers/tar/TarArchiveInputStream

converting date to datenum using pandas giving invalid token errors [duplicate]

Posted: 17 May 2022 04:03 AM PDT

I am trying to change python datetime into matlab datenum by using this and this when I call datetime2matlabdn(2021-08-28 10:30:00) it throws FOLLOWING ERRORS

datetime2matlabdn(2021-08-28 10:30:00)  Syntax Error: invalid token  

if I try to remove these zeros then it throws invalid syntax error. I figured out I need to strip the zeros I tried some thing like this but it is not working

dt=dt.strptime('2021-06-28 10:30','%Y-%m-%d %H:%M')      dn=datetime2matlabdn(dt)  

how can I strip my zeros in function. any help would be appreciated.

Service is not started in windows

Posted: 17 May 2022 04:03 AM PDT

I have successfully installed the Windows service but when tried to start it gives below error.

the application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe for more details

Serve static files without hard coding all file types header information

Posted: 17 May 2022 04:03 AM PDT

I am currently making a router in my project and I realised a problem. I am using the .htaccess file to redirect all routes to my router.php file. This creates a problem where all of my css/images/js files are redirected to my .htaccess file too. This is the code for my .htacess file:

RewriteEngine on  Options +Multiviews  RewriteCond %{REQUEST_FILENAME}.php -f  RewriteCond %{REQUEST_FILENAME} !-f  RewriteCond %{REQUEST_FILENAME} !-d  RewriteRule ^(.*)$ router.php [NC,L,QSA]  

I had tried solving this problem by manually detecting if it is one of the recognised static file type and manually returning the contents. In my router class, I checked if the give file type is a recognised static file type. If it is a static file type I will render it if not I will give it to the handle function which basically checks if the route is recognised and returns the call to a function.

       if ($isStatic["check"]) {              $this->render->returnStaticFiles($data["uri"], $isStatic["type"], $isStatic["ext"] ?? "");          } else {              $this->handle($data["uri"]);          }  

However, the problem with this is I need to manually add the static file types to an array and use a function to set the right headers or else it is just going to be recognised as text/html and that doesn't work with either css or images. Css will not get parsed and images will simply return as binary texts as gibberish. This is how I currently implement the render class:

<?php    namespace app\Router;    use JetBrains\PhpStorm\ArrayShape;    class Render  {      public array $static_file_types = ["js", "css", "html", "json"];      public array $image_types = ["png", "jpg", "jpeg"];        public function __construct(          public string $root_dir = "",          public string $home = "http://localhost/"      ){}        public function throwError(int $statusCode = 500) :string      {          $err_dir = $this->root_dir . "errors\\";          $file_contents = file_get_contents($err_dir . "$statusCode.php") ?? false;          if (!$file_contents) {              return str_replace(                  ["{code}", "{home}"],                  [$statusCode, $this->home],                  file_get_contents($err_dir . "err_template.php")              );          }          return str_replace("{home}", $this->home, $file_contents);      }      public function returnStaticFiles(string $uri, string $type, string $ext) : void      {          if ($type == "cnt") {              $this->setHeader($ext);              include_once $this->root_dir . $uri;          } elseif ($type == "img") {              $this->handleImage($this->root_dir . urldecode($uri), $ext);          } else {              echo "This file is not supported sorry";              exit();          }      }      private function handleImage(string $path_to_image, string $type) : void      {          if (file_exists($path_to_image)) {              $image = fopen($path_to_image, "r");              header("Content-Type: image/$type");              header("Content-Length: " . filesize($path_to_image));              fpassthru($image);          } else {              echo "This image does not exist sorry";          }      }      #[ArrayShape(["check" => "bool", "type" => "string", "ext" => "string"])]      public function checkIsStatic($uri) : array      {          $_uri = explode(".", $uri);          $ext = end($_uri);            if (in_array($ext, $this->static_file_types)) {              return ["check" => true, "type" => "cnt", "ext" => $ext];          } elseif (in_array($ext, $this->image_types)) {              return ["check" => true, "type" => "img", "ext" => $ext];          } else {              return ["check" => false, "type" => ""];          }      }      private function setHeader($ext): void      {          switch ($ext) {              case "css":                  header("Content-Type: text/css"); break;              case "js":                  header("Content-Type: text/javascript"); break;              case "json":                  header("Content-Type: application/json"); break;              default:                  header("Content-Type: text/html"); break;          }      }  }  

This is working just fine but is there any way around this? I might need to serve PDF content or other file types such as audio or video and I don't think this is an optimal solution for it. I tried searching it but I don't think I can find anything.

I appreciate any assistance.

Sequence kubernates Operators

Posted: 17 May 2022 04:03 AM PDT

I have two k8s operators say operatorA and operatorB . I have both custom resources present in microservice(helm/templates).

how can I make sure custom resource for operatorB applied only after operatorA custom resource is applied?

Time complexity halving an array

Posted: 17 May 2022 04:03 AM PDT

What would be the time complexity of halving an array and finding an element.

Is it O(n) or O(log n)?

Deleting a post with a link click submit [closed]

Posted: 17 May 2022 04:03 AM PDT

We are having issues deleting an appointment when the cancel appointment is clicked. We have gone through everything and are not sure why it's not deleting.

screenshot of code

Generic Type in an array throws "Cannot find name 'T' "

Posted: 17 May 2022 04:03 AM PDT

I have this code:

interface Process<T> {    first: () => T[];    second: (d: T) => void;    }    const PROCESSES: Process<T>[] = [    {      first: () => [{car: "car1"}],      second: (car: {car: string}) => {},      },    {      first: () => [{person: "person1"}],      second: (person: {car: string}) => {}, // => How to make TS mark this as an error because is not a persona type?    },  ];  

TS Playground

The problem is TS throws me this error: Cannot find name 'T'. that I don't know how to solve it.

SSRS report subscriptions - How to customise the report attachment name

Posted: 17 May 2022 04:03 AM PDT

We have SSRS reports and the subscription emails go out on a daily basis.

Recently we were asked to rename the attachment file name, I think currently it create a file with the same name that was given to the report but need help with customising the report attachment name in emails.

Please advice.

Can't import the named export 'PublicKey' from non EcmaScript module (only default export is available)

Posted: 17 May 2022 04:02 AM PDT

Describe the bug Hi, I'm trying using Metaplex to upload the assets and verify the collection, I am now moving towards "Minting Website": https://docs.metaplex.com/candy-machine-v2/mint-frontend

run rpm start inside the folder ~/metaplex/js/packages/candy-machine-ui to test the mint button, it doesn't load the localhost and it shows me the following error on the terminal:

Failed to compile.    ./node_modules/@solana/buffer-layout-utils/lib/esm/web3.mjs  Can't import the named export 'PublicKey' from non EcmaScript module (only default export is available)    

Anyone know how to solve this? thanks

I'm using Visual Studio on Windows, node 14.15.

Update: It seems I'm not alone: https://github.com/solana-labs/buffer-layout-utils/issues/6

Solved it: How to downgrade the version of Solana to 1.9.1

How to render Pelican site with custom CSS theme?

Posted: 17 May 2022 04:03 AM PDT

I'm trying to add a custom theme to my Pelican site, following the tutorial, but my theme isn't rendering. There are some previous questions about this (e.g. here) but I the solution isn't working for me.

My pelicanconf.py looks like:

AUTHOR = 'name'  SITENAME = 'my-blog'  SITEURL = ''    PATH = 'content'    TIMEZONE = 'Europe/Rome'    DEFAULT_LANG = 'en'    RELATIVE_URLS = True    # Feed generation is usually not desired when developing  FEED_ALL_ATOM = None  CATEGORY_FEED_ATOM = None  TRANSLATION_FEED_ATOM = None  AUTHOR_FEED_ATOM = None  AUTHOR_FEED_RSS = None    # Blogroll  LINKS = (('Pelican', 'https://getpelican.com/'),)               # Social widget  SOCIAL = (('You can add links in your config file', '#'),            ('Another social link', '#'),)    DEFAULT_PAGINATION = 10    # Uncomment following line if you want document-relative URLs when developing  #RELATIVE_URLS = True  

and my directory structure for website/themes is exactly like the tutorial (with the content being in website/content):

├── static  │   ├── css  │   └── images  └── templates      ├── archives.html         // to display archives      ├── period_archives.html  // to display time-period archives      ├── article.html          // processed for each article      ├── author.html           // processed for each author      ├── authors.html          // must list all the authors      ├── categories.html       // must list all the categories      ├── category.html         // processed for each category      ├── index.html            // the index (list all the articles)      ├── page.html             // processed for each page      ├── tag.html              // processed for each tag      └── tags.html             // must list all the tags. Can be a tag cloud.  

My base.html looks like:

<!DOCTYPE html>   <html>       <body>           <style>              {% block mystyles %}                  <link rel='stylesheet' type="text/css" href="{{ SITEURL }}/theme/css/main.css"/>              {% endblock mystyles %}          </style>          <nav>              {% block nav %}                  {% include 'nav.html' %}              {% endblock nav %}          </nav>          <main>              {% block content %}              {% endblock content %}          </main>          <footer>              {% block footer %}              {% include 'footer.html' %}              {% endblock footer %}          </footer>      </body>  </html>  

and index.html looks like:

{% extends "base.html" %}      {% block content %}    <div class="post-list">      <p> Recent posts: </p>      {% for article in articles_page.object_list %}      <li> {{ article.date }} |           <a href="/{{ article.slug }}.html">{{ article.title }}</a>      </li>      {% endfor %}  </div>  {% endblock content %}  

I'm generating the site using pelican content -s pelicanconf.py -t theme and then viewing the site with pelican --listen. All I get is a page with no theme at all -- all white and black text. Can anyone help me out?

Which way to fetch value from local.settings.json?

Posted: 17 May 2022 04:02 AM PDT

Could someone please explain which way, if any of these, is the preferred way of fetching values in Startup class from local.settings.json, C# .NET6. The startup.cs is for a function.

            client.BaseAddress = new Uri(configuration["BaseEndpoints:RestIg"]);              client.BaseAddress = new Uri(Environment.GetEnvironmentVariable("BaseEndpoints:RestIg"));              client BaseAddress = new Uri(configuration.GetSection("BaseEndpoints:RestIg").Value);  

In my local.settings.json I can have the value of BaseEndpoints:RestIg either inside or outside the values{}, not sure where I would want to place it?

{  "IsEncrypted": false,  "Values": {  "AzureWebJobsStorage": "UseDevelopmentStorage=true",  "FUNCTIONS_WORKER_RUNTIME": "dotnet",  "TimerInterval": "0 0 * * * *"  },  "BaseEndpoints": {  "RestIg": "https://myurl.com....etc.etc.etc"    }  }  

Core dumped when opening RocksDB on HDFS

Posted: 17 May 2022 04:03 AM PDT

I'm currently opening rocksdb on HDFS using tools offered by RocksDB official website https://github.com/facebook/rocksdb/tree/master/hdfs, I have set the environment variables according to the instructions and installed HDFS lib. NewHdfsEnv() returns ok, while core dump happened when excutes Open(the last line) , please tell me how to fix it.

#include <rocksdb/env_hdfs.h>  #include <rocksdb/db.h>  #include <string>    int main(int argc, char *argv[]) {    std::string hdfs_host("hdfs://haruna");    rocksdb::Options options;    auto s = rocksdb::NewHdfsEnv(&(options.env), hdfs_host);    std::cerr << s.ToString() << std::endl;    rocksdb::DB *db{};    options.create_if_missing = true;    rocksdb::Status status = rocksdb::DB::Open(options, "/dev/shm/rocksdb_xxxx", &db);  

Typescript subset of enum

Posted: 17 May 2022 04:03 AM PDT

In Typescript, I have an enum like

export enum CarBrands {     Toyota = "TOYOTA"     Ford = "FORD"     .....  }  

I would like to create a subset of this enum like this but cannot seem to do it

enum JapaneseCars {      CarBrands.Toyota  }  

or create an object with a subset

const JapaneseCars = {      Carbrands.Toyota  }  

Is there anyway i can create an object or enum that uses that values from another existing enum?

I cannot change the CarBrands enum to be some other data type

HEIC to JPEG conversion with metadata

Posted: 17 May 2022 04:03 AM PDT

I'm trying to convert heic file in jpeg importing also all metadadata (like gps info and other stuff), unfurtunately with the code below the conversion is ok but no metadata are stored on the jpeg file created. Anyone can describe me what I need to add in the conversion method?

heif_file = pyheif.read("/transito/126APPLE_IMG_6272.HEIC")  image = Image.frombytes(      heif_file.mode,      heif_file.size,      heif_file.data,      "raw",      heif_file.mode,      heif_file.stride,  )  image.save("/transito/126APPLE_IMG_6272.JPEG", "JPEG")  

How to fail aws_instance creation if user_data fails to run to completion

Posted: 17 May 2022 04:02 AM PDT

Is it possible to fail an aws_instance creation if script passed into user_data fails to run? e.g., with exit 1?

I have a null_resource that uses depends_on [aws_instance.myVM] to post a JSON to the instance, and I need that depends_on to fail when the user_data script fails.

Thanks!

How do font apps/websites work across multiple platforms/apps?

Posted: 17 May 2022 04:03 AM PDT

There are apps which you can type text and convert them into fancy fonts. Then copy it and paste with the formatting. Like this. 𝑻𝒉𝒊𝒔 𝒇𝒐𝒓𝒎𝒂𝒕𝒕𝒊𝒏𝒈 𝒘𝒊𝒍𝒍 𝒘𝒐𝒓𝒌 𝒆𝒗𝒆𝒏 𝒂𝒇𝒕𝒆𝒓 𝒄𝒐𝒑𝒚𝒊𝒏𝒈 𝒂𝒏𝒅 𝒑𝒂𝒔𝒕𝒊𝒏𝒈!

How does this work? Are there any special fonts for this? How the input is being converted/mapped into these characters? I understand it's unicode. But I don't seem to understand how this works.

Example site: https://lingojam.com/BoldLetters

Example app: https://play.google.com/store/apps/details?id=com.theruralguys.stylishtext

Any tips would be much appreciated. Thanks!

How to create ami with specific image-id using moto?

Posted: 17 May 2022 04:03 AM PDT

I'am using moto to mock aws for my application. I wondering if it is possible to create ami in moto with specific image-id (for example: ami-1a2b3c4d). Thank you!

PyCharm not recognizing Python files

Posted: 17 May 2022 04:02 AM PDT

PyCharm is no longer recognizing Python files. The interpreter path is correctly set.

Screen shot

How to convert MP3 to WAV in Python

Posted: 17 May 2022 04:03 AM PDT

If I have an MP3 file how can I convert it to a WAV file? (preferably, using a pure python approach)

No comments:

Post a Comment