Tuesday, May 18, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Getting rid of duplicate columns pulling through and linking output to second table like a multiway vlookup

Posted: 18 May 2021 07:55 AM PDT

Good morning, I am newish to SQL and would really appreciate some help. I am using the following query but do not want the "ar" column or second occurrence of the "station_ref column". When I try to remove it in the group by area it I get an area saying it "not in aggregate function". Also I am trying to link this output with another table named "station_sizes" where based on wk # it assigns a size to a station. For example if a station is small at wk 20 and standard at wk 48 then it will be a standard size. The station_size table outlines 100s of different scenarios and what size a station will be.Refer below for what the table looks like.Can you please help.Thanks!

wk48    wk20   station size  

standard small small

SELECT station,ar,del_date,sum(volume) /7 as volume_ref, CASE when volume_ref between 0 and 20000 then 'ds x-small' when volume_ref between 20000 and 36000 then 'ds small' when volume_ref between 36000 and 42000 then 'ds standard' when volume_ref between 42000 and 72000 then 'ds large' when volume_ref > 72000 then 'ds x-large' else 'ds small' end as station_ref, CASE when ar = 'YES' and station_ref = 'ds small' then 'ds standard' else station_ref end FROM prophecy_na.na_topology_lrp Right JOIN wbq_global.raw_station_extended_attribute ON prophecy_nq.na_topology_lrp.station = wbr_global.raw_station_extended_attribute.ds where del_date in('2021-10-17','2021-08-01','2021-06-27','2021-10-17') GROUP BY 1,2,3;

enter image description here

how to display text only on 3 lines without knowing the width of the parent block in React?

Posted: 18 May 2021 07:54 AM PDT

I have a text that needs to be displayed only on the first 3 lines of a block, and add a button to expand it at the end. What is the best way I can do this in react component?

I update a global variable in a listener but the outer method returns the former value

Posted: 18 May 2021 07:54 AM PDT

I have a method called getUserName() which intends to return a string. Inside there is an OnComplete() listener that modifies a global string variable. When getUserName() returns that string, it will return it with the global value. How can I prevent this from happening? This is the code:

private String name = "";    private String getUserName(String matchId) {      DocumentReference docRef = FirebaseFirestore.getInstance().collection("users").document(matchId);      docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {          @Override          public void onComplete(@NonNull @NotNull Task<DocumentSnapshot> task) {              DocumentSnapshot document = task.getResult();              name = document.getString("name");          }      });      return name;  }  

Why sometimes Kafka Messaging Queue returns no message when writing Integration Test?

Posted: 18 May 2021 07:54 AM PDT

I have am trying to write Integration test for Kafka Messaging in my application. When I run my tests sometimes they pass and sometimes they fail. When they fail, below line in test class fails to return any message. I am not sure why it returns message sometimes and sometimes it does not. Any help in resolving is greatly appreciated. All the configurations are in yml file.

Map<String, MessageResponse> message = messageResponseTestListener.getMessages();   

Producer

@KafkaClient  public interface MessageRequestTestProducer {         @Topic("${kafka.messageRequestTopic}")       Single<RecordMetadata> sendMessageRequest(@KafkaKey String id, MessageRequest messageRequest);  }   

Consumer

@Singleton  @KafkaListener(groupId = "test", offsetReset = OffsetReset.EARLIEST)  public class MessageResponseTestListener {        public CountDownLatch getLatch() {          return latch;      }        private CountDownLatch latch = new CountDownLatch(1);        private Map<String, MessageResponse> messages = new HashMap<>();        @Topic("${kafka.messageResponseTopic}")      public Single<MessageResponse> eventOccurred(@KafkaKey String key, Single<MessageResponse> recordSingle) {          return recordSingle.doOnSuccess(record -> {                      messages.put(key, record);                      latch.countDown();                  }          );        }        public Map<String, MessageResponse> getMessages() {          return messages;      }  }  

Test Class

@Inject  MessageRequestTestProducer messageRequestTestProducer;    @Inject  MessageResponseTestListener messageResponseTestListener;    @Test  void test() throws InterruptedException {        TEST("Message Testing Kafka version");        String id = "123";      MessageRequest messageRequest = buildCorrectRequest();      messageRequestTestProducer.sendMessageRequest(id, messageRequest).blockingGet();        messageResponseTestListener.getLatch().await(2, TimeUnit.SECONDS);      WHEN("Message event received");        Map<String, MessageResponse> message = messageResponseTestListener.getMessages();        THEN("Message is produced");        assertTrue(message.containsKey(id));      assertEquals(buildExpectedMessageResponse(), message.get(cdrId));    }  

ImagickPixel::__construct not implemented

Posted: 18 May 2021 07:54 AM PDT

Imagick has been implemented for generating a QRcode when enabling MFA. When trying to visit the page to enable MFA this error appears:

500 ImagickPixel::__construct not implemented

Here is some more info:

  • PHP 7.3 is in use
  • php7.3-imagick has been installed
  • Ubuntu 18.04 Server
  • extension=imagick.so has been added to /etc/php/7.3/apache2/php.ini
  • The apache server has been restarted after changes
  • php7.3-fpm also has been restarted
  • When running php -m | grep imagick imagick does appear

Thanks in advance!!

class or inferface expected hou to solve it

Posted: 18 May 2021 07:54 AM PDT

static final Migration MIGRATION_1_2 = new Migration(1,2) {

@Override  

public void migrate(SupportSQLiteDatabase database){

    database.execSQL("ALTER TABLE department "        +" ADD COLUMN phone_num TEXT");          }      };  

I want to calculate all binary numbers up untill x bits with y set bits

Posted: 18 May 2021 07:54 AM PDT

Is there a way to easily calculate the sequence of all numbers with a specific amount of set bits?

E.g. I want to have all numbers with 2 bits set with a maximum of 4 bits:

3: has 2 bits set to true  5: ,,  6: ,,  9: ,,  10: ,,  12: ,,  

Is there a way to determine these numbers without manually counting the bits?

How to resend a message from a whatsapp to other?

Posted: 18 May 2021 07:54 AM PDT

I have a company whatsapp account, and I want the message that reaches me to be automatically forwarded to another 5 numbers more, how i can do it?

Creating Activity using CreateNewActivityEntry of CrmServiceClient

Posted: 18 May 2021 07:54 AM PDT

I am calling the CreateNewActivityEntry() method in the CrmServiceClient. The method always returns an empty Guid and does not throw an error. The activity record is never created.

Example code:

/// <param name="activityTypeName">Part of the ActivityTypes option set.  Ex: Email, Phone, Task</param>  /// <param name="entityTypeName">For example:  Contact, Lead, Realtor Office</param>  /// <returns>The ActivityID of the new activity or Guid.Empty if it fails</returns>  public Guid CreateNewActivityForContact(string activityTypeName, string entityTypeName, Guid contactID, string subject, string description, Guid createdByID)  {      Guid tmpRet = Guid.Empty;      if (contactID != null)      {          CrmServiceClient tmpSvc = MyCompany.CRM.ServiceReference.Crm.CreateCrmService(ConfigurationManager.AppSettings["CRMServiceURL"], ConfigurationManager.AppSettings["CRMOrganization"]              , ConfigurationManager.AppSettings["CRMServiceUserName"], ConfigurationManager.AppSettings["CRMServicePassword"], ConfigurationManager.AppSettings["CRMServiceDomainName"], 0, "");            //this is not creating the record but not throwing an error either          tmpRet = tmpSvc.CreateNewActivityEntry(activityTypeName, entityTypeName, contactID, subject, description, createdByID.ToString());      }      else          throw new ApplicationException("ContactID cannot be null");        return tmpRet;  }  

We use other methods on this service so I know the service works.

The parameters all contain values that I believe are correct, but I have not been able to find any examples of implementing this method anywhere.

Does anyone have experience using the CreateNewActivityEntry method and can help?

Here is some relevant version info:

  • Using Microsoft Dynamics CRM 2016 Version: 8.1.0.359
  • Application version: .NET version 4.6.1
  • SDK version from NuGet: Microsoft.CrmSdk.XrmTooling.CoreAssembly package version 8.2.0.1

Thanks,

Eric

Are Cilk hyperobjects lock free?

Posted: 18 May 2021 07:55 AM PDT

I have read on various Cilk implementors' documentation pages that hyperobjects are used in order to mitigate data-races in a lock free way. For example:

#include <cilk/reducer_opadd.h>  cilk::reducer_opadd<int> count;  // Replaces int count;  void IncrementCount() {      // ANNOTATE_LOCK_ACQUIRE() annotation removed      count++;      // ANNOTATE_LOCK_RELEASE() annotation removed  }  

Doesn't the execution block though at the end of the IncrementCount() block scope?

Factorial Digit Sum Project Euler 20

Posted: 18 May 2021 07:54 AM PDT

I would need some help with this code bellow.

function main(n) {    factCounter = 1;    for (let i = n; i > 0; --i) {      factCounter *= i;    }    let numArr = BigInt(factCounter).toString().split('');    let sum = 0;    numArr.forEach((el) => (sum += +el));    console.log(sum);  }  main(100);  

It is solution for Project Euler #20, where i need to get the sum of all digits from 100! (factorial). But from some reason it gives me wrong answer. My output is 734, but expected output should be 648.

Please find some bug, mistake or whatever please.

how to download a file from given url to buffer with got library?

Posted: 18 May 2021 07:54 AM PDT

I want to download a file from an url with got library, this is my current code:

    var data      try      {          var stream = got.stream (url)          stream.on ('data', d => data += d)          stream.end ()      }      catch (error)      {          console.error (error)      }  

But i'm getting this error:

TypeError: The payload has been already provided  

I need a fix for Multiple videos from local drive

Posted: 18 May 2021 07:54 AM PDT

I am trying to play multiple videos from my hard drive locally. I found the code here on stack overflow at "Play local (hard-drive) video file with HTML5 video tag?". I enclosed the code in a div<> and copied it six times. The issue is that only the first player plays a video. Any help would be greatly appreciated.

<div id="video_1">  <div id="message"></div>  <input type="file" accept="video/*" />  <video id="video_1" width="400" height="239" controls="controls" preload="none">    <style>  video,  input {  display: block;  }    input {  width: 100%;  }  </style>    <script>  (function localFileVideoPlayer() {  'use strict'  var URL = window.URL || window.webkitURL  var displayMessage = function (message, isError) {  var element = document.querySelector('#message')  element.className = isError ? 'error' : 'info'  }    var playSelectedFile = function (event) {  var file = this.files[0]  var type = file.type  var videoNode = document.querySelector('video')  var canPlay = videoNode.canPlayType(type)  if (canPlay === '') canPlay = 'no'  var isError = canPlay === 'no'  displayMessage(message, isError)  if (isError) {  return  }    var fileURL = URL.createObjectURL(file)  videoNode.src = fileURL  }  var inputNode = document.querySelector('input')  inputNode.addEventListener('change', playSelectedFile, false)  })()  </script>  </div>  

Displaying FlatList using array of objects

Posted: 18 May 2021 07:54 AM PDT

I'm new in react-native I have this data and I wanna get the privateUrl in my Flatlist.

console.log(information)  

Return :

{  "images": [      {        "_id": "60a39eda33c50c377afd9cef",        "name": "155055995_4635322536484663_1177699315069654339_n.jpg",        "sizeInBytes": 677009,        "publicUrl": null,        "privateUrl": "tenant/607b7b33b168410028b2a095/informations/images/dad8915d-2292-4a9a-be2e-1b2fe711069f.jpg",        "updatedAt": "2021-05-18T14:07:42.859Z",        "createdAt": "2021-05-18T14:07:42.859Z",        "id": "60a39eda33c50c377afd9cef",        "downloadUrl": "http://172.16.224.151:8080/api/file/download?privateUrl=tenant/607b7b33b168410028b2a095/informations/images/dad8915d-2292-4a9a-be2e-1b2fe711069f.jpg"      }    ],    "email": null,    "site_web": "https://www.git-tower.com/learn/git/faq/solve-merge-conflicts/",    "num_Tel": null,    "type": "news",    "publish": "true"  }  

and this is my Flatlist :

     <FlatList              data={information}          windowSize={60}           initialNumToRender={6}           keyExtractor={(item, index) => index.toString()}          renderItem={({ item, index }) => (            <HotelItem              block              image={image}              name={item.titleFR}              location={item.createdAt}              style={{ marginLeft: 15, marginBottom: 15 }}              onPress={() => {                /* 1. Navigate to the Details route with params */                navigation.navigate('HotelDetail', {                  infoId: item._id,                });              }}              />          )}        />  

and I wanna get the privateUrl in my flatlist and i tried this :

 image={item.images.privateUrl}  

but not working .

data not refreshed after second apollo client useQuery call

Posted: 18 May 2021 07:54 AM PDT

I am using useQuery like below:

 const [query, setQuery] = useState(GET_PRODUCTS);   const { data, loading, error } = useQuery(query);  

There is a search box component, which takes setQuery prop.

When user types in search box and submit, the setQuery will set the query and above component will render.

Intended outcome: - The data should be updated with search results.

Actual outcome: - I can see the search graphql query is executed and gives search results (network tab) but data is still undefined in above component and it never refreshes . Loading works however.

Versions - @apollo/client: "^3.3.18"

ora-00900 invalid sql statement execute immediate

Posted: 18 May 2021 07:54 AM PDT

I am trying to solve a task with a dynamic SQL, but facing an issue ora-00900 invalid sql statement.

execute immediate 'alter table my_table set interval (NUMTOYMINTERVAL(1, ''MONTH''))';  

However, it works in the anonymous block treating the statement to be executed as a string.

DECLARE  str VARCHAR2 (250) := 'alter table my_table set interval (NUMTOYMINTERVAL(1, ''MONTH''))';  BEGIN      execute immediate str;  END;  

So where is the issue in the first case? It looks like with escape quotes, but can't catch this.

How can i get the original id of an id to color algorithm?

Posted: 18 May 2021 07:54 AM PDT

I have the following function to convert a given id of an object into an RGB color:

int r = ((int) id & 0x000000FF) >> 0;  int g = ((int) id & 0x0000FF00) >> 8;  int b = ((int) id & 0x00FF0000) >> 16;  

How would I receive the original id if I can get the RGB color from the mouse pixel? I can't wrap my mind around these bit operations.

Any suggestions?

EDIT my approach:

int r = pixels[index] & 0xFF;  int g = pixels[index + 1] & 0xFF;  int b = pixels[index + 2] & 0xFF;    return r + g * 256 + b * 256 * 256;  

EDIT 2 example: Input: 50 -> RGB : 255,0,0 returned value: -1,0,0 -> ID: 255

printing wrong number from defined function related to struct in c

Posted: 18 May 2021 07:54 AM PDT

I had an assignment about entering an unknown number of the students' information and then printing them out. the code that I wrote works properly for one student but when I enter other students, only the output of the phone numbers and IDs are wrong but there isn't any error message. This is the shorter version of my code. I was hoping that someone could help me find the error. Thank you for helping in advance!!

code:

#include <stdio.h>  #include <stdlib.h>  #include <string.h>  #define STRSIZE 75    struct student GetData();  int print_info (struct student *STU, int i);    struct company  {      char Co_Intern[STRSIZE];      long int Co_Tel; ///this variable has wrong output  };    struct student  {      long int ID; ///this variable has wrong output      char name[STRSIZE];      long int Tel; ///this variable has wrong output      struct company COE;      int Tot_days;        struct Date      {        int dd;        int mm;        int yyyy;      }doj;  };    int main()  {      struct student *STU;      int i, n;      printf("Enter the number of students: ");      scanf("%d", &n);      STU = (struct student*) malloc(n * sizeof(struct student));        for(i = 0; i < n; ++i)      {          STU[i]= GetData(); //calling a struct function to scan data      }      printf("\nDisplaying Information:\n==============================\n\n");      for(i = 0; i < n; ++i)      {          print_info (STU, i);  //calling a function to print data      }      return 0;  }     struct student GetData() ///struct function to scan data  {          struct student info_s;          printf("\nEnter student's information:\n");            printf("Student ID:\t");          scanf("%li", &info_s.ID);            printf("Student's name:\t");          getchar();          gets(info_s.name);            printf("Student Telephone number:\t");          scanf("%li", &info_s.Tel);             printf("\nEnter student's internship company date and information:\n");          printf("Student's Company of internship:\t");          scanf("%s", info_s.COE.Co_Intern);            printf("Company's Telephone:\t");          scanf("%li", &info_s.COE.Co_Tel);             printf("Beginning date: dd-mm-yyyy:\t");          scanf("%d%d%d", &info_s.doj.dd, &info_s.doj.mm, &info_s.doj.yyyy);          printf("Total days of internship:\t");          scanf("%d", &info_s.Tot_days);          return(info_s);  }    int print_info (struct student *STU, int i)  {          printf("\nStudent-%d:\t\t\t\t\t\t",i+1);          printf("\n\nStudent ID:\t\t\t\t\t%li", STU[i].ID);          printf("\n\nStudent's name:\t\t\t\t\t%s", STU[i].name);            printf("\n\nStudent Telephone number:\t\t\t%li", STU[i].Tel);          //here is the problem            printf("\n\nStudent's Company of internship:\t\t%s", STU[i].COE.Co_Intern);            printf("\n\nCompany's Telephone:\t\t\t\t%li", STU[i].COE.Co_Tel);  //here is the problem            printf("\n\nBeginning date: dd-mm-yyyy:\t\t\t%d%d%d", STU[i].doj.dd, STU[i].doj.mm, STU[i].doj.yyyy);          printf("\n\nTotal days of internship:\t\t\t%d", STU[i].Tot_days);          printf("\n\n==============================\n\n");  }    

and this is the output in which the long numbers are wrong:

Enter the number of students: 2    Enter student's information:  Student ID:     1234567890  Student's name: xxxx xxxx  Student Telephone number:       987654321    Enter student's internship company date and information:  Student's Company of internship:        aaaa  Company's Telephone:    5554443330  Beginning date: dd-mm-yyyy:     22-10-2020  Total days of internship:       365    Enter student's information:  Student ID:     1112223330  Student's name: nnnn ssss  Student Telephone number:       9998887770    Enter student's internship company date and information:  Student's Company of internship:        name  Company's Telephone:    3333344444  Beginning date: dd-mm-yyyy:     20-10-2020  Total days of internship:       365    Displaying Information:  ==============================      Student-1:    Student ID:                                     1234567890    Student's name:                                 xxxx xxxx    Student Telephone number:                       987654321    Student's Company of internship:                aaaa    Company's Telephone:                            1259476034    Beginning date: dd-mm-yyyy:                     22-10-2020    Total days of internship:                       365    ==============================      Student-2:    Student ID:                                     1112223330    Student's name:                                 nnnn ssss    Student Telephone number:                       1408953178    Student's Company of internship:                name    Company's Telephone:                            -961622852    Beginning date: dd-mm-yyyy:                     20-10-2020    Total days of internship:                       365    ==============================  

as you can see the following lines have problem, and only the IDs were correct however sometimes randomly the second Id is also wrong and has the wrong value but the dates and durations that I have in the code are correct. i also tried other ways that others asked about like scanning them individually as an int and then assigning them to their related struct but it didn't work as well.

Company's Telephone: -961622852

Student Telephone number: 1408953178

Company's Telephone: 1259476034

How can I skip a field for json.Marshal & not for json.Unmarshal in go?

Posted: 18 May 2021 07:54 AM PDT

type Alpha struct {     Name            string `json:"name"`    SkipWhenMarshal string `json:"skipWhenMarshal"`  }    func MarshalJSON(out interface{}){    json.Marshal(out)  }   

Is it possible to ignore the SkipWhenMarshal field when I do json.Marshal but not when I do json.Unmarshal. It should work for any type who calls MarshalJSON

Do PostgreSQL server side cursors store the results to disk?

Posted: 18 May 2021 07:54 AM PDT

Do PostgreSQL (server-side) cursors store/materialise the entire results set to disk?

Context: running some queries with a large number of results and getting disk space errors from the server.

How to select value with multiple conditions

Posted: 18 May 2021 07:54 AM PDT

tbl_A has 4 columns OrgID, EmpID, Time, Status and tbl_B has 2 columns OrgID, Threshold. There are 2 conditions:

  1. If Threshold time in tbl_B for any OrgID is 0 then simply print OrgID
  2. If Threshold time in tbl_B for OrgID is not 0, then whose Time (from tbl_A) is greater than current time that OrgID should print.

There may be multiple EmpIDs for one OrgID so we have to check validation one by one if 1st EmpID (under of same OrgID) validates Time is greater then current time then no need to check for 2nd EmpID just print OrgID directly.

tbl_status:

OrgID   EmpID   Time                         Status    100     1       2021-05-18 00:00:00.000       A       100     2       2021-05-18 00:00:00.000       B        200     1       2021-05-18 00:00:00.000       A        200     2       2021-05-18 00:00:00.000       A       

tbl_hold:

OrgID  Threshold  100       0  200       10     

IF Threshold is 0 then it does not validate any condition just print OrgID but if There is threshold value then it should first check for first EmpID and if qualify then no need to check condition for rest EmpIDs.

Output:

OrgID  100  200  

Because for OrgID 100, i first check Threshold value which is 0 so no need any condition simply it will be printed. But OrgID 200 has threshold so i checked there are 2 EmpIDs for it. so first i did validation for first EmpID of 200 OrgID and it validated condition and it worked.

Is it possible to display WPF UI components in a UWP app?

Posted: 18 May 2021 07:54 AM PDT

I have a huge application in WPF and step by step I move the UI to UWP (using XamlIslands).

In a list view for the items I have a very complex item template (still in WPF), and I'd like to create the ListView itself in UWP (because of the smooth scrolling) and to display the items from the WPF item template. Is it possible to inject somehow the WPF UI into a UWP list item?

More background:

  • The scrolling in a WPF ListView by default is very jittery (I mean it's not smooth as it is in a UWP ListView). A ListView item could cover the whole screen (it also contains a web view), so this is not acceptable from UX point of view
  • Yes, there is a way to make it smooth in WPF, but then I loose the virtualization. But this is very important, because I could have many items in that list.

I appreciate any other idea as well.

html.js loading the script only once on page load Gatsby

Posted: 18 May 2021 07:54 AM PDT

I am using html.js to load custom script. I have created a js file in static folder custom.js but when I am running my project it loads the script only once on first time page load but when I am navigation to other page it not loading the script.

My custom.js file

$(document).ready(function () {      console.log("in ready");  });  

My html.js file

import React from "react";  import PropTypes from "prop-types";  import { withPrefix } from "gatsby";    export default function HTML(props) {      return (          <html {...props.htmlAttributes}>              <head>                  <meta charSet="utf-8" />                  <meta httpEquiv="x-ua-compatible" content="ie=edge" />                  <meta                      name="viewport"                      content="width=device-width, initial-scale=1, shrink-to-fit=no"                  />                  <script                      type="text/javascript"                      src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js"                  ></script>                  <link                      href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css"                      rel="stylesheet"                      type="text/css"                  />                  {props.headComponents}              </head>              <body {...props.bodyAttributes}>                  {props.preBodyComponents}                  <div                      key={`body`}                      id="___gatsby"                      dangerouslySetInnerHTML={{ __html: props.body }}                  />                  {props.postBodyComponents}                  <link                      rel="stylesheet"                      href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"                  />                  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>                  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>                  <script                      type="text/javascript"                      src={withPrefix("js/custom.js")}                  ></script>              </body>          </html>      );  }    HTML.propTypes = {      htmlAttributes: PropTypes.object,      headComponents: PropTypes.array,      bodyAttributes: PropTypes.object,      preBodyComponents: PropTypes.array,      body: PropTypes.string,      postBodyComponents: PropTypes.array,  };  

What I am doing here wrong ? Why it's loading script only once ? What I have to do load custom.js script on every page navigation?

I have also tried to include custom.js inside my Layout file in <Helmet></Helmet> but same issue.

Thanks

How to add line at the beginning of csv file in ruby?

Posted: 18 May 2021 07:54 AM PDT

How can I add text line at the beginning of csv file? Im using csv library to create csv file, adding data in the loop and at the end I want to add a other line. How to do this?

Grep and replace set of lines in a file with a single line in linux

Posted: 18 May 2021 07:54 AM PDT

test.yaml  :        app.kubernetes.io/name: {{ .Chart.Name }}        app.kubernetes.io/instance: {{ .Release.Name }}        app.kubernetes.io/version: {{ .Chart.Version }}        app.kubernetes.io/component: {{ .Values.component }}         app.kubernetes.io/part-of: {{ .Values.partOf }}        app.kubernetes.io/managed-by: {{ .Values.managedBy }}  

where test.yaml is the name of the file. How do I replace these lines (which are present in multiple files) with a single line "app.kubernetes.io/name: {{ .Chart.Name }}".

Laravel join with 3 Tables to Filter view table

Posted: 18 May 2021 07:55 AM PDT

I am building a logistic app. I have 3 tables that look like this: users: UserID service: ServicesID providers_services: ProviderID, ServiceID providers_services table contains all services in the application provided by providers(users). that's means when a user register in the app as a provider they will select services that they will provide these stores into the providers_services table. a single user could have many services that they provide. in the dashboard, I fetch all users from the user's table (in blade view) and a select option with all services. I want when I select a service the table should be filtered and show me only the users (providers) that they provide the selected service.

This is my code :

[![enter image description here][1]][1]    public function getForm(Request $request)  {        $getSerName = $request['ServiceName'];        $dataReqServices    = DB::table('service')      ->join('category','category.CategoryID','=','service.CategoryID')      ->get();        $users = DB::table('users')     ->join('providers_services','providers_services.ProviderID','users.UserID')     ->where('users.UserID','=',$getSerName)      ->get();        return view('push.notify', compact('users','dataReqServices'));  }  

How to send image from whatsapp in flutter

Posted: 18 May 2021 07:54 AM PDT

I am a newbie flutter. I want to open (just open) WhatsApp from my app and send data (containing text and image) to select the contact. I'm able to send text in Whatsapp by using URL launch but stuck to open the image in Whatsapp. I'm using the below code.

How can I open WhatsApp from my app and share images and text with my contacts?

_launchURL() async {      const url = "whatsapp://send?text=' + state.product.title + "\n" + state.product.description + "\n" + "Price: \$" + state.product.price.toString() ";      if (await canLaunch(url)) {        await launch(url);      }    }  

HERE requests how to assign multiple values to a key in params

Posted: 18 May 2021 07:54 AM PDT

I am trying to obtain the best route using FindSequence API for n number of destinations. Here is my code:

URL5 = "https://wse.ls.hereapi.com/2/findsequence.json"  params5 = {      "apiKey": my_key,      "departure":"2014-11-11T16:52:00Z",      "start": first,      "destinations": [i for i in f],       "end": last,      "mode": "fastest;truck;traffic:enabled" # To enable traffic, "departure" parameter must be included  }    res5 = requests.get(url = URL5, params = params5)  data5 = res5.json()  

Where first and last are strings with name of the destination;lat,long

  • first = "HARDIE'S MOBILE HOME PARK; 30.44126118, -86.6240656099999"
  • last = "HOUSTON PARK MOBILE HOME PARK; 30.4424195300001, -86.64733076"

And f is a list with the other points the route must pass before arriving to the last destination.

f = ['CRESTVIEW RV PARK; 30.7190163500001, -86.5716222299999',   'HOMESTEAD TRAILER PARK; 30.5115772500001, -86.4628417499999']  

However, it looks like it is just "reading" the first and last data points and is completely ignoring the other two destinations from the list f. This is the output I am getting:

[{'id': "HARDIE'S MOBILE HOME PARK",    'lat': 30.44126118,    'lng': -86.6240656099999,    'sequence': 0,    'estimatedArrival': None,    'estimatedDeparture': '2014-11-11T16:52:00Z',    'fulfilledConstraints': []},   {'id': 'HOUSTON PARK MOBILE HOME PARK',    'lat': 30.4424195300001,    'lng': -86.64733076,    'sequence': 1,    'estimatedArrival': '2014-11-11T17:02:30Z',    'estimatedDeparture': None,    'fulfilledConstraints': []}]  

The desired output must look like this:

[{'id': "HARDIE'S MOBILE HOME PARK",    'lat': 30.44126118,    'lng': -86.6240656099999,    'sequence': 0,    'estimatedArrival': None,    'estimatedDeparture': '2014-11-11T16:52:00Z',    'fulfilledConstraints': []},   {'id': 'CRESTVIEW RV PARK',    'lat': 30.719016,    'lng': -86.571622,    'sequence': 1,    'estimatedArrival': None,    'estimatedDeparture': '2014-11-11T17:37:08Z',    'fulfilledConstraints': []},   {'id': 'HOMESTEAD TRAILER PARK',    'lat': 30.511577,    'lng': -86.462842,    'sequence': 2,    'estimatedArrival': None,    'estimatedDeparture': '2014-11-11T18:07:25Z',    'fulfilledConstraints': []},   {'id': 'HOUSTON PARK MOBILE HOME PARK',    'lat': 30.4424195300001,    'lng': -86.64733076,    'sequence': 3,    'estimatedArrival': '2014-11-11T18:43:24Z',    'estimatedDeparture': None,    'fulfilledConstraints': []}]  

And that desired output can be obtained using this code:

URL3 = "https://wse.ls.hereapi.com/2/findsequence.json"  params3 = {      "apiKey": here_api_key,      "departure":"2014-11-11T16:52:00Z",      "start": first,      "destination1": "CRESTVIEW RV PARK;30.719016, -86.571622",      "destination2": "HOMESTEAD TRAILER PARK;30.511577, -86.462842",      "end": last,      "mode": "fastest;truck;traffic:enabled" # To enable traffic, "departure" parameter must be included  }    res3 = requests.get(url = URL3, params = params3)  data3 = res3.json()  

Although the code above works just fine, it is not the best approach since I need to pass from than just 2 destinations. I am new at HERE APIs so If anyone knows how to do that I would really appreciate your help!

How to translate Jquery.animate to Vanilla JS

Posted: 18 May 2021 07:54 AM PDT

I use only a little part of Jquery code and I want to translate it

  $("html,body").animate(        {          scrollTop: sections[counter].offsetTop,          behavior: "smooth",        },        800      );  

Window.scrollTo() doesn't work

Full code

let delay = false;    let counter = 0;  // let scrollHeight = 0;    const sections = document.querySelectorAll(".scrolling-block");    function scrollToSection(e, directionY, directionX) {    if (delay) return;    // console.log(e);    delay = true;      if (directionY !== 0) {      // if scroll by y      setTimeout(function () {        delay = false;      }, 1500);    } else {      // if scroll by x      delay = false;    }      if (directionY !== 0 || directionY !== -0) {      e.preventDefault();    }    if (directionY > 0) {      //scroll down      if (counter + 1 !== sections.length) {        // scrollHeight += sections[counter].clientHeight;        counter++;      } else {        scrollHeight = scrollHeight;        counter = counter;      }      $("html,body").animate(        {          scrollTop: sections[counter].offsetTop,          behavior: "smooth",        },        800      );        // console.log(scrollHeight + "\n", counter);      return counter;    } else if (directionY < 0) {      //scroll up      if (counter - 1 !== -1) {        // scrollHeight -= sections[counter - 1].clientHeight;        counter--;      } else {        scrollHeight = scrollHeight;        counter = counter;      }        $("html,body").animate(        {          scrollTop: sections[counter].offsetTop,          behavior: "smooth",        },        800      );        // console.log(scrollHeight);      return counter;    }  }    window.addEventListener(    "wheel",    function (e) {      let directionY = e.deltaY;        let directionX = e.deltaX;        let maxY = sections[sections.length - 1].offsetTop;        if (pageYOffset < maxY - 10) {        // console.log(scrollHeight, " < ", maxY);        if (directionY !== 0) {          e.preventDefault();        }        scrollToSection(e, directionY, directionX);      } else {        if (pageYOffset < maxY && directionY < 0) {          if (directionY !== 0) {            e.preventDefault();          }          scrollToSection(e, directionY, directionX);        }        // console.log(scrollHeight, " > ", maxY);      }        // e.stopPropagation();    },    { passive: false }  );  

dotnet nuget push with user credentials

Posted: 18 May 2021 07:54 AM PDT

I am trying to push package from Linux via dotnet-cli.
I have my own nuget server - via package https://www.nuget.org/packages/NuGet.Server/
Using following command: dotnet nuget push mypackage.nupkg

I have XML config with package source:

<?xml version="1.0" encoding="UTF-8"?>  <configuration>     <config>        <add key="DefaultPushSource" value="https://mynuget.azurewebsites.net/api/v2/package" />     </config>     <packageSources>        <add key="MyNuget" value="https://mynuget.azurewebsites.net/api/v2/package" />     </packageSources>     <packageSourceCredentials>        <MyNuget>           <add key="Username" value="user" />           <add key="ClearTextPassword" value="pass" />        </MyNuget>     </packageSourceCredentials>     <apikeys>      <add key="https://mynuget.azurewebsites.net/" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAV4A39UQG0kyF2wMV56X9wQAAAAACAAAAAAAQZgAAAAEAACAAAAABPigYqsJ8B9Vcs2e6SXGUKbqctjmrNyoUQz/6H7FSWwAAAAAOgAAAAAIAACAAAAAhm/tVYS41jbvn9NIL6IPHFSFDpBDL/fbBXzdTBSRvWRAAAACY41RYMpAJoSeSdq5paZCvQAAAADZRmyl+f4XYYnPpi1Ia9Kf0TsM6ddNXUL2sJIWXtQ6zNOliZ1IGlpU62c83v93siZp7GCRjj9fIoG6ixbK2Rxg=" />    </apikeys>  </configuration>    

Error message which I am getting is:

warn : No API Key was provided and no API Key could be found for 'https://mynuget.azurewebsites.net/api/v2/package'.   To save an API Key for a source use the 'setApiKey' command.  info : Pushing mypackage.nupkg to 'https://mynuget.azurewebsites.net/api/v2/package'...  info :   PUT https://mynuget.azurewebsites.net/api/v2/package/  info :   Forbidden https://mynuget.azurewebsites.net/api/v2/package/ 3898ms  

It seems that nuget.config is completely ignored by dotnet-cli?

I also cannot pass --config-file parameter - getting error error: Unrecognized option '--config-file' but it should be possible as per documentation:
https://github.com/dotnet/docs/blob/master/docs/core/tools/dotnet-nuget-push.md

No comments:

Post a Comment