Tuesday, April 13, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


comma separated data display in angular on the basis of condition

Posted: 13 Apr 2021 08:39 AM PDT

I am working on a angular application. I have a ngFor in my html code which is as follows.

<span *ngFor="let data of myData">                  <img  src="assets/myImage.png">                  <span>                      {{data.title}}</span>,              </span>  

The problem is that myData array can have one single value or more than one value at run time. I want to have a display such that if one value is present then only one value is shown but if more that one value is present those should be separated by comma. In my above code I just put "," after span. It is working fine with more than one value but in case of single value comma still will be there. How can I do that?

Arranging data from django model in chartsJS

Posted: 13 Apr 2021 08:39 AM PDT

I have a chartsJS chart that takes numbers from a django model and uses the values to populate the chart. Is it possible to perform data organisation that will organise the values from highest to lowest in the data section of chartsjs:

datasets: [{      axis: 'y',      label: false,      data: [          {% for number in numbers_in_sModel %}          {{number.L1_Full_Sum}},          {{number.L2_Full_Sum}},          {{number.L3_Full_Sum}},          {{number.L4_Full_Sum}},          {{number.L5_Full_Sum}},          {{number.L6_Full_Sum}},          {{number.L7_Full_Sum}},          {{number.L8_Full_Sum}},          {{number.L9_Full_Sum}},          {{number.L10_Full_Sum}},          {% endfor %}         ],  

View cart button text color change Wordpress Storefront

Posted: 13 Apr 2021 08:39 AM PDT

I am using storefront theme and I am struggling with changing the color of the text of the "view to cart" button. When you click on "add to cart", it shows the button but the text is the same color as the background of the button, so you can`t see what is written there. I have tried everything that I found on the internet, but none of it works.. I also tried to change every color on each that I found when clicking on "Inspect element"..adding the !important everytime..

You can try to click on the "Přidat do košíku" here and inspect it on your own - https://www.alloyware.cz/produkty/ .enter image description here

Segmentation Fault on fscanf() function

Posted: 13 Apr 2021 08:39 AM PDT

I am trying to load data from a file into an array and am getting a segmentation error, I am not quite sure where my issue is. Any help is appreciated.

#include <stdio.h>  #include <stdlib.h>  #include <strings.h>    FILE* GetFile();  int GradeAvgs();  int GradeSort();  int PrintOut();    int main(void) {    FILE* userFile = GetFile();    double* studentGrades[6][10];    int i = 0;    int j = 0;    for(i = 0; i < 5; i++){      for(j = 0; i <= 9; j++){        while(!feof(userFile)){          fscanf(userFile, "%lf", studentGrades[i][j]);        }      }    }    return 0;  }    FILE* GetFile(){      FILE* fiStrm;    char fileName[40];    printf("Please enter the name of your file: \n");    fgets(fileName, 40, stdin);    fileName[strlen(fileName) - 1] = '\0';    fiStrm = fopen(fileName, "r");    perror("Error: \n");    if(fiStrm == NULL){      printf("No such file or Failure to open file.\n");}    return fiStrm;    }  

How in PhpStorm 2019.3 to open view by ref in control?

Posted: 13 Apr 2021 08:38 AM PDT

Working with laravel 8 app if there is a way in PhpStorm 2019.3.4 having view reference in the control like : return view('admin.users.index',

to open view by clicking on view name ?

I have several plugins installed as : Laravel (by Daniel Espendiller ) , LaravelStorm 1.1 but I did not get functionality I wrote above.

Can I add this functionality?

Thanks!

Python - Using accented letters

Posted: 13 Apr 2021 08:38 AM PDT

I'm having an issue with accented letters in Python. It can't really replace accented letters with non-accented letters because it won't recognize the words when searching for them in the dataframe.

The code below adds to new columns to the dataframe 'df_sb' and combines a string (Section Début or Section da Tête) with the content of another column.

The thing is, when I run the block below in my main script file, it will correctly write and display the words with accented letters (Section Début and Section da Tête). However, this needs to be executed in a different file by calling a function. When I call the function and it returns me the df_sb dataframe (with the two columns), it messes up the accented letters for some reason. I don't understand why this is happening.

for i in range(0,len(df_sb['NAME']),1):     df_sb['SECTION_DEBUT'] = "Section Début: " + df_sb.loc[:,'NAME'] + " "     df_sb['SECTION_TETE'] = "Section da Tête: " + df_sb.loc[:,'NAME'] + " "  

How should deal with this?

ZipFile ExtractToDirectory Wrong Folder Name Unicode

Posted: 13 Apr 2021 08:38 AM PDT

I have zip archive, with folders inside. Folder name contains unicode characters (Georgian letters). When I extract it I'm getting wrong folder names. For example

Folder Name in Archive: 6001 SAHIN INOX 192MM სახელური

Folder Name Extracted: 6001 SAHIN INOX 192MM fossyhew

The machines where archive was created and where I'm trying to extract it are different. Here is my code with all different options I've tried, but non of them worked.

static void Main(string[] args)      {          var ZipFilePath = $"1.zip";          ZipFile.ExtractToDirectory(ZipFilePath, AppDomain.CurrentDomain.BaseDirectory, Encoding.UTF8);          //ZipFile.ExtractToDirectory(ZipFilePath, AppDomain.CurrentDomain.BaseDirectory, new UTF8Encoding());                      //ZipFile.ExtractToDirectory(ZipFilePath, AppDomain.CurrentDomain.BaseDirectory, Encoding.GetEncoding(1252));          //ZipFile.ExtractToDirectory(ZipFilePath, AppDomain.CurrentDomain.BaseDirectory, Encoding.GetEncoding(850));                  }  

Archive URL: 1.zip

Any ideas?

Select suite of tests for coverage with pytest

Posted: 13 Apr 2021 08:38 AM PDT

I'm running a set of tests with pytest and want also to measure its coverage with the coverage package.

I have some decorators in my code, dividing the tests in several suites using something like:

@pytest.mark.firstgroup  def test_myfirsttest():      assert True is True    @pytest.mark.secondgroup  def test_mysecondtest():      assert False is False  

I need to find something like:

coverage run --suite=firstgroup -m pytest

So that in this case only the first test, since it's in the correct suite, will be used to test coverage.

The suites work correctly when I use directly pytest but I don't know how to use them in coverage

Is there any way to configure coverage to achieve this?

PostGresSQL pgAdmin Database, How do i fix "relation does not exist error"?

Posted: 13 Apr 2021 08:38 AM PDT

i have verified in the pgAdmin page and in the plsql shell and the table exists but when i run my procedure i cant seem to get it to work... what do i have wrong here?

my current table:

CREATE TABLE public.inventory_tb  (      inventory_id integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),      inventory_name character varying(100) COLLATE pg_catalog."default" NOT NULL,      brand character varying(100) COLLATE pg_catalog."default" NOT NULL,      category character varying(100) COLLATE pg_catalog."default" NOT NULL,      color character varying(100) COLLATE pg_catalog."default" NOT NULL,      date_added date NOT NULL,      inventory_size character varying(50) COLLATE pg_catalog."default" NOT NULL,      list_price money NOT NULL,      image_link character varying(100) COLLATE pg_catalog."default" NOT NULL,      sku character varying(100) COLLATE pg_catalog."default" NOT NULL,      row_status integer NOT NULL,      CONSTRAINT "inventory_tb_PK" PRIMARY KEY (inventory_id)  )    TABLESPACE pg_default;    ALTER TABLE public.inventory_tb      OWNER to postgres;  

my thought process was to input data into the database and use this procedure for an app, My Procedure:

CREATE OR REPLACE PROCEDURE public.add_inventory(      _inventory_name text,      _brand text,      _category text,      _color text,      _inventory_size text,      _image_link text,      _sku text,      _date_added date,      _list_price numeric,      _row_status integer DEFAULT 1)  LANGUAGE 'plpgsql'  AS $BODY$  BEGIN      INSERT INTO dbo.inventory_tb          (inventory_name, brand, category, color, inventory_size, image_link, sku, date_added, list_price, row_status)      VALUES          (_inventory_name, _brand, _category, _color, _inventory_size, _image_link, _sku, _date_added, _list_price, _row_status);  END;  $BODY$;    GRANT EXECUTE ON PROCEDURE public.add_inventory(text, text, text, text, text, text, text, date, numeric, integer) TO postgres;    GRANT EXECUTE ON PROCEDURE public.add_inventory(text, text, text, text, text, text, text, date, numeric, integer) TO PUBLIC;  

Call:

CALL public.add_inventory(      'Specs',      'Gracia1',      'Shirt1',      'Red1',      'Small',      'rootfile',      '00001',      '2021-03-31',      60.00,      1  );  

This is my error code exactly:

ERROR:  relation "dbo.inventory_tb" does not exist  LINE 1: INSERT INTO dbo.inventory_tb                      ^  QUERY:  INSERT INTO dbo.inventory_tb          (inventory_name, brand, category, color, inventory_size, image_link, sku, date_added, list_price, row_status)      VALUES          (_inventory_name, _brand, _category, _color, _inventory_size, _image_link, _sku, _date_added, _list_price, _row_status)  CONTEXT:  PL/pgSQL function add_inventory(text,text,text,text,text,text,text,date,numeric,integer) line 3 at SQL statement  SQL state: 42P01  

Create Grand Mean Centered Variables by Group Means in Pandas

Posted: 13 Apr 2021 08:38 AM PDT

I am trying to create grand mean centered variables by groups.

The sample data is:

import pandas as pd  import numpy as np    dat = {      'group': ['1', '1', '1', '2', '2', '1', '2'],      'age': [40, 29, 34, 35, 37, 32, 36],      'weight': [150, 175, 135, 125, 189, 178, 137],      'score': [98.0, 77.0, 88.0, 78.0, 78.0, 85.0, 84.0]      }  df = pd.DataFrame(data=dat)  

I am trying to write a function that will estimate the grand mean centered variables by groups for all the variables in the dataset. My code to attempt that is below:

def group_mean_centered(x):            d = []            d.append(x.groupby(x.iloc[:, 0]).transform('mean') - x.iloc[:,0:].mean())            d = np.asarray(d)            d_ = d.reshape(-1,len(x.columns))                dd = pd.DataFrame(d_, columns=[list(x.columns.values)])            return dd  

However, when I do that, it returns a dataframe where the grouping variable, group, is also transformed, instead of getting the groups as in the brackets []

     group           age         weight     score  0   -0.428571 [1]   -0.964286    3.928571    3.0  1   -0.428571 [1]   -0.964286    3.928571    3.0  2   -0.428571 [1]   -0.964286    3.928571    3.0  3    0.571429 [2]    1.285714   -5.238095   -4.0  4    0.571429 [2]    1.285714   -5.238095   -4.0  5   -0.428571 [1]   -0.964286    3.928571    3.0  6    0.571429 [2]    1.285714   -5.238095   -4.0  

Just looking for some ideas on how to fix the code to keep the grouping variable, group, as is instead of transforming it.

Problem with reading input from file properly

Posted: 13 Apr 2021 08:38 AM PDT

On my current project I have to read some numbers (first is coefficient, second is the exponent there of) from an input file. For some reason I get an error for using "Integer.parseInt". Does anyone know why/how to fix this? Current code below.

Error Message:

Exception in thread "main" java.lang.NumberFormatException: For input string: "2 5 "      at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)      at java.base/java.lang.Integer.parseInt(Integer.java:652)      at java.base/java.lang.Integer.parseInt(Integer.java:770)      at polynomialproject.Driver.main(Driver.java:35)      Java returned: 1  BUILD FAILED (total time: 0 seconds)  

Input File:

2 5   -4 3   1 1   -16 0  

Driver:

import java.io.*; //Can use all io's  import java.util.*; //Can use all util's  import polynomialproject.SortedLinkedList;  import polynomialproject.SortedListInterface;    public class Driver {            private static Scanner file;      static PrintWriter outputFilePrinter;      static Scanner inputFileScanner;        public static void main(String[] args) throws FileNotFoundException {                    Scanner inFile;          PrintWriter printWriter = new PrintWriter("output.txt");  //printWriter will output to proper text          inFile = new Scanner(new File("input.txt"));                    Polynomial One = new Polynomial();                     while (inFile.hasNext()) {                  String String1 = inFile.nextLine(); //Reads lines                  int one = Integer.parseInt(String1);                  String String2 = inFile.nextLine();                  int two = Integer.parseInt(String2);                  One.setTerm(two, one);           }                     Polynomial Two = new Polynomial();                     while (inFile.hasNext()){              String String1 = inFile.nextLine();              int one = Integer.parseInt(String1);                  String String2 = inFile.nextLine();                  int two = Integer.parseInt(String2);                  One.setTerm(two, one);                    }                    printWriter.println(One.toString());          printWriter.println("The degree of the first polynomial is: " + One.getDegree());          printWriter.println("The coefficient of exponent two is: " + One.getCoefficient(2));          printWriter.println("The coefficient of exponent three is: " + One.getCoefficient(3));                    printWriter.println("The degree of the second polynomial is: " + Two.getDegree());          printWriter.println("The sum of the polynomials is: " + Two.sum(Two));                    printWriter.close();      }//End main        }//End Driver  

JavaScript not getting the value

Posted: 13 Apr 2021 08:39 AM PDT

I am trying to access the form id in the js file. but I can't get the id. i have check js file is link with the blade file and also check the value in the console but not getting it.

Blade file

 <form id="ApplyCoupon" method="post" action="javascript;" class="form-horizantal" @if(Auth::check()) user="1" @endif>        @csrf        <ul>           <li>               <label for="">COUPON CODE:</label>                 <input type="text" name="code" id="code" class="form-control" placeholder="Enter Coupon Code" class="col-sm-4" required>               <br>               <button type="submit" class="btn btn-warning"> Apply </button>           </li>        </ul>     </form>  

Js file

$("#ApplyCoupon").submit(function () {      alert("Test");  });  

How to compare two instances in Python?

Posted: 13 Apr 2021 08:39 AM PDT

Is there possibility to compare two 'instances'? I have one variable and one list. Variable have type 'instance', items in list have also the same type. When I compare variable with the same item in list:

variable == list[1]  

I received 'False' as output. I'm 100% sure that both elements are the same.

Thanks in advance!

use of If function in selenium python

Posted: 13 Apr 2021 08:39 AM PDT

Below is the HTML where i would like to do an if check for 'test', if exists I want to click on rtPlus

</div></li><li class="rtLI rtLast"><div class="rtBot rtSelected TreeNodeSelect sonetto-children">                                  <span class="rtSp"></span><span class="rtPlus"></span><span class="rtIn TreeNode sonetto-children">test</span>  

enter image description here

my code

ul = driver.find_element_by_xpath("//div[@id='ctl00_ctl00_ContentPlaceHolderContent_MainCategoriserContent_Results1_ResultsTree1_radTree']/ul//ul")  ul = ul.find_element_by_xpath("./li[./div/span[text()='{}']]/ul//li[./div/span[text()='{}']]".format(levels[0],levels[1]))  if ul.text == 'test':      ul = ul.find_element_by_xpath("//span[@class='rtPlus']").click()  

Hope this info is enough please leet me know what can be done here to click on the plus icon

Access xml tag value

Posted: 13 Apr 2021 08:39 AM PDT

I have a simple xml file and I can't access the tag value (The value in Person) in a loop, it returns me empty.

  • I can, however access the other informations like : Item, name,etc. My php is something like this:
<?php  // xml file path  $path = "Users.xml";      // Read entire file into string  $xmlfile = file_get_contents($path);      // Convert xml string into an object  $new = simplexml_load_string($xmlfile);      // Convert into json  $con = json_encode($new);      // Convert into associative array  $newArr = json_decode($con, true);    foreach ($newArr['User'] as $elem) { ?>        <div class="basket-product">          <div class="item">            <div class="product-image">              <img src="../../Images/icon.png" alt="Placholder Image 2" class="product-frame">            </div>            <div class="product-details">              <h1><strong><?php echo $elem['Person'];?></strong>              <p><strong><?php echo "Order #".$i; ?></strong></p>              <p> <?php echo "Client ID - 00000000".$i; ?></p>            </div>          </div>  

and my xml file is a number of users like this:

<?xml version="1.0" encoding="UTF-8"?>  <Users>   <User Person="Alex">    <Item>     <name>Striploin</name>     <price>7.99</price>     <quantity>2</quantity>     <imagaPath>"../../Images/beef.png"</imagaPath>    </Item>    <Item>     <name>Brocoli</name>     <price>7.99</price>     <quantity>3</quantity>     <imagaPath>"../../Images/beef.png"</imagaPath>    </Item>   </User>     <User Person="Bob">    <Item>     <name>Striploin</name>     <price>7.99</price>     <quantity>2</quantity>     <imagaPath>"../../Images/beef.png"</imagaPath>    </Item>    <Item>     <name>Brocoli</name>     <price>7.99</price>     <quantity>3</quantity>     <imagaPath>"../../Images/beef.png"</imagaPath>    </Item>   </User>       </Users>  

How to operate in pairs within a list (two by two)? [duplicate]

Posted: 13 Apr 2021 08:38 AM PDT

I have a list of values

A = [1, 3, 6, 8, 2, 6, 7, 10, 12, 17]  

I want to be able to operate in pairs in a way that I can do average (1,3), (6,8), (2,9) etc.

I tried with:

for i in rang(0, len(A)):    y(i)=1/2(x(2(i-1)) + x(2(i-1)+1))  

I expect to get:

2  7  5.5  ...  

but I keep getting an error message How can I do that with a simple code with python?

React Typescript error TS2332: type '{...}' is not assignable to type '{...}'

Posted: 13 Apr 2021 08:39 AM PDT

I'm trying to dynamically render a child component using a string I get in the props of the parent component. I'm creating an object and using an interface:

interface compsInterface {    [key: string]: React.ComponentType<ComponentAProps> | React.ComponentType<ComponentBProps>;  }    const comps: compsInterface = {    compA: ComponentA,    compB: ComponentB  }    const ChildComponent = comps[type]  

But when I call the component in the html the linter tells me there is the following error (I abbreviated object attributes):

<ChildComponent {...childProps} />  ERROR: Type '{all attributes}' is not assignable to type 'IntrinsicAttributes & ComponentAProps & { children?: ReactNode; } & ComponentBProps & Record<...>'.    Property 'required attribute from component b' is missing in type 'ComponentAProps' but required in type 'ComponentBProps'.  

Component A and Component B have both different attributes from each other. It is saying that an attribute that is required in component B is missing in component A.

I'm not sure if I'm getting all this union types well. I just want to be able to tell the interface that it should either use one component type or the other without having to put all attributes optional.

Thanks for your help!

Using Evaluate with string variable not with range object

Posted: 13 Apr 2021 08:38 AM PDT

I have a line of code that returns 1d array based on a value in range A1. Example suppose there's a value 6548102 in A1 and I used this line x = [TRANSPOSE(MID(A1,1+len(A1)-ROW(OFFSET(A1,,,LEN(A1))),1))] this line returned a 1d array of each digit in A1 This is my try

Sub Demo()      Dim x      Dim s As String      s = "6548102"      'x = [TRANSPOSE(MID(A1,1+len(A1)-ROW(OFFSET(A1,,,LEN(A1))),1))]      x = [TRANSPOSE(MID(" & s & ",1+LEN(" & s & ")-ROW(OFFSET(" & s & ",,,LEN(" & s & "))),1))]      Stop  End Sub  

I tried to replace A1 with the string variable but it seems this trick doesn't work. Simply I need to deal with a string not a range with the same technique.

Docker PhpMyAdmin configuration to access Joomla (local) Windows 10

Posted: 13 Apr 2021 08:39 AM PDT

My PHP is found at: http://localhost:8080/administrator/index.php
And my PHPMyAdmin is found at: http://localhost:8080/phpmyadmin/index.php?route=/

I encounter an error when trying to log into PhpMyAdmin:

mysqli::real_connect(): (HY000/2002): No such file or directory

I have a local Docker Compose app running:

version: '3.1'    services:    joomla:      image: joomla      restart: always      links:        - joomladb:mysql      ports:        - 8080:80      volumes:        - "../:/var/www/html"      environment:        JOOMLA_DB_HOST: joomladb        JOOMLA_DB_PASSWORD: root      joomladb:      image: mysql:5.6      ports:        - 3306      restart: always      volumes:        - "./data:/var/lib/mysql"      environment:        MYSQL_ROOT_PASSWORD: root  

I go to that route via my console, and execute the command docker-compose up, that way when i list my docker images i get as follows:

C:\Users\danba/docker ps  CONTAINER ID  IMAGE     COMMAND                   CREATED       STATUS        PORTS                   NAMES  aaca47f88000  joomla    "/entrypoint.sh apac..."  2 hours ago   Up 11 minutes 0.0.0.0:8080- >80/tcp   ops_joomla_1  B8d265boбa86  mysql:5.6 "docker-entrypoint....."  19 hours ago  Up 11 minutes 0.0.0.0:55738->3306/tcp ops_joomladb_1  

I have checked my MySQL image and that works correctly.

Joomla works correctly as I can log in and navigate without encountering any problems. I havent changed any PhpMyAdmin credentials in any PHP files so it should be default, as far as I am aware that is:

  • username: root
  • pawword: ``.

Here is my config.inic.php file:

<?php  /**   * phpMyAdmin sample configuration, you can use it as base for   * manual configuration. For easier setup you can use setup/   *   * All directives are explained in documentation in the doc/ folder   * or at <https://docs.phpmyadmin.net/>.   */    declare(strict_types=1);    /**   * This is needed for cookie based authentication to encrypt password in   * cookie. Needs to be 32 chars long.   */  $cfg['blowfish_secret'] = 'W-Bo3r6x3vm-LM{fv/=uR/=2ASEHa[dP'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */    /**   * Servers configuration   */  $i = 0;    /**   * First server   */  $i++;  /* Authentication type */  $cfg['Servers'][$i]['auth_type'] = 'cookie';  /* Server parameters */  $cfg['Servers'][$i]['host'] = 'localhost';  $cfg['Servers'][$i]['compress'] = false;  $cfg['Servers'][$i]['AllowNoPassword'] = true;  $cfg['CheckConfigurationPermissions'] = false;    /**   * phpMyAdmin configuration storage settings.   */    /* User used to manipulate with storage */  // $cfg['Servers'][$i]['controlhost'] = '';  // $cfg['Servers'][$i]['controlport'] = '';  // $cfg['Servers'][$i]['controluser'] = 'pma';  // $cfg['Servers'][$i]['controlpass'] = 'pmapass';    /* Storage database and tables */  // $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';  // $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';  // $cfg['Servers'][$i]['relation'] = 'pma__relation';  // $cfg['Servers'][$i]['table_info'] = 'pma__table_info';  // $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';  // $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';  // $cfg['Servers'][$i]['column_info'] = 'pma__column_info';  // $cfg['Servers'][$i]['history'] = 'pma__history';  // $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';  // $cfg['Servers'][$i]['tracking'] = 'pma__tracking';  // $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';  // $cfg['Servers'][$i]['recent'] = 'pma__recent';  // $cfg['Servers'][$i]['favorite'] = 'pma__favorite';  // $cfg['Servers'][$i]['users'] = 'pma__users';  // $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';  // $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';  // $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';  // $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';  // $cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';  // $cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';    /**   * End of servers configuration   */    /**   * Directories for saving/loading files from server   */  $cfg['UploadDir'] = '';  $cfg['SaveDir'] = '';    /**   * Whether to display icons or text or both icons and text in table row   * action segment. Value can be either of 'icons', 'text' or 'both'.   * default = 'both'   */  //$cfg['RowActionType'] = 'icons';    /**   * Defines whether a user should be displayed a "show all (records)"   * button in browse mode or not.   * default = false   */  //$cfg['ShowAll'] = true;    /**   * Number of rows displayed when browsing a result set. If the result   * set contains more rows, "Previous" and "Next".   * Possible values: 25, 50, 100, 250, 500   * default = 25   */  //$cfg['MaxRows'] = 50;    /**   * Disallow editing of binary fields   * valid values are:   *   false    allow editing   *   'blob'   allow editing except for BLOB fields   *   'noblob' disallow editing except for BLOB fields   *   'all'    disallow editing   * default = 'blob'   */  //$cfg['ProtectBinary'] = false;    /**   * Default language to use, if not browser-defined or user-defined   * (you find all languages in the locale folder)   * uncomment the desired line:   * default = 'en'   */  //$cfg['DefaultLang'] = 'en';  //$cfg['DefaultLang'] = 'de';    /**   * How many columns should be used for table display of a database?   * (a value larger than 1 results in some information being hidden)   * default = 1   */  //$cfg['PropertiesNumColumns'] = 2;    /**   * Set to true if you want DB-based query history.If false, this utilizes   * JS-routines to display query history (lost by window close)   *   * This requires configuration storage enabled, see above.   * default = false   */  //$cfg['QueryHistoryDB'] = true;    /**   * When using DB-based query history, how many entries should be kept?   * default = 25   */  //$cfg['QueryHistoryMax'] = 100;    /**   * Whether or not to query the user before sending the error report to   * the phpMyAdmin team when a JavaScript error occurs   *   * Available options   * ('ask' | 'always' | 'never')   * default = 'ask'   */  //$cfg['SendErrorReports'] = 'always';    /**   * You can find more configuration options in the documentation   * in the doc/ folder or at <https://docs.phpmyadmin.net/>.   */  

I allowed logging in using no password by changing $cfg['Servers'][$i]['AllowNoPassword'] from false to true.

And since I couldn't change the permissions to the file, I added the following line to the file:

$cfg['CheckConfigurationPermissions'] = false;  

I also added a random blowfish as my auth mode is cookie

$cfg['blowfish_secret'] = 'W-Bo3r6x3vm-LM{fv/=uR/=2ASEHa[dP';  

I have read on other sites that the error I am getting can be fixed by changing $cfg['Servers'][$i]['host'] from 'localhost' to '127.0.0.1'. However, I want to connect by typing in "localhost" and not the IP, and it gives an other error:

mysqli::real_connect(): (HY000/2002): Connection refused

I don't think I have any dockerfiles, if I did where would I find them?

Does anyone know how to fix this problem?

I appreciate the help, thanks!

PS: If any more information is needed I'd be happy to edit the post and add it

Creating a new column in pandas with respect to the values of other rows

Posted: 13 Apr 2021 08:38 AM PDT

I have a sample data as:

column1 column2 column3 column4    0.       1.      1.      0    1.       1.      1.      1    0.       0.      0.      0    1.       1.      1.      0    1.       1.      1.      1  

I would like to create a new column(output) which shows 1 if all the row values of the dataframe are 1, otherwise 0.

The sample output is shown below:

column1 column2 column3 column4. output    0.       1.      1.      0.     0    1.       1.      1.      1.     1    0.       0.      0.      0.     0    1.       1.      1.      0.     0    1.       1.      1.      1.     1  

Find the position of an integer A in integer B for multiple occurence

Posted: 13 Apr 2021 08:38 AM PDT

I am trying to find the position of integer A in integer B.

Example:

A = 5;  B = 45356;  

I am using indexOf() but after all the position has been searched the output has -1 in it, how can I remove this?

Output for the above:

1  3  -1  

What is the correct behavior of std::get_time() for "short" input

Posted: 13 Apr 2021 08:38 AM PDT

I'm trying to understand what should be the correct behavior of C++11 std::get_time() when the input data is "shorter" than expected by the format string. For example, what the following program should print:

#include <ctime>  #include <iomanip>  #include <sstream>  #include <iostream>    int main (int argc, char* argv[])  {    using namespace std;      tm t {};    istringstream is ("2016");    is >> get_time (&t, "%Y %d");      cout << "eof:  " << is.eof ()  << endl         << "fail: " << is.fail () << endl;  }  

Note that get_time() behavior is described in terms of std::time_get<CharT,InputIt>::get(). Based on the latter (see 1c paragraph) I would expect both eofbit and failbit to be set and so the program to print:

eof:  1  fail: 1  

However, for all the major Standard C++ Library implementations (libstdc++ 10.2.1, libc++ 11.0.0, and MSVC 16.8) it prints:

eof:  1  fail: 0  

Interestingly, that for MSVC before 16.8 it prints:

eof:  1  fail: 1  

But the commit "std::get_time should not fail when format is longer than the stream" suggests that this was fixed deliberately.

Could someone clarify if (and why) the mentioned standard libraries behave correctly and, if that's the case, how it is supposed to detect that the format string was not fully used.

VeeValidate 4: two forms on one page

Posted: 13 Apr 2021 08:39 AM PDT

I have a Vue component in a Vue component, and both of them contain one form each that I want to validate individually.

<form @submit="submitLogin">    Input fields and button  </form>  <OtherComponent />  

Where the other component has a similar form. It appears when I use handleSubmit the main component will try to handle all the input fields, and the handleSubmit in OtherComponent does not work at all.

const { handleSubmit } = useForm();  

I also tried a workaround where I instead used validate, manually ran a validation on button clicks and checking meta valid to see if the form was valid.

const { validate, meta } = useForm()  

The same thing happened here, since both components use validate useForm it messes up the OtherComponent's one. When I check the meta it says it's always valid even if it isn't. I have thought about putting them in the same component but don't see how that would make a difference.

Is there a way to achieve this or do I have to someone work around it?

How to bypass certificate errors using Microsoft-EDGE

Posted: 13 Apr 2021 08:38 AM PDT

When attempting to access the local git server page Microsoft Edge displays a certificate error because the git server is using a self-signed certificate. I would like to enable access to this specific web host and bypass the error message. This can be done in other browsers, but apparently EDGE doesn't provide a way to override certificate handling or make exceptions.

Error message: "This site is not secure." DLG_FLAGS_INVALID_CA

Show a SnackBar Above Modal Bottom Sheet

Posted: 13 Apr 2021 08:39 AM PDT

I tried to display a SnackBar above my Modal Bottom Sheet, but it doesn't work. Any idea how to achieve that?

P.S.: Setting the SnackBar Behavior to Floating doesnt work. It still appears below the modal bottom sheet

Thank you

Pagination not working with custom URL structure of CPT/Taxonomy

Posted: 13 Apr 2021 08:39 AM PDT

I'm fairly new to posting here and I'll try to keep it as clear as possible! Any guidance is greatly appreciated!

The Goal:


I am trying to create a Custom Post Type and a Taxonomy where I can upload posts inside the Taxonomy and have a URL structure like this: site-name.com/cpt-slug/taxonomy-slug/post-slu.

I also need to be able to have pagination on both site-name.com/cpt-slug/ and site-name.com/cpt-slug/taxonomy-slug

Currently:


I have studied a few other posts that have gotten me 99% of the way there! I just can't quite figure out how to finish it at this point. I have done most of what this answer has suggested and i will show my code below for clarity.

CPT registration

register_post_type( 'knowledge_base',          array(              'labels' => array(                  'name' => __( 'Knowledge Base' ),                  'singular_name' => __( 'Knowledge Base Post' )              ),              'public' => true,              'has_archive' => true,              'menu_position' => 25,              'menu_icon' => 'dashicons-book',              'hierarchical' => true,              'supports' => array(                  'title',                  'editor',                  'excerpt',                  'page-attributes',                  'thumbnail'              ),              'taxonomies' => array('kb_topics'),              'rewrite' => array(                  'slug' => 'kb/%taxonomy_name%',                  'with_front' => false              ),          )      );  

Custom taxonomy registration

register_taxonomy(          'kb_topics',          'knowledge_base',          array(              'label' => 'Categories',              'hierarchical' => true,              'rewrite' => array(                  'slug' => 'kb',                  'with_front' => false              ),          )      );  

Tell WordPress how to interpret my knowledge base URL structure:

function add_rewrite_rules( $rules ) {    $new = array();    $new['kb/([^/]+)/(.+)/?$'] = 'index.php?knowledge_base=$matches[2]';    $new['kb/(.+)/?$'] = 'index.php?kb_topics=$matches[1]';      return array_merge( $new, $rules ); // Ensure our rules come first  }  add_filter( 'rewrite_rules_array', 'add_rewrite_rules' );  

Handle the %taxonomy_name% URL placeholder

function filter_post_type_link( $link, $post ) {    if ( $post->post_type == 'knowledge_base' ) {      if ( $cats = get_the_terms( $post->ID, 'kb_topics' ) ) {        $link = str_replace( '%taxonomy_name%', current( $cats )->slug, $link );      }    }    return $link;  }  add_filter( 'post_type_link', 'filter_post_type_link', 10, 2 );  

The problem:


Overall the post I referenced makes a ton of sense, I feel I understand whats going on here and everything was good until I tried setting up Pagination on the page site-name.com/kb.

This page was working great. I was able to show all the posts per category and I was able to go from here and click any post or Taxonomy and have the URL structure mentioned above. However whenever I try to go to the next page or third page I either get a 404 error or I get redirected to a post in my CPT.

As an example site-name.com/kb/page/2 always goes to the same post that is a post in my CPT and site-name.com/kb/page/3 always goes to 404. After some digging around some more I found another post that seemed to have a very promising answer and I still feel it could be the right answer I just can't get it to work. Admittedly I don't have a lot of experience with rewrites and this may be where the issue is.

Here is my version of this user's suggestion:

function fix_kb_category_pagination( $wp_rewrite ) {      unset($wp_rewrite->rules['kb/([^/]+)/page/?([0-9]{1,})/?$']);      $wp_rewrite->rules = array(          'kb/?$' => $wp_rewrite->index . '?post_type=knowledge_base',          'kb/page/?([0-9]{1,})/?$' => $wp_rewrite->index . '?post_type=knowledge_base&paged=' . $wp_rewrite->preg_index( 1 ),          'kb/([^/]+)/page/?([0-9]{1,})/?$' => $wp_rewrite->index . '?kb_topics=' . $wp_rewrite->preg_index( 1 ) . '&paged=' . $wp_rewrite->preg_index( 2 ),      ) + $wp_rewrite->rules;  }  add_action( 'generate_rewrite_rules', 'fix_kb_category_pagination' );  

I have tested the pagination and my page template by creating a different page with a slug of /kb-test/ and everything works perfectly. So this only happens on /kb/ for some reason.

From what I understand from the posts I mentioned above, WordPress has created rewrites based on the CPT and Taxonomy I set up and so its not able to go to /kb/page/, but I have tried many times now tweaking the code I have here trying to get it to recognize /kb/page/ but to no avail.

Thank you ahead of time to anyone who takes the time to look through this and respond. I really think I must be super close but just cant quite get the last bit alone. Thanks everyone!

**

UPDATE

**

First off thank you for everyone helping me format my question, much appreciated! I wanted to write a quick update to help answer this question for future viewers if I can.

After working on this more I now realize I was very close with the code above. One thing I had to do was remove the rewrite_rules_array hook. I assume because the rules were conflicting with the rules I have in the generate_rewrite_rules hook.

So that's great! However I still have one remaining issue i'm working on. For some reason when I go to site-name.com/kb/page/2/ it still goes to a post that is in the /kb/ CPT. Every other page seems to work great. site-name.com/kb/page/3/ and so on, all work correctly. I even deleted the post that /page/2/ is going to. It still goes to that same URL but now just shows 404.

I'll keep working on this and update when I figure it out. In the mean time if anyone has any tips to help with this i'd appreciate any help!

**

FINAL UPDATE

**

Turns out the last little issue of /page/2/ was a caching issue and all is good now. I will answer my question so we can close it out. Hopefully this helps anyone in the future with this same issue!

How to search the group by the DisplayName using Microsoft Graph?

Posted: 13 Apr 2021 08:39 AM PDT

According to the document, I can list the Office 365 Groups by using the following Graph API:

GET https://graph.microsoft.com/v1.0/groups

I have a C# Web application, and there is a input for searching by the Group DisplayName. Any idea how to query groups based on the DisplayName?

I have tried the following URL: https://graph.microsoft.com/v1.0/groups?$search="displayName:Test" in the MS Graph Explorer which didn't work.

I get the following error.

{  "error": {      "code": "Request_UnsupportedQuery",      "message": "This query is not supported.",      "innerError": {          "request-id": "35d90412-03f3-44e7-a7a4-d33cee155101",          "date": "2018-10-25T05:32:53"      }  }  

Any suggestion is welcomed. Thanks in advance.

Sublime Text - command to make first character uppercase

Posted: 13 Apr 2021 08:38 AM PDT

There are upper_case and lower_case commands:

{ "keys": ["ctrl+k", "ctrl+u"], "command": "upper_case" },  { "keys": ["ctrl+k", "ctrl+l"], "command": "lower_case" },  

I'm searching for command to capitalize the first letter of string, which can be assigned to custom shortcut.

Does IntelliJ support any kind of templating to create multiple files automatically?

Posted: 13 Apr 2021 08:39 AM PDT

So I have a spring mvc application, and I am noticing there is allot of repetitive code I am doing (I'm newish to both java/spring).

Each time I create a new entity I have to create the following files:

Entity  EntityDao  EntityDaoImpl  EntityService  EntityServiceImpl  

All of the files except for the Entity.java file (say User.java or Product.java etc) are pretty much something that could be automatically generated.

Is there anything out there that can help generate these files (in the correct folders)?

How to call an async method from a getter or setter?

Posted: 13 Apr 2021 08:38 AM PDT

What'd be the most elegant way to call an async method from a getter or setter in C#?

Here's some pseudo-code to help explain myself.

async Task<IEnumerable> MyAsyncMethod()  {      return await DoSomethingAsync();  }    public IEnumerable MyList  {      get      {           //call MyAsyncMethod() here      }  }  

No comments:

Post a Comment