Mohamedcarriejeanine's Profile

180
Points

Questions
34

Answers
30

  • XML namespaces can be URIs, but XML element names cannot: / is not allowed in XML elements names.

    I wanted to know how can I retain all the special characters in my XML document

    Realize that your error is not about special characters in your XML document; it’s about special characters in the names of your XML elements.

    Regarding XML elements, you simply must abide by the rules specified in the standard regarding the allowed characters in XML element names. Otherwise, your data is not XML, and you and your callers will not be able to use XML tools and libraries with it.

    See also How to include ? and / in XML tag

    • 494 views
    • 1 answers
    • 0 votes
  • The documentation describes a way to get into MySQL/MariaDB if you forget the root password. For security, it only works from the same machine, and only if you have OS’s root permission.

    Non-root passwords, like the root password, are stored via one-way encryption.

    • 354 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in Mysql.

    Neither. Strict mode in this case forces you to explicitly set your default values, which is a good practice. Otherwise you will rely on mysql’s internal logic to derive the default value. What happens if that logic changes and you don’t notice it?

    • 262 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Mysql.

    Ciao, try to modify code in this way:

    connection.beginTransaction(function(err) {  if (err) { throw err; }    connection.query(`CREATE TABLE adjustreason (         AdjustID int NOT NULL AUTO_INCREMENT,         AdjustReason varchar(100) NOT NULL,         PRIMARY KEY (AdjustID)       )`, function (error, results, fields) {  if (error) {   return connection.rollback(function() {     throw error;   });  }  connection.query(`insert into adjustreason(AdjustReason) values('sdsds')`, function  (error, results, fields) {   if (error) {     return connection.rollback(function() {       throw error;     });   }   connection.query(`insert into adjustreason(FAKECOLUMN) values('sdsds')`, function   (error, results, fields) {   if (error) {     return connection.rollback(function() {       throw error;     });   }   connection.commit(function(err) {     if (err) {       return connection.rollback(function() {         throw err;       });     }     console.log('success!');   }); }); }); }); }); 

    so you call connection.query inside connection.beginTransaction and if one of those query fails, you call connection.rollback. Otherwise connection.commit

    • 307 views
    • 1 answers
    • 0 votes
  • If that’s about re-mapping your source array with filtered copies of items-objects, based on previously seen key/value pairs, you may use Array.prototype.map() in combination with Object.assign() for re-mapping along with Object.keys() together with Array.prototype.reduce() for filtering:

    const src = [{tier1:"Normal",tier2:"none",tier3:"none",tier4:"none",tier5:"none",},{tier1:"Urgent",tier2:"GCC & Labour",tier3:"new",tier4:"Cancellation",tier5:"Cancellation",},{tier1:"Urgent",tier2:"Foreigner",tier3:"renew",tier4:"Cancellation",tier5:"none",},],  simplify = (arr, hashMap = []) =>   arr.map(o => Object.assign(     {},     ...Object.keys(o).reduce((r,key) => {       const hash = key+'\ud8ff'+o[key]       if(!hashMap.includes(hash)){         r.push({[key]:o[key]})         hashMap.push(hash)       }       return r     }, [])   ))  console.log(simplify(src))
    .as-console-wrapper{min-height:100%;}

    • 254 views
    • 4 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    collections.Counter could be used for this.

    Example:

    from collections import Counter  my_str = "abra cadabra" my_str = my_str.replace(" ", "")  c = Counter(list(my_str))  print('{}\n{}\n{}'.format(c, c.keys(), c.values())) 

    output:

    Counter({'a': 5, 'b': 2, 'r': 2, 'c': 1, 'd': 1}) dict_keys(['a', 'b', 'r', 'c', 'd']) dict_values([5, 2, 2, 1, 1]) 

    You can iterate through the keys and values just like you would a normal dict.

    • 278 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in php.

    As per the image attached to the question, you are attempting to store the (assumedly) user-entered password in the database. This makes the hashing absolutely nugatory as the whole point of generating a password hash is to secure the password in the case of database intrusions.

    In your case, if you insist on using the sha1() function to generate the hash, I suggest you drop the password column from your table and add a new column which stores strings of 40-character length to store your hash.

    • 286 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in php.

    run below command

      php artisan config:cache  

    or

     composer dump-autoload 
    • 271 views
    • 4 answers
    • 0 votes
  • Asked on July 16, 2020 in HTML.

    Can you just use

    headers = [element.text.strip() for element in data_table.find_all("th")] 

    To get the text in the headers?

    To get the entire table as a pandas dataframe, you can do:

    import pandas as pd from bs4 import BeautifulSoup soup = BeautifulSoup(html_file) data_table = soup.find("div", {"class": 'mw-stack stack-container stack-clear-right mobile-float-reset'}) rows = data_table.find_all("tr")  # Delete first row as it's not part of the table and confuses pandas # this removes it from both soup and data_table rows[0].decompose() # Same for third row rows[2].decompose() # Same for last two rows rows[-1].decompose() rows[-2].decompose()  # Read html with pandas df = pd.read_html(str(data_table))[0]  # Keep only the useful columns df = df[['U.S. state or territory[i].1', 'Cases[ii]', 'Deaths', 'Recov.[iii]', 'Hosp.[iv]']]  # Rename columns df.columns = ["State", "Cases", "Deaths", "Recov.", "Hosp."]  
    • 280 views
    • 3 answers
    • 0 votes
  • Asked on July 16, 2020 in AngularJS.

    Hi,

    The best solution is to use reactive form.

    But i think you can name the edited data and pass it to your fonction updateToDB like this :

    <tr  *ngFor="let row of tableData;">         <td >{{ row.id}}</td>                            <td contenteditable="true" #data1>{{ row.editableData1 }}</td>         <td contenteditable="true" #data2>{{ row.editableData2}}</td>         <td style="color: black;">{{ row.user }}</td>         <td class="link">         <button  (click)="updatetoDB(data1, data2, row.id)" type="button">&nbsp;&nbsp;Update&nbsp;&nbsp;</button>         </td>     </tr> 

    Log the content of data1 ans data2 variables, i think tour data should be in data1.value ans data2.value.

    Hope that help you.

    • 321 views
    • 2 answers
    • 0 votes