Tuesday, October 5, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Detect exit from application in browser Vuejs

Posted: 05 Oct 2021 08:21 AM PDT

I am trying to implement a warning right before user exits the application. It's not on browser closing or tab closing. I want to implement this when user keep tapping on back button until app is about to exit. Please let me know how to do this. I am using Vue2 with composition api plugin. Highly appreciate your help. Thanks !

Json parse error on api call react-native

Posted: 05 Oct 2021 08:21 AM PDT

I have this Ajax request function.

export async function fetchAllCoinsPromise() {    const apiCall = await fetch('https://api.coincap.io/v2/assets');    const jsonResult = await apiCall.json();      return jsonResult;  }  

I call it like this:

  const fetchCoins = () => {  fetchAllCoinsPromise()    .then(res => console.log(111))    .catch(err => {      console.log('err', err);      fetchCoins();    });   };  

the reason why I'am doing this recursion is because sometimes I'm getting this strange error: SyntaxError: JSON Parse error: Unexpected identifier "You"] and I thought the async recursion would solve the issue and it does but I am not sure if this is the best solution in case of time complexity. Any suggestions please?

Function of a formula in python for big dataset

Posted: 05 Oct 2021 08:21 AM PDT

Say, I need to convert the following formula into python and use it on a data frame. The formula is as follows.

enter image description here

The data frame has got values for Xj and Bj. The data frame looks like the following.

 df.head()  type name   OR  1   SAP1    11.21  1   SAP1    1301  2   SAP1    0.7578  2   LUF1    1447  2   LUF1    0.7578  1   ANK3    1150  1   ANK3    0.9909  1   ANK3    1535  1   ACR     0.9909  1   ACR     1535  

The above data frame has got values for Xj=type and bj=OR from the data frame. I need for each sam The ^S score from the formula In the end, for each name, I need a single S score.

I have implemented something like this,

   def score(df):          df_sum   =df[['type','name','OR']].groupby('name').sum().reset_index()          sum   =df_sum['type']          OR=df_sum['OR']          score=sum([sum*OR])          return score  

The question is I need to get them for each name value single score not many scores for all repeating name values. In the end, I need only 4 rows with 4 score values.

It is possible on small datasets. However, when I give a big data frame with multiple name values for OR and type columns. Then I have multiple scores for the same name

Unsure how to resolve SQLite Error 1: 'near "(": syntax error

Posted: 05 Oct 2021 08:21 AM PDT

I have the SQL string:

"(SELECT LOCATIONS.HTH_ID, FILE_NAME, PHOTOS.COMMENT, PHOTO_DATE, PHOTOS.ID, PHOTOS.TARGET_TYPE FROM LOCATIONS INNER JOIN PHOTOS ON LOCATIONS.ID = PHOTOS.TARGET_ID WHERE (PHOTOS.NEW = 'Y') AND (PHOTOS.TARGET_TYPE = 'TY1'))   UNION   (SELECT PHOTOS.TARGET_ID, FILE_NAME, PHOTOS.COMMENT, PHOTO_DATE, PHOTOS.ID, PHOTOS.TARGET_TYPE FROM PHOTOS WHERE (PHOTOS.NEW = 'Y') AND (PHOTOS.TARGET_TYPE = 'TY2'));"  

I am executing it with SQLite and I receive the error: "SQLite Error 1: 'near "(": syntax error"

Please help me find the syntax error. I am quite new to SQL so a small explanation would be much appreciated :) thank you

Git-hub corrupts RData files

Posted: 05 Oct 2021 08:21 AM PDT

I am uploading a file image (RData) to git-hub.

When the file image is generated thus:

save.image("myfile.RData",compress = FALSE, version = 3)  

I have no issue loading it back into R.

However, if I put the same file image into git-hub and try to download and load it I get an error message

githubURL <- "https://github.com/mygit/folde/myfile.RData"  download.file(githubURL, destfile = "myfile.RData", method="curl")  read("myfile.RData")    Error in load("myfile.RData") :     bad restore file magic number (file may be corrupted) -- no data loaded  In addition: Warning message:  file ' myfile.RData' has magic number 'Not F'    Use of save versions prior to 2 is deprecated     

Get closest match between sentence(represented as string) and list of phrases

Posted: 05 Oct 2021 08:20 AM PDT

Let me start with an example. Consider the following list in python

cities = [      'New york'      'San francisco',      'California',      'Las vegas',      'Chicago',      'Miami'  ]  

I also have following sentences.

sentences = [      "Both of us were new to New York City, and had few or no friends.",      "Win three more games and he becomes king of San Francisco.",      "Uncurling from the couch, she started to the bedroom of her father's small Miami apartment."  ]  

For each sentence, find out substring in this sentence that is closest to any string present in the list. So, in this example, I want to get the longest substring for each sentence in sentences which is closest to any string in the list cities. Therefore, in this case, my result should look like:

desired_result = [      'New York',      'San Fransisco',      'Miami'  ]  

There are few algorithms that are in my mind, but they are not ideal.

Algorithm 1

One algorithm can give very good results, but it is very bad in terms of time complexity. I tried to extract all sub phrases of a sentence, starting from n word sub-phrase to one word sub-phrase for a sentence with n tokens. Then I use difflib.get_close_matches function to detect any sub-phrase that is closest to any string in the list of cities. However, the complexity as we can clearly see is very high. For sentence of length n, we have total O(n*n) sub-phrases. Also, the list of cities is not small. In my real-world use-case this list contains around 7 million strings.

In this case, my code looks like this:

  def generate_subphrases(sen):       subphrases: List[str] = []      # My logic to generate all possible subphrases      # .       # .       # .       return subphrases      result = []  for sen in sentences:      subphrases = generate_subphrases(sen)      ans = None      for phrase in subphrases:          if get_close_matches(phrase, cities):              ans = phrase              break      result.append(ans)    print(result)    

Algorithm 2

This is bit faster compared to previous approach, however, this is not as good as last one. The benefit of using last approach was that we could tolerate few mismatches in that approach. For example, New York would be detected if the cities list even contained New york. However, in this case we do not tolerate even single character mismatch. In my use-case, I can tolerate error upto 30-35% in terms of character mismatch. In this approach, I form huge regular expression with union of all cities in the list. Then I use re.search to search for the sub-phrase in my sentence. In my opinion, this is faster but not very good.

I want to know if I can use any data structure to achieve this task, or any python utility function similar to difflib.get_close_matches that can allow searching over entire sentence.

how to make a card on middle of body on flutter

Posted: 05 Oct 2021 08:20 AM PDT

So i have an error that i wanted to make card that stack on my background like this, but eventually it not working it just showing blank screen
Heres the code that im writted
Thanks Before!

                        Column(                            mainAxisAlignment: MainAxisAlignment.start,                            crossAxisAlignment: CrossAxisAlignment.end,                            children: <Widget>[                              Padding(                                padding: EdgeInsets.fromLTRB(90, 30, 0, 0),                                child: Text(                                  'Profile',                                  style: TextStyle(                                      color: Colors.white,                                      fontSize: 35,                                      fontWeight: FontWeight.bold),                                ),                              )                            ],                          )                        ],                      ),                    ),    
              Padding(                  padding: EdgeInsets.fromLTRB(20, 20, 0, 20),                  child: Column(                    children: <Widget>[                      Card(                        child: Column(                          children: <Widget>[                            SvgPicture.network(                              'https://www.pngall.com/wp-content/uploads/5/Profile-Male-PNG.png',                              height: 40,                            )                          ],        

Is it possible to retrieve the text in edit text and use it?

Posted: 05 Oct 2021 08:20 AM PDT

Python 3. x TypeError: byte indices must be integers or slices, not str

Posted: 05 Oct 2021 08:20 AM PDT

i have an python error TypeError: "byte indices must be integers or slices, not str" when executing this below code.

conn = http.client.HTTPSConnection("afi-obs.apibackbone.api.intraorange")  payload = 'grant_type=client_credentials'  headers = {    'Accept': 'application/json',    'Content-Type': 'application/x-www-form-urlencoded',    'Authorization': 'Basic NWRFU0gwd25zV29TUkJ3V1BXSXlKbVk2amlsaGNiblI6amUycTg2MmQ3UU1vbFJ6cw=='  }  conn.request("POST", "/oauth/v3/token", payload, headers)  res = conn.getresponse()  data = res.read()  print(data.decode("utf-8"))    # #here is the result of : print(data.decode("utf-8"))  # {    # "token_type": "Bearer",    # "access_token": "ibw4iGEUVONbraevqBvK6ywXlW5q",    # "expires_in": 3600  # }    print(data['access_token']) ```    Even my "print(data['access_token'])" is not working error type ( TypeError: byte indices must be integers or slices, not str ).  So can you please tell me how can i do these print and how to get "access_token" value and save it in avariable ?  i need to do something like this : var1 = data['access_token']    Thank you for your help   

I started to make selenium scripts browse in New Relic, and when i try to print a Attribute i cant get this data

Posted: 05 Oct 2021 08:20 AM PDT

Script: enter image description here

Output:

ManagedPromise { flow_: ControlFlow { propagateUnhandledRejections_: true, activeQueue_: TaskQueue { name_: 'TaskQueue::3218', flow_: [Circular], tasks_: [Array], interrupts_: null, pending_: null, subQ_: null, state_: 'new', unhandledRejections_: Set {} }, taskQueues_: Set { [TaskQueue], [TaskQueue] }, shutdownTask_: null, hold_: Timeout { called: false, idleTimeout: 2147483647, idlePrev: [TimersList], idleNext: [TimersList], idleStart: 598, onTimeout: [Function], timerArgs: undefined, repeat: 2147483647, destroyed: false, [Symbol(unrefed)]: false, [Symbol(asyncId)]: 18, [Symbol(triggerId)]: 1 } }, stack: { Task: WebElement.getAttribute(id) at Driver.schedule (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/webdriver.js:807:17) at WebElement.schedule (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/webdriver.js:2010:25) at WebElement.getAttribute (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/webdriver.js:2263:17) at eval (eval at JobResource.getScriptFn (/opt/runtimes/4.0.0/modules/synthetics-runner/lib/job-resource/index.js:79:19), :64:37) at ManagedPromise.invokeCallback (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:1376:14) at TaskQueue.execute (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:3084:14) at TaskQueue.executeNext (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:3067:27) at asyncRun (/opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:2927:27) at /opt/runtimes/4.0.0/node_modules/selenium-webdriver/lib/promise.js:668:7 at process.tickCallback (internal/process/next_tick.js:68:7) name: 'Task' }, parent: null, callbacks: null, state: 'pending', handled: false, value: undefined, queue_: null }

enter image description here

Is it currently possible to programmatically enable iap.googleapis.com in GCP?

Posted: 05 Oct 2021 08:20 AM PDT

Is it currently possible to programmatically enable iap.googleapis.com in GCP?

When we configure the iap service in terraform currently, it doesnt seem to be fully enabled.

When I visit the IAP page in gcp console, it tells me:

"Before you can use IAP, you need to configure your OAuth consent screen."

Terraform doesnt seem to have an option for changing this - is there an api we could invoke manually, or are we not able to automate this part?

Thanks

How can I select text in an element that isn't inside another element? [duplicate]

Posted: 05 Oct 2021 08:20 AM PDT

I have a problem with some css selector (I have only one way to find an element if I use JS commands so only CSS selector is available for me) The page looks like this:

<div class='test'>  some_text  <span> some_other_text </span>  </div>  

And I need to get some_text without getting "some_other_text"; I tried to use: By.CssSelector("div[class='test'] :not(span)") >> it returns all text; By.CssSelector("div[class='test'] span:not(last-child)") >> it returns only "some_other_text"; By.CssSelector("div[class='test'] span:not(:last-child)") >> it returns only "some_other_text"; By.CssSelector("div[class='test']:not(:last-child)") >> it returns only "some_other_text";

is there any way to do what I need? could anyone help me , please?

How to add and update objects into array of objects?

Posted: 05 Oct 2021 08:20 AM PDT

I am trying to dynamically add an object to an array of objects, I have been trying to Destructuring the main object but it adds a number to the end of the parent array. This is what I have:

const [data, setData] = useState ([   {       _id:1,       firstName:'Leo',       lastName:'Miller',       telephone:'+569273829',       mail:'leo.miller@gmail.com',       work:[            {_id:1, startWorkDate:'01/01/2015', endWorkDate:'01/02/2017', work:'description...'},            {_id:2, startWorkDate:'01/01/2018', endWorkDate:'01/02/2020', work:'description...'}       ]  }];  

I generate dynamically this object:

const value = {_id:3, startWorkDate:'01/01/2018', endWorkDate:'01/02/2020', work:'description...'}  

I need to add it into data.work and after that update only the description of work._id[3]

I try with this function

const addNewWork = (value) => {          let copyData = [...data, data[0].workExperience.push(value)]          return setData(copyData)      }  

but for some reason doesn't add correctly the object. Help please!

My Flask Site is giving me a White Black Page with a jinja error icon on the tab

Posted: 05 Oct 2021 08:20 AM PDT

This is the code of the python side :

@app.route("/articles")  def articles():      cur = mysql.connection.cursor()      sorgu = cur.execute("Select * From articles")      if sorgu > 0:          makaleler = cur.fetchall()          return render_template("makaleler.html",makaleler = makaleler)      else:          return render_template("makaleler.html")  

and this is the html/flask(folder name makaleler.html) side of it :

    {% extends "site.html" %}            {% block body %}      <h3>Makaleler</h3>      <hr>      {% if articles %}      <ul class="list-group">         {% for article in articles %}         <li class = "list-group-item">{{article.title}}</li>         {% endfor %}      </ul>    {% else %}  <div class = "alert alert-danger">Bu blokta henüz makale bulunmuyor...</div>  {% endif %}  {% endblock  %}  

Can you point out the problem here

Computed Hash seems to be wrong with SHA256

Posted: 05 Oct 2021 08:20 AM PDT

I have the following class which computes a hash for a file that I want to send to a server.

public class GetHashCode       {          public static string CalculateHash()          {              try              {                  var filePath = "\\\\abc\\abc-fs\\_My-Data\\user\\Documents\\test.jpg";                  var fileStream = File.Open(filePath, FileMode.Open,                  FileAccess.Read, FileShare.ReadWrite);                  var hashProvider = SHA256.Create();                  var buffer = hashProvider.ComputeHash(fileStream);                  return Convert.ToBase64String(buffer);              }              catch (Exception err)              {                  Console.WriteLine(err);                  return null;              }                  }      }  

When I send the file to the server via another application I can see that the hash of this action is a little bit different to the hash that I create with my code from above:

hash from the other application (the correct one):

R7av4w6Ow3M3z%252bpKPBBpojzvLvyl6aM0Q7q%252bJ%252fDvLPQ%253d  

hash that is generated with my code:

R7av4w6Ow3M3z+pKPBBpojzvLvyl6aM0Q7q+J/DvLPQ=  

So there seems to be a problem with the encoding of special characters, but I do not know how to solve this yet. Can somebody help? Thanks in advance!

Generic type hint python

Posted: 05 Oct 2021 08:20 AM PDT

I have following code in python. Is it possible to get here intellisense in Visual Studio Code?

from typing import TypeVar    T = TypeVar('T')    # Example class for a possible type T  class MyT:      def name():          return "I'm T"    class FooBar:      def __init__(self, something: T) -> None:          self.its_t = something    foo_bar = FooBar(MyT())  intellisense_test = foo_bar.its_t  

Visual Studio Code says

so does not recognize the type and has no intellisense and no suggestion for "name"

Returning an Object's method names

Posted: 05 Oct 2021 08:20 AM PDT

I have the ability to run code that lets me make calculations and/or get variable information from a program. However I do not have access to the base code, and wondering if there is a way to print out all the methods an Object has available (public)?

Example the Class Shape, with sub classes of Circle and Square. If I was able to print out methods to Circle I would possibly see:

.getRadius()  .setRadius(newValue)  

but Square would have

 .getSide()   .setSide(newValue)  

I have a myObject, where I know I can get

myObject[1].GetLength()  myObject[1].getDimUom()  myObject[1].getQuantity().getValue()  

However I am unaware of what I can set only certain things like (by trial and error)

myObject[1].setClass(newValue)  

So I would like to be able to find a way to print out the method names from an Object; again without any ability to see or modify base code (like adding reflection)

Terraform - yamlencode() is returning YAML in backwards format

Posted: 05 Oct 2021 08:20 AM PDT

Everytime I run this yamldecode function to create a yaml file in a github repository, the format comes out backwards:

Output:

      "framework": "N/A"        "language": "Terraform"        "lifecycle": "generally_available"        "owner": "someone"        "repositories":          "display_name": "miscellaneous-infrastructure"          "name": "someone/miscellaneous-infrastructure"          "path": "/"          "provider": "github"        "serivce":          "aliases":          - "N/A"          "description": "Repository for the hardware team's miscellaneous infrastructure."          "name": "miscellaneous-infrastructure"          "product": "hardware"        "tier": "tier_3"        "version": 1  

yaml.tf:

locals {    yaml = {      version : 1,      serivce : {        name : "${var.serivce_name}",        description : "${var.description}",        product : "${var.product_name}",        aliases : "${var.aliases}"      },        owner : var.organization,      lifecycle : var.serivce_lifecycle,      tier : var.tier,      language: var.language,      framework: var.framework,        repositories : {        name : "${var.organization}/${var.name}",        path: "/"        provider: "github",        display_name : "${var.serivce_name}"      }    }  

}

github-file.tf:

resource "github_repository_file" "opslevel" {    repository          = github_repository.repository.name    file                = "yaml.yml"    content             = yamlencode(local.yaml)      lifecycle {      ignore_changes = [        content      ]    }      depends_on = [      github_repository.repository,      github_team.reviewers_team    ]  }  

I need a way to not have this be reversed. I have tried using the reverse() function but cannot since this is not a list or a tuple.

Workaround for using function from context hook outside a component

Posted: 05 Oct 2021 08:20 AM PDT

I understand that we cannot use hooks outside a component, but was looking for a workaround of using function from context hook outside a react component to show toast (using a separate utility function).

Saw usage of event emitters for achieving this but wanted to explore some another workaround if its there. Creating A React Component That Can Be Shown With A Function Call (like react-toastify

const { add } = useToast();  

Basically, want to do this outside a component.

Selenoid: How to setup hostname for chromium driver in browser.json

Posted: 05 Oct 2021 08:21 AM PDT

I run a selenoid with docker-compose, I cannot setup a host table for browsers, because "hosts" attribute seems to be ignored in the browser started from selenoid. I cannot open the http://myfrontend page because it cannot resolve hostname.

A have a following browsers.json configuration:

{    "chrome": {      "default": "latest",      "versions": {        "latest": {          "image": "selenoid/vnc_chrome:94.0",          "port": "4444",          "tmpfs": {"/tmp":"size=512m"},          "env" : [ "DRIVER_ARGS=--disable-web-security --ignore-certificate-errors --verbose" ],          "hosts": [            "myfrontend:172.20.176.10"          ]        },        "94.0": {          "image": "selenoid/vnc_chrome:94.0",          "port": "4444",          "tmpfs": {"/tmp":"size=512m"},          "env" : [ "DRIVER_ARGS=--disable-web-security --ignore-certificate-errors --verbose" ],          "hosts": [            "myfrontend:172.20.176.10"          ]        }           }    }  }          

JavaFX how to embed ImageView

Posted: 05 Oct 2021 08:21 AM PDT

public class JavaFX extends Application {        @Override      public void start(Stage primaryStage) {          primaryStage.setTitle("Coolo");          GridPane grid = new GridPane();          grid.setAlignment(Pos.TOP_LEFT);          grid.setHgap(10);          grid.setVgap(10);          grid.setPadding(new Insets(25, 25, 25, 25));            Text scenetitle = new Text("Gib deinen Text ein");          scenetitle.setFont(Font.font("Comic Sans MS", FontWeight.BLACK, 20));          grid.add(scenetitle, 0, 0, 2, 1);            Label lbl1 = new Label("Text:");          grid.add(lbl1, 0, 1);            TextField userTextField = new TextField();          grid.add(userTextField, 1, 1);            //grid.setGridLinesVisible(true);            Button btn = new Button("Was ist passiert");          HBox hbBtn = new HBox(10);          hbBtn.setAlignment(Pos.CENTER);          hbBtn.getChildren().add(btn);          grid.add(hbBtn, 0, 2,4,1);            final Text actiontarget1 = new Text();          grid.add(actiontarget1, 1, 6);            final Text actiontarget2 = new Text();          grid.add(actiontarget2, 1, 7);            final Text actiontarget3 = new Text();          grid.add(actiontarget3, 1, 8);            userTextField.setOnKeyReleased(event -> {              if (event.getCode() == KeyCode.ENTER){                  actiontarget1.setFill(Color.ORANGERED);                  actiontarget2.setFill(Color.DEEPSKYBLUE);                  actiontarget3.setFill(Color.LIGHTSEAGREEN);                  actiontarget1.setText("Anzahl Wörter: " +WordCounter.countWords(userTextField.getText().split(" ")));                  actiontarget2.setText("Anzahl Buchstaben: " +WordCounter.countChars(userTextField.getText().split(" ")));                  actiontarget3.setText("Reversed: " +WordReverse.reverse(userTextField.getText().split(" ")));              }          });          /*            On button click the image of Obama should go all over the screen,             primaryStage.set.Title works, just the image doenst. I hope             someone can help out.          */          btn.setOnAction((ActionEvent e) -> {              Image obamaWhyGIF = new Image(JavaFX.class.getResourceAsStream("/obama-why.gif"));              ImageView obamaView = new ImageView(obamaWhyGIF);              obamaView.setX(0);              obamaView.setY(0);              obamaView.setFitHeight(300);              obamaView.setFitWidth(300);              primaryStage.setTitle("Displaying Image");          });          Scene scene = new Scene(grid, 300, 300);          primaryStage.setScene(scene);          primaryStage.show();      }        public static void main(String[] args) {          launch();      }  }  

How do i sort a 2D array or multiple arrays by the length of the array using bubble sort

Posted: 05 Oct 2021 08:21 AM PDT

trying to write a Python function: def compare_lengths(x, y, z)

which takes as arguments three arrays and checks their lengths and returns them as a triple in order of length.

For example, if the function takes [1,2,3], [10,20,30,40] and [65,32,7] as input, want it to return either ([1,2,3], [65,32,7], [10,20,30,40]) or ([65,32,7], [1,2,3], [10,20,30,40])

it can take it as either:

Array = [1,2,3],[10,20,30,40],[65,32,7]  

or:

x = [1,2,3]  y = [10,20,30,40]  z = [65,32,7]  

but it needs to be sorted as either:

([1,2,3], [65,32,7], [10,20,30,40])  

or:

([65,32,7], [1,2,3], [10,20,30,40])  

using bubble sort

In ListView.builder Bloc event triggered only once

Posted: 05 Oct 2021 08:20 AM PDT

enter image description hereenter image description hereI m using Bloc for state management , I have my screen where I'm calling event in ListView.builder

   loadSuccess: (state) {          return ListView.builder(              shrinkWrap: true,              physics: const NeverScrollableScrollPhysics(),              itemCount: state.questions.size,              itemBuilder: (                context,                index,              ) {                // ignore: avoid_unnecessary_containers                  debugPrint("this is index $index");                debugPrint(                    "this is user id ${state.questions.get(index).userId.getorCrash()}");                  context.read<UsersWatcherBloc>().add(                      UsersWatcherEvent.watchAllUsers(                        state.questions.get(index).userId.getorCrash(),                      ),                    );                return Container(                  color: Colors.white,                   ......)  

But problem is that my event is triggered only one time and state changed one time but I want to change my event for each index :

Event.dart:

    part of 'users_watcher_bloc.dart';       @freezed      abstract class UsersWatcherEvent with _$UsersWatcherEvent {      const factory UsersWatcherEvent.watchAllUsers(String uId) = _Started;        }  

Bloc.dart:

      @injectable      class UsersWatcherBloc extends Bloc<UsersWatcherEvent, UsersWatcherState> {     final IElearningRepository _iElearningRepository;        UsersWatcherBloc(this._iElearningRepository)    : super(const UsersWatcherState.initial());        @override     Stream<UsersWatcherState> mapEventToState(     UsersWatcherEvent event,   ) async* {    yield* event.map(    watchAllUsers: (e) async* {      print("this is user id ${e.uId}");      yield const UsersWatcherState.loadInProgress();      yield* _iElearningRepository.watchAllUsers(e.uId.toString()).map(            (failureOrUsers) => failureOrUsers.fold(              (f) => UsersWatcherState.loadFailure(f),              (users) {                if (users.isEmpty) {                  return const UsersWatcherState.empty();                }                  return UsersWatcherState.loadSuccess(users);              },            ),          );    },  );   }     }  

Java applications/IDE not opening (IntelliJ, Toolbox, NetBeans)

Posted: 05 Oct 2021 08:20 AM PDT

I am trying to install JetBrains toolbox, IntelliJ, and Pycharm so I can use them on my computer. When installing these they seem to install fine (no errors) but when I launch the applications I get a number of errors for classes not being found such as the ca certs and random bootstrap errors. I am not sure what the problem is but when talking with IntelliJ support they mentioned it was a Java Swift issue (not sure what this is) as it affected more than just JetBrains products. Does anyone have any advice for me to solve this issue?

System:

  • Windows 10 (up to date)
  • AMD CPU
  • NVIDIA GPU
  • Java 8 u202 (works for these programs on another computer)

What I have tried:

  • Reinstall all java
  • reinstall windows and keeping files (remove all other apps)
  • reinstall windows and delete all files (started fresh)

If there is any other info needed to help please let me know and I can get that as well.

Error from running .bat for IntelliJ (Updated 10/5):

2021-10-05 10:17:55,272 [     25]  ERROR -        #com.intellij.idea.Main - UI initialization failed  com.intellij.ide.plugins.StartupAbortedException: UI initialization failed          at com.intellij.idea.StartupUtil.lambda$start$15(StartupUtil.java:265)          at java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:986)          at java.base/java.util.concurrent.CompletableFuture.uniExceptionallyStage(CompletableFuture.java:1004)          at java.base/java.util.concurrent.CompletableFuture.exceptionally(CompletableFuture.java:2307)          at com.intellij.idea.StartupUtil.start(StartupUtil.java:264)          at com.intellij.idea.Main.bootstrap(Main.java:123)          at com.intellij.idea.Main.main(Main.java:84)  Caused by: java.util.concurrent.CompletionException: java.lang.NoClassDefFoundError: sun/java2d/pipe/PixelFillPipe          at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)          at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)          at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1739)          at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728)          at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)          at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)          at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)          at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)          at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)  Caused by: java.lang.NoClassDefFoundError: sun/java2d/pipe/PixelFillPipe          at java.desktop/sun.java2d.NullSurfaceData.<clinit>(NullSurfaceData.java:66)          at java.desktop/sun.java2d.SurfaceData.initIDs(Native Method)          at java.desktop/sun.java2d.SurfaceData.<clinit>(SurfaceData.java:120)          at java.desktop/sun.awt.windows.WToolkit.initIDs(Native Method)          at java.desktop/sun.awt.windows.WToolkit.<clinit>(WToolkit.java:130)          at java.base/java.lang.Class.forName0(Native Method)          at java.base/java.lang.Class.forName(Class.java:315)          at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:588)          at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:583)          at java.base/java.security.AccessController.doPrivileged(Native Method)          at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:582)          at com.intellij.idea.StartupUtil.lambda$scheduleInitUi$21(StartupUtil.java:434)          at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)          ... 6 more  2021-10-05 10:17:55,280 [     33]  ERROR -        #com.intellij.idea.Main - IntelliJ IDEA 2021.2.2  Build #IU-212.5284.40  2021-10-05 10:17:55,286 [     39]  ERROR -        #com.intellij.idea.Main - JDK: 11.0.12; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.  2021-10-05 10:17:55,286 [     39]  ERROR -        #com.intellij.idea.Main - OS: Windows 10  Exception in thread "JobScheduler FJ pool 4/31" java.lang.NoClassDefFoundError: java/util/ServiceConfigurationError          at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:582)          at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:804)          at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:722)          at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)          at java.base/java.lang.Iterable.forEach(Iterable.java:74)          at java.management/java.lang.management.ManagementFactory$PlatformMBeanFinder.lambda$static$0(ManagementFactory.java:926)          at java.base/java.security.AccessController.doPrivileged(Native Method)          at java.base/java.security.AccessController.doPrivileged(AccessController.java:430)          at java.management/java.lang.management.ManagementFactory$PlatformMBeanFinder.<clinit>(ManagementFactory.java:922)          at java.management/java.lang.management.ManagementFactory.getPlatformMXBean(ManagementFactory.java:684)          at java.management/java.lang.management.ManagementFactory.getRuntimeMXBean(ManagementFactory.java:364)          at com.intellij.idea.StartupUtil.logEssentialInfoAboutIde(StartupUtil.java:862)          at com.intellij.idea.StartupUtil.lambda$start$8(StartupUtil.java:225)          at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)          at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)          at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)          at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)          at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)          at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)    !bootstrap.error.title.start.failed!  !bootstrap.error.message.internal.error.please.refer.to.0!https://jb.gg/ide/critical-startup-errors!    com.intellij.ide.plugins.StartupAbortedException: UI initialization failed          at com.intellij.idea.StartupUtil.lambda$start$15(StartupUtil.java:265)          at java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:986)          at java.base/java.util.concurrent.CompletableFuture.uniExceptionallyStage(CompletableFuture.java:1004)          at java.base/java.util.concurrent.CompletableFuture.exceptionally(CompletableFuture.java:2307)          at com.intellij.idea.StartupUtil.start(StartupUtil.java:264)          at com.intellij.idea.Main.bootstrap(Main.java:123)          at com.intellij.idea.Main.main(Main.java:84)  Caused by: java.util.concurrent.CompletionException: java.lang.NoClassDefFoundError: sun/java2d/pipe/PixelFillPipe          at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)          at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)          at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1739)          at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1728)          at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)          at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)          at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)          at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)          at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)  Caused by: java.lang.NoClassDefFoundError: sun/java2d/pipe/PixelFillPipe          at java.desktop/sun.java2d.NullSurfaceData.<clinit>(NullSurfaceData.java:66)          at java.desktop/sun.java2d.SurfaceData.initIDs(Native Method)          at java.desktop/sun.java2d.SurfaceData.<clinit>(SurfaceData.java:120)          at java.desktop/sun.awt.windows.WToolkit.initIDs(Native Method)          at java.desktop/sun.awt.windows.WToolkit.<clinit>(WToolkit.java:130)          at java.base/java.lang.Class.forName0(Native Method)          at java.base/java.lang.Class.forName(Class.java:315)          at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:588)          at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:583)          at java.base/java.security.AccessController.doPrivileged(Native Method)          at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:582)          at com.intellij.idea.StartupUtil.lambda$scheduleInitUi$21(StartupUtil.java:434)          at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)          ... 6 more    -----  !bootstrap.error.message.jre.details!11.0.12+7-b1504.28 amd64 (JetBrains s.r.o.)  C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2\jbr!    Also, a UI exception occurred on an attempt to show the above message  java.lang.NoClassDefFoundError: Could not initialize class java.awt.GraphicsEnvironment$LocalGE          at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:129)          at java.desktop/javax.swing.RepaintManager.<clinit>(RepaintManager.java:243)          at java.desktop/javax.swing.JComponent.repaint(JComponent.java:4843)          at java.desktop/java.awt.Component.repaint(Component.java:3409)          at java.desktop/javax.swing.text.JTextComponent.setEditable(JTextComponent.java:1818)          at java.desktop/javax.swing.text.JTextComponent.<init>(JTextComponent.java:323)          at java.desktop/javax.swing.JEditorPane.<init>(JEditorPane.java:198)          at java.desktop/javax.swing.JTextPane.<init>(JTextPane.java:87)          at com.intellij.idea.Main.showMessage(Main.java:264)          at com.intellij.idea.Main.showMessage(Main.java:219)          at com.intellij.ide.plugins.StartupAbortedException.logAndExit(StartupAbortedException.java:88)          at com.intellij.idea.StartupUtil.lambda$start$15(StartupUtil.java:265)          at java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:986)          at java.base/java.util.concurrent.CompletableFuture.uniExceptionallyStage(CompletableFuture.java:1004)          at java.base/java.util.concurrent.CompletableFuture.exceptionally(CompletableFuture.java:2307)          at com.intellij.idea.StartupUtil.start(StartupUtil.java:264)          at com.intellij.idea.Main.bootstrap(Main.java:123)          at com.intellij.idea.Main.main(Main.java:84)  2021-10-05 10:17:55,366 [    119]  ERROR - j.openapi.util.ShutDownTracker - class com.intellij.util.containers.CollectionFactory tried to access method 'void com.intellij.util.containers.WeakHashMap.<init>(int, float, com.intellij.util.containers.HashingStrategy)' (com.intellij.util.containers.CollectionFactory and com.intellij.util.containers.WeakHashMap are in unnamed module of loader com.intellij.util.lang.PathClassLoader @7225790e)  java.lang.IllegalAccessError: class com.intellij.util.containers.CollectionFactory tried to access method 'void com.intellij.util.containers.WeakHashMap.<init>(int, float, com.intellij.util.containers.HashingStrategy)' (com.intellij.util.containers.CollectionFactory and com.intellij.util.containers.WeakHashMap are in unnamed module of loader com.intellij.util.lang.PathClassLoader @7225790e)          at com.intellij.util.containers.CollectionFactory.createWeakMap(CollectionFactory.java:54)          at com.intellij.util.containers.CollectionFactory.createWeakIdentityMap(CollectionFactory.java:81)          at com.intellij.openapi.util.ObjectTree.<init>(ObjectTree.java:29)          at com.intellij.openapi.util.Disposer.<clinit>(Disposer.java:23)          at com.intellij.idea.SocketLock.dispose(SocketLock.java:106)          at com.intellij.idea.StartupUtil.lambda$lockSystemDirs$26(StartupUtil.java:767)          at com.intellij.openapi.util.ShutDownTracker.run(ShutDownTracker.java:46)          at java.base/java.lang.Thread.run(Thread.java:829)  2021-10-05 10:17:55,366 [    119]  ERROR - j.openapi.util.ShutDownTracker - IntelliJ IDEA 2021.2.2  Build #IU-212.5284.40  2021-10-05 10:17:55,367 [    120]  ERROR - j.openapi.util.ShutDownTracker - JDK: 11.0.12; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.  2021-10-05 10:17:55,368 [    121]  ERROR - j.openapi.util.ShutDownTracker - OS: Windows 10  

Here is error from trying to launch JetBrains ToolBox app:

1.21.9712 19728 2021-10-02 14:56:39.849 WARN   DefaultDispatcher-worker-2 LoggingKt                 Failed to cleanup logs dir. java/util/Spliterators$IteratorSpliterator: java.lang.NoClassDefFoundError: java/util/Spliterators$IteratorSpliterator      at java.base/java.util.Spliterators.spliteratorUnknownSize(Unknown Source)      at java.base/java.nio.file.Files.walk(Unknown Source)      at java.base/java.nio.file.Files.walk(Unknown Source)      at com.jetbrains.toolbox.LoggingKt.cleanupLogsFolder(Logging.kt:35)      at com.jetbrains.toolbox.entry.ToolboxEntry$startToolbox$2.invokeSuspend(toolbox-process-entry.kt:72)      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)      at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)      at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)      at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)      at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)      at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)  1.21.9712 19728 2021-10-02 14:56:39.896 INFO   main I18nKt                    UI Locale set to en  1.21.9712 19728 2021-10-02 14:56:39.921 ERROR  main CertificateManager        Failed to setup certificates: java.lang.NoClassDefFoundError: java/lang/ExceptionInInitializerError      at java.base/sun.security.jca.ProviderConfig$3.run(Unknown Source)      at java.base/sun.security.jca.ProviderConfig$3.run(Unknown Source)      at java.base/java.security.AccessController.doPrivileged(Native Method)      at java.base/sun.security.jca.ProviderConfig.doLoadProvider(Unknown Source)      at java.base/sun.security.jca.ProviderConfig.getProvider(Unknown Source)      at java.base/sun.security.jca.ProviderList.loadAll(Unknown Source)      at java.base/sun.security.jca.ProviderList.removeInvalid(Unknown Source)      at java.base/sun.security.jca.Providers.getFullProviderList(Unknown Source)      at java.base/java.security.Security.getProviders(Unknown Source)      at okhttp3.internal.platform.Platform$Companion.isConscryptPreferred(Platform.kt:194)      at okhttp3.internal.platform.Platform$Companion.findJvmPlatform(Platform.kt:223)      at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:214)      at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:169)      at okhttp3.internal.platform.Platform.<clinit>(Platform.kt:170)      at okhttp3.tls.HandshakeCertificates$Builder.addPlatformTrustedCertificates(HandshakeCertificates.kt:142)      at com.jetbrains.toolbox.CertificateManager.setupTrustManager(CertificateManager.kt:42)      at com.jetbrains.toolbox.CertificateManager.<init>(CertificateManager.kt:25)      at com.jetbrains.toolbox.SettingsManagerImpl.<init>(SettingsManager.kt:65)      at com.jetbrains.toolbox.SettingsManagerImpl.<init>(SettingsManager.kt:36)      at com.jetbrains.toolbox.interop.cef.NativeGUIProcessKt.createToolboxServices(NativeGUIProcess.kt:103)      at com.jetbrains.toolbox.entry.ToolboxEntry.startToolbox(toolbox-process-entry.kt:76)  1.21.9712 19728 2021-10-02 14:56:39.921 ERROR  main ToolboxEntry              Failed to create services: java/lang/IllegalAccessError: java.lang.NoClassDefFoundError: java/lang/IllegalAccessError      at com.jetbrains.toolbox.CertificateManager.<init>(CertificateManager.kt:26)      at com.jetbrains.toolbox.SettingsManagerImpl.<init>(SettingsManager.kt:65)      at com.jetbrains.toolbox.SettingsManagerImpl.<init>(SettingsManager.kt:36)      at com.jetbrains.toolbox.interop.cef.NativeGUIProcessKt.createToolboxServices(NativeGUIProcess.kt:103)      at com.jetbrains.toolbox.entry.ToolboxEntry.startToolbox(toolbox-process-entry.kt:76)  

Angular routing with optional parameters

Posted: 05 Oct 2021 08:21 AM PDT

I use angular with optional parameters. I route to a location with navigate:

router.navigate(["route1"], { p1: v1 });  

and I see the location

/route1;p1=v1

Now I try to navigate to

/route1;p1=v1 ;p2=v2

I search something like

router.navigate({ p2: v2 }, relative);  

but I have problems finding a working syntax.

How do I generate a PDF report using data from forms in php?

Posted: 05 Oct 2021 08:21 AM PDT

I tried using mpdf but it didn't work out well for me, is there any other easy to use libraries for PHP?

Edit : TCPDF worked out well.

SVG width attribute css animation in firefox

Posted: 05 Oct 2021 08:20 AM PDT

SVG width attribute css animation not working in Firefox but in chrome it working perfectly. Please check the below snippet demo.

Does any wrong in my codes? Is there a way to apply the animation over the attribute width?

svg {    display: inline-block;  }      @-moz-keyframes glareAnim1 {    0% {      width: 0;    }    50% {      width: 10px;    }    100% {      width: 0;    }  }  @-webkit-keyframes glareAnim1 {    0% {      width: 0;    }    50% {      width: 10px;    }    100% {      width: 0;    }  }  @keyframes glareAnim1 {    0% {      width: 0;    }    50% {      width: 10px;    }    100% {      width: 0;    }  }  .glare-top {    -moz-animation: glareAnim1 2s linear infinite;    -webkit-animation: glareAnim1 2s linear infinite;    animation: glareAnim1 2s linear infinite;  }    @-moz-keyframes glareAnim2 {    0% {      width: 10px;    }    50% {      width: 0;    }    100% {      width: 10px;    }  }  @-webkit-keyframes glareAnim2 {    0% {      width: 10px;    }    50% {      width: 0;    }    100% {      width: 10px;    }  }  @keyframes glareAnim2 {    0% {      width: 10px;    }    50% {      width: 0;    }    100% {      width: 10px;    }  }  .glare-bottom {    -moz-animation: glareAnim2 2s linear infinite;    -webkit-animation: glareAnim2 2s linear infinite;    animation: glareAnim2 2s linear infinite;  }    @-moz-keyframes translateDoor {    0% {      -moz-transform: translate(-1px, 0);      transform: translate(-1px, 0);      opacity: 1;      width: 1px;      height: 6px;    }    15% {      width: 4px;    }    50% {      -moz-transform: translate(16px, 0);      transform: translate(16px, 0);      opacity: 1;      width: 2px;    }    51% {      opacity: 0;    }    100% {      -moz-transform: translateX(-10px);      transform: translateX(-10px);      opacity: 0;    }  }  @-webkit-keyframes translateDoor {    0% {      -webkit-transform: translate(-1px, 0);      transform: translate(-1px, 0);      opacity: 1;      width: 1px;      height: 6px;    }    15% {      width: 4px;    }    50% {      -webkit-transform: translate(16px, 0);      transform: translate(16px, 0);      opacity: 1;      width: 2px;    }    51% {      opacity: 0;    }    100% {      -webkit-transform: translateX(-10px);      transform: translateX(-10px);      opacity: 0;    }  }  @keyframes translateDoor {    0% {      -moz-transform: translate(-1px, 0);      -ms-transform: translate(-1px, 0);      -webkit-transform: translate(-1px, 0);      transform: translate(-1px, 0);      opacity: 1;      width: 1px;      height: 6px;    }    15% {      width: 4px;    }    50% {      -moz-transform: translate(16px, 0);      -ms-transform: translate(16px, 0);      -webkit-transform: translate(16px, 0);      transform: translate(16px, 0);      opacity: 1;      width: 2px;    }    51% {      opacity: 0;    }    100% {      -moz-transform: translateX(-10px);      -ms-transform: translateX(-10px);      -webkit-transform: translateX(-10px);      transform: translateX(-10px);      opacity: 0;    }  }  .researchDoor {    fill: #464949;    -moz-animation: translateDoor 5s linear infinite;    -webkit-animation: translateDoor 5s linear infinite;    animation: translateDoor 5s linear infinite;  }    .research0 {    fill: #FFFFFF;    stroke: #464949;    stroke-width: 2;    stroke-miterlimit: 10;  }    .research1 {    fill: #FCBD38;    overflow: hidden;  }    .research2 {    fill: #464949;  }    .research3 {    fill: none;    stroke: #464949;    stroke-width: 2;    stroke-linecap: square;    stroke-miterlimit: 10;  }
<svg version="1.1" x="0px" y="0px" viewBox="0 0 100 120" style="enable-background:new 0 0 100 120;" xml:space="preserve">      <path id="XMLID_42_" class="research0" d="M57.9,25.5c-3-6.4-8.3-11.6-8.3-11.6c-5.1,5-8.3,11.5-8.3,11.5v5.8L57.7,32L57.9,25.5z" />    <g id="XMLID_40_">      <rect x="41.4" y="25.9" class="research1" width="16.3" height="11.5" />      <path class="research2" d="M56.7,26.9v9.5H42.4v-9.5H56.7 M58.7,24.9H40.4v13.5h18.3V24.9L58.7,24.9z" />    </g>    <polygon id="XMLID_43_" class="research3" points="33.5,85.2 40.8,37.7 58.8,37.7 66.2,85.2 	" />    <!--  door    -->    <rect x="41" y="28.9" class="researchDoor" />    <!--   left top wind  -->    <rect x="30" class="glare-top" y="28" fill="#464949" width="14" height="2" />    <!--   left bottom wind    -->    <rect x="30" class="glare-bottom" y="32" fill="#464949" width="14" height="2" />    <!--   right top wind  -->    <rect x="62" y="28" class="glare-top" fill="#464949" width="14" height="2" />    <!--   right bottom wind    -->    <rect x="62" y="32" class="glare-bottom" fill="#464949" width="14" height="2" />    <!--       <line id="glareLeftTop" class="research3" x1="36.6" y1="28.7" x2="32.8" y2="28.7"/>    <line id="glareLeftBottom" class="research3" x1="36.6" y1="33.3" x2="23.8" y2="33.3"/>     <line id="glareTopRight" class="research3" x1="62.9" y1="28.7" x2="66.6" y2="28.7"/>    <line id="glareTopBottom" class="research3" x1="62.9" y1="33.3" x2="75.6" y2="33.3"/>    -->    <line id="XMLID_2_" class="research3" x1="76.3" y1="85.3" x2="23.7" y2="85.3" />    <line id="XMLID_64_" class="research3" x1="60.7" y1="37.7" x2="38.8" y2="37.7" />    <line id="XMLID_70_" class="research3" x1="58.7" y1="44.3" x2="40.8" y2="44.3" />    <line id="XMLID_79_" class="research3" x1="60.2" y1="51.7" x2="39.3" y2="51.7" />    <line id="XMLID_80_" class="research3" x1="61.7" y1="61" x2="37.8" y2="61" />    <line id="XMLID_90_" class="research3" x1="63.5" y1="69.3" x2="36.8" y2="69.3" />    <g id="XMLID_49_">      <path class="research2" d="M49.8,76.2c1.5,0,2.8,1.2,2.8,2.8v5.2H47v-5.2C47,77.4,48.2,76.2,49.8,76.2 M49.8,74.2  			c-2.6,0-4.8,2.1-4.8,4.8v7.2h9.5v-7.2C54.5,76.3,52.4,74.2,49.8,74.2L49.8,74.2z" />    </g>  </svg>

How to add echo effect to wav file in android?

Posted: 05 Oct 2021 08:20 AM PDT

I have been struggling for a while now on how to modify a wav file by adding echo effect on it; My app does pitch sifting, speed and volume, but I can't add effects. I'm a total begginer at audio engineering or something like that.

My main goal is to find an algorithm and make a function that takes the byte[] samples and modifies it.

I'm using this current code right now:        sonic = new Sonic(44100, 1);              byte samples[] = new byte[4096];              byte modifiedSamples[] = new byte[2048];              int bytesRead;                if (soundFile != null) {                  sonic.setSpeed(params[0]);                  sonic.setVolume(params[1]);                  sonic.setPitch(params[2]);                  do {                      try {                          bytesRead = soundFile.read(samples, 0, samples.length);                      } catch (IOException e) {                          e.printStackTrace();                          return null;                      }                        if (bytesRead > 0) {                          sonic.putBytes(samples, bytesRead);                      } else {                          sonic.flush();                      }                        int available = sonic.availableBytes();                        if (available > 0) {                          if (modifiedSamples.length < available) {                              modifiedSamples = new byte[available * 2];                          }                            sonic.receiveBytes(modifiedSamples, available);                          if (thread.getTrack() != null && thread.getTrack().getState() != AudioTrack.STATE_UNINITIALIZED)                                thread.WriteTrack(modifiedSamples, available);                      }                    } while (bytesRead > 0);  

As you can see I use sonic ndk to alter the pitch speed and volume by passing another byte[] array there "modifiedSamples" and I need to know if there is a way to modify this "modifiedSamples" to get the echo effect. I know this sounds like I'm asking for the function, but I don't. I just don't know anything about audio processing stuff and I would apreciate a starting point or even if what i'm trying to do is possible with my byte array.

How to measure elapsed time in Python?

Posted: 05 Oct 2021 08:21 AM PDT

What I want is to start counting time somewhere in my code and then get the passed time, to measure the time it took to execute few function. I think I'm using the timeit module wrong, but the docs are just confusing for me.

import timeit    start = timeit.timeit()  print("hello")  end = timeit.timeit()  print(end - start)  

autocomplete in vaadin?

Posted: 05 Oct 2021 08:21 AM PDT

I'm new to vaadin. How do I do autocomplete (actually, more like google suggest) on a huge set of data that cannot be loaded in memory, but instead performing a JPA query on every key event. Is it possible to capture key events on a textfield or combobox?

No comments:

Post a Comment