Monday, June 27, 2022

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Can not list Azure Devops directory in visual studio and from browser stuck on login screen

Posted: 27 Jun 2022 08:02 AM PDT

I am not an expert on Azure DevOps but I created an organization, two users, and some GIT projects by reading some articles.

It was working until the last week for two users.

One day, the second user couldn't submit because he was disconnected.

Since we try to reconnect but impossible !!!

We are using Visual Studio 2022.

He is connected with his Microsoft account.

First of all, when he tries to clone an application, the azure server is not listed!

When we try to add it manually by clicking on the button Add Azure DevOps Server, it says that we must select a server from the list.

When he tries to connect via a browser, the login screen repeats an infinite loop.

I have changed the access type of the user but it doesn't change anything.

Visual studio Users

Project details

Any idea, please?

Abort trap 6 when merging arrays in bottom-up Merge Sort

Posted: 27 Jun 2022 08:02 AM PDT

I was trying to implement Merge Sort (Bottom-up approach) until a mysterious Abort trap occurs:

void botup_mergesort(int *arr, int begin, int end)  {      for (int merge_sz = 1; merge_sz < (end - begin); merge_sz *= 2)      {          for (int par = begin; par < end; par += merge_sz*2)          {              const int &sub_begin = par;              const int &sub_end = std::min(par + merge_sz*2, end);                if (sub_end - sub_begin <= 1)              {                  continue;              }                const int& m = par + merge_sz;                const int &merge_size = sub_end - sub_begin;              int *aux = new int[merge_size];              int cnt = -1;                int p1 = sub_begin;              int p2 = m;              while (p2 < end && p1 < m && p2 < sub_end)              {                  if (arr[p1] <= arr[p2])                      aux[++cnt] = arr[p1++];                  else if (arr[p1] > arr[p2])                      aux[++cnt] = arr[p2++];              }                while (p1 < m)              {                  aux[++cnt] = arr[p1++];              }                while (p2 < sub_end && p2 < end)              {                  aux[++cnt] = arr[p2++];              }                for (int i = sub_begin, m_cnt = 0; i < sub_end; ++i)              {                  arr[i] = aux[m_cnt++];              }              delete[] aux;          }      }  }    void sort(int *arr, int begin, int end) { botup_mergesort(arr, begin, end); }    int main()  {      int arr[] = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5};      // int arr2[] = {2, 2, 2, 2, 2, 8, 5, 3, 9, 4, 6, 2, 1, 5, 1, 5, 7};      int n = sizeof(arr) / sizeof(int);      cout << "Size: " << n << endl;        sort(arr, 0, n);        print(arr, n);      return 0;  }  

The code works fine for small arrays, i.e int arr2[], but as the array gets bigger, Abort trap comes back.

I tried using the debugger and it returned SIGABRT at delete[] aux;. I did a little search on the internet and decided to use std::vector instead of a dynamic array, and it worked. However, I really desired to know what is wrong behind this code.

My compiler is Apple clang version 11.0.3 on Visual Studio Code.

Thank you for your help! Sorry I've forgetten something, I am a inexperienced college student.

Filtering Flux elements based on result of webservice call

Posted: 27 Jun 2022 08:02 AM PDT

In below code I am filtering elements ina flux based on some logic and then further filtering based on the result of webservice call. Now the webservice returns a Mono so I can use it in the filter method. calling block() doesn't work. Can someone how to go about this. Thanks in advance. The code is not fully compilable as I removed company specific code.

protected Flux<> getFilteredResults(Flux<> resultsToFilter, boolean someBoolean) {          return resultsToFilter.filter(cr -> {              //Filtering logic          })                  .filter( a-> {                      Mono<Boolean> serviceCallResult = makeServiceCall(a);                      return serviceCallResult.block(); //HOW TO DO THIS CORRECTLY                  });        }  

UDP packet does not gets distributed in rr fashion in IPVS mode in K8S

Posted: 27 Jun 2022 08:01 AM PDT

I am running a kubernetes cluster with ipvs mode rr scheduler. I want to set the Udp time out of ipvsadm to zero, but the minimum value permissible for udptimeout is 1. (ipvsadm --set 900 180 1)

Can anyone help as I am unable to distribute Udp traffic in a round robin fashion from one server to another server due to 1 second of time out I want to disable the udptimeout of ipvsadm

REGEX Syntax for CaSe Insensitive - Tosca

Posted: 27 Jun 2022 08:01 AM PDT

Does anyone have the REGEX syntax for Tosca automation app.? I'm trying to verify 2 buffers with case mismatch.

Hi, I just started in Odoo with docker but I had several problems

Posted: 27 Jun 2022 08:01 AM PDT

#the first was in importing the odoo library

'from odoo import controller'

#the second was about entering the PostgreSQL database but I can not access. What can you recommend me to do to fix this problem?

NiFi Unable to write flowfile content to content repository

Posted: 27 Jun 2022 08:01 AM PDT

I have a simple flow which receive http requests by handlehttprequest, process it and write to Kafka. I don't have any error in processors, but I give this error in panel.

6 WARN [Timer-Driven Process Thread-9] o.a.n.c.repository.FileSystemRepository Unable to write flowfile content to content repository container default due to archive file size constraints; waiting for archive cleanup. Total number of files currently archived = 1198

It seems related to Content Repository Archiving, but I don't know how to solve it. Is it possible to disable archiving by nifi.content.repository.archive.enabled set to false without affecting to loss data in flow.

How do you animate between two different lists of CatmullRomSpline points?

Posted: 27 Jun 2022 08:01 AM PDT

I've been playing around with the CatmullRomSpline class from Flutter the past few days. Drawing points with is trivial, however, I've been looking for information on interpolating between two sets of values and haven't had much luck.

to give a better overview here is the first plot of offsets: 1

This is the next plot of offsets that I would like to morph/animate to:

2

Here is the code I have so far:

import 'dart:ui';    import 'package:curves/data.dart';  import 'package:flutter/material.dart';  import 'dart:math' as math;    import 'models/price_plot.dart';    void main() {    runApp(const App());  }    class App extends StatelessWidget {    const App({Key? key}) : super(key: key);      @override    Widget build(BuildContext context) {      return const MaterialApp(        home: Home(),      );    }  }    class Home extends StatefulWidget {    const Home({      Key? key,    }) : super(key: key);      @override    State<Home> createState() => _HomeState();  }    class _HomeState extends State<Home> with SingleTickerProviderStateMixin {    late Animation<List<Offset>> animation;    late AnimationController controller;      List<Offset> controlPoints = [];      @override    void initState() {      super.initState();        WidgetsBinding.instance.addPostFrameCallback((_) {        controlPoints = buildControlPoints(hourItems);          setState(() {});      });    }      List<Offset> buildControlPoints(List<List<double>> items) {      final max = items.map((x) => x.last).fold<double>(            items.first.last,            math.max,          );      final min = items.map((x) => x.last).fold<double>(            items.first.last,            math.min,          );        final range = max - min;        final priceMap = {        for (var v in items)          v.last: ((max - v.last) / range) * MediaQuery.of(context).size.height,      };        final pricePlots =          priceMap.entries.map((e) => PricePlot(e.value.toInt(), e.key)).toList();        return controlPoints = List.generate(        pricePlots.length,        (index) {          return Offset(            calculateXOffset(                MediaQuery.of(context).size.width, pricePlots, index),            pricePlots[index].yAxis.toDouble(),          );        },      ).toList();    }      double calculateXOffset(double width, List<PricePlot> list, int index) {      if (index == (list.length - 1)) {        return width;      }        return index == 0 ? 0 : width ~/ list.length * (index + 1);    }      void _startAnimation() {      controller.stop();      controller.reset();      controller.forward();    }      @override    Widget build(BuildContext context) {      return Scaffold(        appBar: AppBar(          title: const Text("App"),        ),        body: Stack(          children: [            CustomPaint(              painter: SplinePainter(controlPoints),              size: Size(MediaQuery.of(context).size.width,                  MediaQuery.of(context).size.height),            ),            FloatingActionButton(onPressed: () {              _startAnimation();            })          ],        ),      );    }  }    class SplinePainter extends CustomPainter {    final List<Offset> items;      SplinePainter(this.items);      @override    void paint(Canvas canvas, Size size) {      canvas.drawPaint(Paint()..color = Colors.white);        if (items.isEmpty) {        return;      }        final spline = CatmullRomSpline(items);        final bezierPaint = Paint()        ..strokeCap = StrokeCap.round        ..strokeWidth = 2        ..color = Colors.blue;        canvas.drawPoints(        PointMode.points,        spline.generateSamples(tolerance: 1e-17).map((e) => e.value).toList(),        bezierPaint,      );    }      @override    bool shouldRepaint(SplinePainter oldDelegate) => true;  }    

Java DateTimeFormatter 'OR'?

Posted: 27 Jun 2022 08:02 AM PDT

Is there a way do write a DateTimeFormatter pattern that parser "either" one of two optional parts? Something like (MMMM-d-(yy OR yyyy))?

For an example:

val formatter = DateTimeFormatter.ofPattern("MMMM-d-[yyyy][yy]");  System.out.println(formatter.parse("June-27-2022")); // {},ISO resolved to 2022-06-27  System.out.println(formatter.parse("June-27-22")); // {},ISO resolved to 2022-06-27  System.out.println(formatter.parse("June-27-")); // {MonthOfYear=6, DayOfMonth=27},ISO  

I want to parse either the short (yy) or long (yyyy) year format. The problem with my pattern is that the last example gets parsed without either of these optional parts of the pattern defined.

How to aggregate data for logic and show non-aggregated results in the output?

Posted: 27 Jun 2022 08:02 AM PDT

I have a table that looks like below:

person fruit date
A apple xxxx
B banana xxxx
C apple xxxx
A banana xxxx
C apple xxxx
B banana xxxx

I am interested in persons who have more than one banana in the data set. In this case, it would be person B. I understand how to achieve this by aggregating the data. However, if I want my result to be NOT agrregated and look something like below, what would be the best way?

person fruit date
B banana xxxx
B banana xxxx

What is the equivalent "Yup.transform" of Joi?

Posted: 27 Jun 2022 08:01 AM PDT

I'm using Yup package for data validation schemas but I would like to start to use Joi now. Or atleast, learn it.

This screenshot is what I have now for my app : My Yup version

And I would like to do exactly the same thing but with Joi and I can't find the equivalent of Yup's "transform()" method.

My need is simple: I have a property, I want to accept null values BUT if I get a null value, then I transform it to false (as you see in the screenshot above).

Thanks in advance !

UPDATE:

  Yup.boolean().nullable().transform((value) => (value === null ? false : value));    

UPDATE 2::

I tried this, it doesn't work :

Joi.boolean().allow(null).custom((value, helper) => {                  if (value === null) {                      return false;                  }                    return value;              });    

The result of my unit test of the code above :

Expected: false  Received: null  

Delete the second to last line of a json file

Posted: 27 Jun 2022 08:01 AM PDT

I am trying to write user inputs into a json file. My issue is in maintaining valid json. Every time I write new data to my file I need to delete a closing square bracket "]" which is on the second to last line of my file. I'm still new to C++ and not sure how to do this.

ForEach-Object Delete & Out-File

Posted: 27 Jun 2022 08:01 AM PDT

I'm having trouble with one of my file deletion scripts on my directories.

I use Get-ChildItem to get the different files I want and I delete them with a del. I would then like to keep logs of the deleted files with an Out-File. However the Out-file does not work and the log file is empty. The files are well deleted.

Here is my code, does anyone have any idea how I can solve my problem?

#5th directory  $Folder5 = "E:\What\Ever\"  #delete  Get-ChildItem $Folder5 -Recurse -Force -ea 0 | Where-Object      { $_.psiscontainer -and $_.fullname -notmatch 'coolfiles' -and $_.LastWriteTime -lt (Get-Date).AddDays(-90) }  |   Select-Object -expandproperty FullName |  ForEach-Object {      $_ | del -Force -Recurse      $_.FullName | Out-File "C:\What\Ever\deleteditems.txt" -encoding ASCII -Append      }  

Thanks a lot

R: Splitting multiple-choice-column and creating a matrix

Posted: 27 Jun 2022 08:01 AM PDT

I have a multiple-choice-question with seven possible answers, my data looks like this:

Q12
1 Inhalt, Ermöglichen Koalition
2 Inhalt, Ermöglichen Koalition, Verhindern Kanzlerschaft
3 Inhalt
4 Spitzenpolitiker

My goal is to -> seperate the observations and create a binary matrix with seven variables ("Inhalt", "Arbeit", "Verhindern Koalition", "Ermöglichen Koalition", "Verhindern Kanzlerschaft", "Ermöglichen Kanzlerschaft", "Spitzenpolitiker") akin to this:

Inhalt Ermöglichen Koalition Verhindern Kanzlerschaft Spitzenpolitiker
1 1 1 0 0
2 1 1 1 0
3 1 0 0 0
4 0 0 0 1

I have tried einzeln_strategisch_2021 <- data.frame(strategisch_2021[, ! colnames (strategisch_2021) %in% "Q12"], model.matrix(~ Q12 - 1, strategisch_2021)) %>%

This gives me the matrix I want but it does not separate the observations, so now I have a matrix with 20 variables instead of the seven

also tried seperate() like this separate(Q12, into = c("Inhalt", "Arbeit", "Verhindern Koalition", "Ermöglichen Koalition", "Verhindern Kanzlerschaft", "Ermöglichen Kanzlerschaft", "Spitzenpolitiker"), ",") %>%

This does separate the observations, but not in the right order and without the matrix.

I also tried to use splitstackshape and the charMat-function, but I cant get that to work at all (judging from the description "Create a Binary Matrix from a List of Character Values") it should do exactly what I want.

Any help would be greatly appreciated as I have been stuck for days now ;)

Case insensitive search over email field as index in MongoDB

Posted: 27 Jun 2022 08:01 AM PDT

My collection of users (user) is indexed by the email field (and some other indexes). Trying to find all documents that has an email that has an email which starts with a search term case insensitive (trying to implement serach-suggest logic).

I'm using the following query:

db.user.getCollection('user').find({      "email" :  /^myEmail@gmail/i  })  

As I understood, when using regex we are not able to use the index capabilities hence my query runs very slow.

Is there a way to implement such starts with search logic over indexed filed using MongoDB (or additional Atlas capabilities) leveraging the indexed field over large collection or should I use different technology for that matter?

Edit Tried text indexes and it didn't work as I expected. Mongo text search treats myEmail@gmail as 2 different text tokens myEmail and gmail so I'm getting results matching myEmail and results matching gmail. It is not what I'm looking for.

Testing method calls within subscribe call back function

Posted: 27 Jun 2022 08:01 AM PDT

I'm trying to create a test which tests whether a method has been called within the subscribe call back function. This is the method in which the test has been setup for:

 save() {     this.testService.upsert(this.test).subscribe(() => {          this.testMethod();     });   }  

This is the test I have setup:

 it('should call testMethod()', () => {         mockTestService.upsert.and.returnValue(of(null));         component.save();         const spy = spyOn(component, 'testMethod');         expect(spy.calls.count()).toBe(1);   });  

I have a spy object setup on the service:

beforeEach(() => {          mockTestService = jasmine.createSpyObj(['upsert']);          TestBed.configureTestingModule({              imports: [HttpClientTestingModule],              declarations: [TestComponent],              providers: [                  { provide: TestService, useValue: mockTestService },              ],              schemas: [NO_ERRORS_SCHEMA]          })              .compileComponents();          fixture = TestBed.createComponent(TestComponent);          component = fixture.componentInstance;      });  

The test is failing with 'Error: Expected 0 to be 1'

Anyone know how to approach testing method calls within a subscribe call back?

how to implement backend using Koajs(C)?

Posted: 27 Jun 2022 08:02 AM PDT

I am facing an issue while trying to implement my backend with koa. The problem is that I cannot figure out the structure of it. I don't know what I am missing in my code, I really need your help and I am open to all advice so I can better understand what to do it. Here below are my codes:

const customers = require('./index').db('shop').collection('customers');    const objectId = require('mongodb').ObjectId;    const save = async({name, email, phone, address}) => {  const result = await customers.insertOne({name, email, phone, address});  return result;  }  

How to use automatic variables in Swagger UI?

Posted: 27 Jun 2022 08:02 AM PDT

In Postman I can automatically save variables the from response body.

For example: First I send login request and as response I get accessToken and refreshToken variables.

Sending request

Then by Postman test scripts I save these variables:

var jsonData = JSON.parse(responseBody);  postman.setEnvironmentVariable("access_token", jsonData.accessToken);  postman.setEnvironmentVariable("refresh_token", jsonData.refreshToken);  

These variables automatically updates themselves in next request:

automatically updates themselves

The question is how I can do the same in Swagger UI?

The problem is that by default in Swagger UI every time I need to write refresh token by hand:

Writing by hand

Cannot connect to Firebase's Firestore Database New Collection

Posted: 27 Jun 2022 08:02 AM PDT

I have a problem where I can connect my firebase database collection "Agricultures" but I cannot connect with the "Admins" collection. Here are some of my codes in my firebase file.

// Initialize Firebase  const app = initializeApp(firebaseConfig);  const db = getFirestore(app);  const AgriColRef = collection(db, "Agricultures");  export const AdminColRef = collection(db, "Admins");    export default AgriColRef;   

However, it returned with the error

[Vue warn]: Property "fname" was accessed during render but is not defined on instance.      at <AddAdmin onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > >      at <RouterView>      at <App>  

including for the other attributes.

Here is the code in the AddAdmin file

<script>  import { AdminColRef } from '../firebase';  import { addDoc } from 'firebase/firestore'    export default {      dataAdmin(){          return {              fname:null,              lnama:null,              workerno:null,          };      },      methods: {          async createAdmin() {              console.log("Create");              const addedDoc = await addDoc(AdminColRef, this.$dataAdmin);              console.log(addedDoc);          }      }  };  </script>  

Next is in the router

import AddAdmin from '../components/admin/AddAdmin.vue'  const routes = [{          path: '/add-admin',          name: 'addAdmin',          component: AddAdmin      }]  const router = createRouter({      history: createWebHistory(process.env.BASE_URL),      routes  })    export default router  

And in the App file

<nav>     <router-link to="/add-admin">Add Admin</router-link>  </nav>  

Dataproc; Spark job fails on Dataproc Spark cluster, but runs locally

Posted: 27 Jun 2022 08:01 AM PDT

I have a JAR file generated via a Maven project that works fine when I run it locally via java -jar JARFILENAME.jar. However, when I try to run the same JAR file on Dataproc I get the following error:

22/06/27 13:13:45 INFO org.apache.spark.SparkEnv: Registering BlockManagerMaster  22/06/27 13:13:46 INFO org.apache.spark.SparkEnv: Registering BlockManagerMasterHeartbeat  22/06/27 13:13:46 INFO org.apache.spark.SparkEnv: Registering OutputCommitCoordinator  22/06/27 13:13:49 INFO org.sparkproject.jetty.util.log: Logging initialized @7373ms to org.sparkproject.jetty.util.log.Slf4jLog  22/06/27 13:13:51 INFO com.google.cloud.hadoop.repackaged.gcs.com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl: Ignoring exception of type GoogleJsonResponseException; verified object already exists with desired state.  Exception in thread "main" java.lang.NoSuchMethodError: org.apache.spark.sql.catalyst.expressions.aggregate.ApproximatePercentile$PercentileDigest.getPercentiles([D)Lscala/collection/Seq;      at com.amazon.deequ.analyzers.ApproxQuantile.fromAggregationResult(ApproxQuantile.scala:84)      at com.amazon.deequ.analyzers.ScanShareableAnalyzer.metricFromAggregationResult(Analyzer.scala:192)      at com.amazon.deequ.analyzers.ScanShareableAnalyzer.metricFromAggregationResult$(Analyzer.scala:185)      at com.amazon.deequ.analyzers.ApproxQuantile.metricFromAggregationResult(ApproxQuantile.scala:50)      at com.amazon.deequ.analyzers.runners.AnalysisRunner$.successOrFailureMetricFrom(AnalysisRunner.scala:362)      at com.amazon.deequ.analyzers.runners.AnalysisRunner$.$anonfun$runScanningAnalyzers$5(AnalysisRunner.scala:330)      at scala.collection.immutable.List.map(List.scala:297)      at com.amazon.deequ.analyzers.runners.AnalysisRunner$.liftedTree1$1(AnalysisRunner.scala:328)      at com.amazon.deequ.analyzers.runners.AnalysisRunner$.runScanningAnalyzers(AnalysisRunner.scala:318)      at com.amazon.deequ.analyzers.runners.AnalysisRunner$.doAnalysisRun(AnalysisRunner.scala:167)      at com.amazon.deequ.VerificationSuite.doVerificationRun(VerificationSuite.scala:121)      at com.amazon.deequ.VerificationRunBuilder.run(VerificationRunBuilder.scala:173)      at com.amazon.deequ.thesis.GCTestOne$.$anonfun$main$1(GCTestOne.scala:42)      at com.amazon.deequ.thesis.GCTestOne$.$anonfun$main$1$adapted(GCTestOne.scala:11)      at com.amazon.deequ.examples.ExampleUtils$.withSpark(ExampleUtils.scala:32)      at com.amazon.deequ.thesis.GCTestOne$.main(GCTestOne.scala:11)      at com.amazon.deequ.thesis.GCTestOne.main(GCTestOne.scala)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)      at java.lang.reflect.Method.invoke(Method.java:498)      at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)      at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:951)      at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:180)      at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:203)      at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:90)      at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1039)      at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1048)      at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)  

I quite don't get why Dataproc has a NoSuchMethodError when everything runs fine locally.

Someone knows why this is?

How to skip php empty rows in a table [closed]

Posted: 27 Jun 2022 08:01 AM PDT

I'm trying combine a table where fixtures are under their respective leagues [Headers] but i'm having a problem with the empty rows appearing in my table as its showing the empty rows instead of ignoring them

please check through the three pictures on how i want to shape my table:

SQL Table With Empty Cells In COL 1

HTML Table With Empty Rows Under Every Row

How I want My Table To Look Like after skipping empty Rows

My Code:

  <!DOCTYPE html>  <html lang="en">  <head>            <meta charset="UTF-8">      <meta http-equiv="X-UA-Compatible" content="IE=edge">      <meta name="viewport" content="width=device-width, initial-scale=1.0">      <title>Welcome To Bet 13</title>      <link rel="stylesheet" href="style.css">      <link rel="stylesheet" href="button.css">      <script src="https://code.jquery.com/jquery-3.5.0.js"></script>              </head>    <body style ="margin:10px;">    <table class="tg" >  <thead>    <tr>      <td>Acc:(+264 818054386)</td>      <td>Bal:</td>      <td>N$ 0.00</td>      <td width=20></td>      <td input class="logsig" type="button" value=>Sign Up</td>      <td width=20></td>      <td input class="logsig" type="button" value=>Login</td>    </tr>  </thead>  </table>      <br>  <br>      <img src="img/Logo.png" alt="" class="center" >      </label>      <br>  <br>    <table class="Fixtures-Table">            <thead>          <tr>                            <th>League</th>            </tr>        </thead>            <tbody >            <?php            $servername = "localhost";          $username = "root";          $password = "";          $database = "mystore";            $connection = mysqli_connect($servername, $username, $password, $database);            if($connection->connect_error) {              die("connection failed: " . $connection->connect_error);          }            $sql = "SELECT * FROM engine";          $result = $connection->query($sql);                        if (!$result) {                die("Invalid Query: " . $connection->error);          }                      while($row = $result->fetch_assoc()) {                  if(!$row["COL 1"] && !$row["COL 2"]){                      continue;                  }                                echo "          <tr>            <th class='leagues'>" . $row["COL 1"] . "</th>               </tr>                <tr class='legs' >                <td>" . $row["COL 2"] . "</td>        <tr>";            }                          ?>          <tbody>        </table>      <script>            $(document).ready(function(){               $('.buttons').click(function() {                   $(this).toggleClass('active');              });          });     </script>       <script>    var table =document              </script>      </body>  </html>    php  html      

Setuptools: Creating custom command to install selected package dynamically

Posted: 27 Jun 2022 08:01 AM PDT

I have following package tree , I want to install the particular package from src and base (always install with selected package from src). I am trying to create custom command so that using pip I can pass list of packages names to install as follow: pip install setup.py --install-option="--package=package_1, package_2" , so this should install package_1, package_2 along with base package using single setup.py(let me know if I need more at particular package level too) I am following below folder tree.

parent_package  └── src  |    ├── mypkg1  |    │   ├── module1.py  |    │   ├── module2.py  |    │   └── __init__.py   |    └── mypkg2  |        ├── module1.py  |        └── __init__.py  |  |---- base  |      |----- init.py  |      |----- module1.py   |---- setup.py  |---- requirements.txt  

I have written code as below which is giving an error

from setuptools import setup, find_packages  from setuptools.command.install import install    import sys  # new install class  class InstallCommand(install):      # pass argument subpackage from pip install to setup.py      user_options = install.user_options + [          ('subpackage=', None, None),        ]        def initialize_options(self):          sys.stdout.write(f"Inside initialize_options--->")          sys.stdout.flush()          install.initialize_options(self)          self.subpackage = None        def finalize_options(self):          sys.stdout.write(f"Inside finalize_options--->")          sys.stdout.flush()          install.finalize_options(self)        def run(self):            if self.subpackage is None:              sys.stdout.write(f"Inside IF condition--->")              sys.stdout.flush()              # install all sub-packages              subpackages = find_packages() + ['src.'+x for x in find_packages(where='src')]#['src.'+x for x in find_packages('./src', exclude=['*.tests', '*.tests.*', 'tests.*', 'tests'])]              sys.stdout.write(f"packages to install --->{subpackages}")              sys.stdout.flush()              self.distribution.packages += ['src'] + subpackages             else:                subpackages = self.subpackage.split(', ')              # print("Install sub-packages:", self.subpackage)              # install only specific sub-packages              subpackages = ['src.'+x for x in subpackages]              self.distribution.packages += find_packages() + subpackages#['src'] + subpackages          sys.stdout.write(f"packages distribution install --->{self.distribution.packages}")          sys.stdout.flush()          install.run(self)    metadata = dict(      name='my_connector',      packages=[],      install_requires=[],      setup_requires=[],      cmdclass={          'install': InstallCommand      }      )    setup(**metadata)  

Issue :-

After debugging I could see it's always going in my else condition and installing all the available packages. I tried to print flow , I could see it's first going in initialize_options function and making self.subpackage = None causing entering into else part and not in if.

How should I check for subpackage which I have mentioned in command running as follow:

pip install . -v --install-option="--subpackage=package_1,"  

How to update progress bar animation onclick?

Posted: 27 Jun 2022 08:01 AM PDT

I am working on a web project and I am trying to create a dynamic form with radio buttons that updates an animated progress-bar.

This is what I have so far: JSFiddle

I have multiple groups of radio buttons that should update the progress-bar onclick and it is working, but the CSS is using set widths rather than just changing it by a certain %, therefore when I click radios from other groups it doesnt animate to-or-from the current %.

For example, if I click option 2a then click option 2b it resets first then goes to the %, and if I click 2b first then click 2a I'd expect the progress-bar to maybe go up by a small %.

You can see when you click option 2a then 1a, its good but its not compatible with multiple groups of radios.

So how can I get it to sum up % amounts rather then it going to-and-from set width amounts?

Also, How do I get the onclick events to work multiple times rather than just once per page refresh?

document.addEventListener('click', option_1_default);  function option_1_default() {    $(document).ready(function() {      $("#js1").click(function() {        $(".progress-value").addClass("progress-value-2a");      });    })  };    document.addEventListener('click', option_2_up);  function option_2_up() {    $(document).ready(function() {      $("#js2").click(function() {        $(".progress-value").addClass("progress-value-1a");      });    })  };          document.addEventListener('click', option_1b_default);  function option_1b_default() {    $(document).ready(function() {      $("#js3").click(function() {        $(".progress-value").addClass("progress-value-1b");      });    })  };    document.addEventListener('click', option_2b_up);  function option_2b_up() {    $(document).ready(function() {      $("#js4").click(function() {        $(".progress-value").addClass("progress-value-2b");      });    })  };
body{    padding:12px;  }    .col-6 label{    border:1px solid #333;  }  .col-6 input[type=radio]:checked + label{    border:2px solid blue;  }    .progress {    background: rgba(255,255,255,0.1);    justify-content: flex-start;    border-radius: 100px;    align-items: center;    position: relative;    display: flex;    height: 10px;    width: 100%;    margin-bottom:10px;  }    .progress-value {    animation: load_speed_default 2s normal forwards;    box-shadow: 0 10px 40px -10px #fff;    border-radius: 100px;    background: #0d6efd;    height: 30px;    width: 0;  }  @keyframes load_speed_default {    0%{width:0;}    100%{width:50%;}  }          .progress-value-1a {    animation: load_speed_1a 1s normal forwards;    box-shadow: 0 10px 40px -10px #fff;    border-radius: 100px;    background: #0d6efd;    height: 30px;    width: 0;  }  @keyframes load_speed_1a {    0%{      width:50%;      }    100%{      width:75%;    }  }    .progress-value-2a {    animation: load_speed_2a 1s normal forwards;    box-shadow: 0 10px 40px -10px #fff;    border-radius: 100px;    background: #0d6efd;    height: 30px;    width: 0;  }  @keyframes load_speed_2a {    0%{      width:75%;      }    100%{      width:50%;    }  }      .progress-value-1b {    animation: load_speed_1b 1s normal forwards;    box-shadow: 0 10px 40px -10px #fff;    border-radius: 100px;    background: #0d6efd;    height: 30px;    width: 0;  }  @keyframes load_speed_1b {    0%{      width:50%;      }    100%{      width:50%;    }  }    .progress-value-2b {    animation: load_speed_2b 1s normal forwards;    box-shadow: 0 10px 40px -10px #fff;    border-radius: 100px;    background: #0d6efd;    height: 30px;    width: 0;  }  @keyframes load_speed_2b {    0%{      width:50%;      }    100%{      width:90%;    }  }
<head>  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">   <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>  </head>    <body>        <div class="wrapp">    Speed    <div class="progress">      <div class="progress-value"></div>    </div>  </div>          <div class="row">  <label>Group 1</label>    <div class="col-6">      <input type="radio" style="display:none;" id="js1" data-price="146.99" value="option1a" name="ONE">      <label for="js1" onclick="option_1_default()">        Option 1a (Default 50%)      </label>    </div>    <div class="col-6">      <input type="radio" style="display:none;" id="js2" data-price="123.99" value="option2a" name="ONE">      <label for="js2" onclick="option_2_up()">        Option 2a (75%)      </label>    </div>        <hr style="margin-top:24px;">        <label>Group 2</label>        <div class="col-6">      <input type="radio" style="display:none;" id="js3" data-price="116.99" value="option1b" name="TWO">      <label for="js3" onclick="option_1b_default()">        Option 1b (Default 50%, but if option 2a selected then stay 75%)      </label>    </div>    <div class="col-6">      <input type="radio" style="display:none;" id="js4" data-price="93.99" value="option2b" name="TWO">      <label for="js4" onclick="option_2b_up()">        Option 2b (Should increase from group 1 selection)      </label>    </div>  </div>  </body>

Entity Framework : how to add counter variable to its results

Posted: 27 Jun 2022 08:02 AM PDT

I have an EF query as shown here. I would need to get the list (x variable) with its counter (sequence), 1, 2, 3, 4, 5, as another column

How do I achieve it?

List<ERP_Table> x = db.ERP_Table                        .Where(e => e.INo == currINo)                        .DefaultIfEmpty()                        .ToList();  

Dealing with bloomberg Blpapi element that returns HasElement() as True but causes not found exception

Posted: 27 Jun 2022 08:01 AM PDT

I am consuming trade and quote data with BLPAPI in C#. When I process a LAST_TRADE_PRICE_TIME_TODAY_RT like this using //blp/mktdata service and processing the SUBCRIPTION_DATA event fine except for this message element:

{MarketDataEvents = {      RT_TIME_OF_TRADE = 2022-06-23      INDICATIVE_NEAR =       IMBALANCE_BUY =       IMBALANCE_SELL =       ORDER_IMB_BUY_VOLUME =       ORDER_IMB_SELL_VOLUME =       THEO_PRICE =       IMBALANCE_INDIC_RT =       PREV_CLOSE_VALUE_REALTIME = 11737.5      TRADING_DT_REALTIME = 2022-06-24      PREV_TRADING_DT_REALTIME = 2022-06-23      PX_ASK_LME_OFFICIAL_RT =       NUM_TRADES_RT = 0      PX_OFFICIAL_AUCTION_RT =       LAST_UPDATE_BID_RT = 2022-06-23      LAST_UPDATE_ASK_RT = 2022-06-23      OFFICIAL_AUCTION_VOLUME_RT =       IN_AUCTION_RT =       TURNOVER_TODAY_REALTIME =       OFFICIAL_OPEN_AUCTION_PRICE_RT =       OFFICIAL_OPEN_AUCTION_VOLUME_RT =       OFFICIAL_CLOSE_AUCTION_PRICE_RT =       OFFICIAL_CLOSE_AUCTION_VOLUME_RT =       AUCTION_EXTENSION_RT =       BLOCK_TRADE_ACCUM_VOLUME_RT =       TOTAL_MSG_SCRAPED_OFFERS_RT =       EVENT_TIME = 22:30:00.000      VOLUME_THEO =       OPEN_YLD_TDY_RT =       HIGH_YLD_TDY_RT =       LOW_YLD_TDY_RT =       LAST_YLD_TDY =       MID_TDY =       SIZE_LAST_TRADE_TDY =       RT_PX_CHG_NET_1D = 171.75      RT_PX_CHG_PCT_1D = 1.485      OPEN_TDY =       ASK_SIZE_TDY =       BID_SIZE_TDY =       VOLUME_TDY =       LAST_PRICE_TDY =       BID_TDY =       ASK_TDY =       HIGH_TDY =       LOW_TDY =       BID_YLD_TDY =       ASK_YLD_TDY =       TIME = 2022-06-23      LAST_UPDATE_ALL_SESSIONS_RT =       PX_OPEN_ALL_WITH_SWITCHOVER_RT =       BID_ALL_SESSION_TDY_RT =       ASK_ALL_SESSION_TDY_RT =       CONTINUOUS_TRAD_CLOS_BID_PX_RT =       CONTINUOUS_TRAD_CLOS_ASK_PX_RT =       POST_CLOSING_AUCTION_BID_PX_RT =       POST_CLOSING_AUCTION_ASK_PX_RT =       LAST_TRADE_RECEIVED_TIME_RT =       PRICE_CHANGE_ON_DAY_RT = 171.75      PRICE_LAST_ASK_RT =       PRICE_LAST_BID_RT =       PRICE_HIGH_RT =       PRICE_LOW_RT =       PRICE_OPEN_RT =       LAST_TRADE_PRICE_TODAY_RT =       PREVIOUS_TOTAL_VOLUME_RT = 622197      PREVIOUS_CLOSE_ADJ_BY_GR_DVD_RT =       TIME_AUCTION_CALL_CONCLUSION_RT =       PER_TRADE_VWAP_REALTIME =       PER_TRADE_VWAP_TURNOVER_RT =       PER_TRADE_VWAP_VOLUME_RT =       OPEN_HIGH_PRICE_REALTIME =       OPEN_LOW_PRICE_REALTIME =       CLOSE_HIGH_PRICE_REALTIME =       CLOSE_LOW_PRICE_REALTIME =       EXCHANGE_FOR_PHYSICAL_VOLUME_RT =       EXCHANGE_FOR_SWAP_VOLUME_RT =       LAST_BID_TIME_TODAY_REALTIME =       LAST_ASK_TIME_TODAY_REALTIME =       LAST_MID_TIME_TODAY_REALTIME =       LAST_PRICE_TIME_TODAY_REALTIME =       LAST_TRADE_PRICE_TIME_TODAY_RT =       MINIMUM_ORDER_LIMIT_PRICE_RT =       MAXIMUM_ORDER_LIMIT_PRICE_RT =       MIN_DYNAMIC_TRADING_LIMIT_PX_RT =       MAX_DYNAMIC_TRADING_LIMIT_PX_RT =       15_SECOND_PRICE_CHANGE_RT =       1_MINUTE_PRICE_CHANGE_RT =       5_MINUTE_PRICE_CHANGE_RT =       15_MINUTE_PRICE_CHANGE_RT =       1_HOUR_PRICE_CHANGE_RT =       CIRCUIT_BREAKER_TRIG_SIGNAL_RT =       LAST_CONTINUOUS_TRADE_PRICE_RT =       DYNAMIC_TRADING_LIMITS_REF_PX_RT =       LAST_OFF_BOOK_TRADE_PRICE_RT =       CB_TRIGGER_SIGNAL_START_TIME_RT =       CB_TRIGGER_SIGNAL_END_TIME_RT =       EFFECTIVE_DATE_RT =       OPEN_TRADE_PRICE_TODAY_RT =       HIGH_TRADE_PRICE_TODAY_RT =       LOW_TRADE_PRICE_TODAY_RT =       EXCHANGE_FOR_RISK_VOLUME_RT =       BLOOMBERG_CLOSE_PRICE_TODAY_RT =       PRICE_CLOSE_CC_TODAY_RT =       SUB_SEC_TM_AUCT_CALL_CNCLSN_RT =       THEORETICAL_TIME_TODAY_RT =       ON_EXCHANGE_VOLUME_TODAY_RT =       ON_BOOK_VOLUME_TODAY_RT =       LIT_BOOK_VOLUME_TODAY_RT =       CONTINUOUS_VOLUME_TODAY_RT =       AUCTION_VOLUME_TODAY_RT =       SCHEDULED_AUCT_VOLUME_TODAY_RT =       OPENING_AUCTION_VOLUME_RT =       CLOSING_AUCTION_VOLUME_RT =       INTRADAY_AUCTION_VOLUME_TODAY_RT =       UNSCHEDULED_AUCT_VOLUME_TODAY_RT =       TRADE_LAST_CLOSE_VOLUME_TODAY_RT =       PRE_POST_AUTO_EXECTN_VOL_TDY_RT =       DARK_BOOK_VOLUME_TODAY_RT =       ON_BK_NEG_BTF_OR_CC_VOL_TDY_RT =       ODD_LOT_BOOK_VOLUME_TODAY_RT =       OFF_BOOK_VOLUME_TODAY_RT =       NEGOTIATED_VOLUME_TODAY_RT =       OFF_BK_BLOCK_OR_CC_VOLUME_TDY_RT =       OFF_BOOK_ODD_LOT_VOLUME_TODAY_RT =       OTC_VOLUME_TODAY_RT =       SYSTEMATIC_INTERNAL_VOL_TDY_RT =       REPORTED_DARK_VOLUME_TODAY_RT =       PERCENT_CHANGE_ON_DAY_TODAY_RT =       NET_CHANGE_ON_DAY_TODAY_RT =       LAST_TRADE_AM_SESSION_TODAY_RT =       OPEN_PRICE_AM_SESSION_TODAY_RT =       HIGH_PRICE_AM_SESSION_TODAY_RT =       LOW_PRICE_AM_SESSION_TODAY_RT =       VOLUME_AM_SESSION_TODAY_RT =       LAST_TRADE_PM_SESSION_TODAY_RT =       OPEN_PRICE_PM_SESSION_TODAY_RT =       HIGH_PRICE_PM_SESSION_TODAY_RT =       LOW_PRICE_PM_SESSION_TODAY_RT =       VOLUME_PM_SESSION_TODAY_RT =       EXCHANGE_VWAP_TODAY_RT =       SETTLEMENT_PRESENT_VALUE_RT =       MATURITY_CALIBRATION_RATE_RT =       MATURITY_CALIBRATION_PV_RT =       CONTRIBUTED_RECOVERY_RATE_RT =       PAR_SPREAD_BID_RT =       PAR_SPREAD_ASK_RT =       LIQUIDITY_INDICATOR_RT =       PRICE_BID_CLOSE_TODAY_RT =       PRICE_ASK_CLOSE_TODAY_RT =       OFFICIAL_CLOSE_TODAY_RT =       PREVIOUS_BLOOMBERG_CLOSE_PX_RT = 11737.5      PREVIOUS_LAST_TRADE_PRICE_RT = 11688      BLOOMBERG_SEND_TIME_RT = 2022-06-23T21:31:23.469+00:00      10_MINUTE_PRICE_CHANGE_RT =       30_MINUTE_PRICE_CHANGE_RT =       BLOOMBERG_CLOSE_PX_AM_TODAY_RT =       PERIODIC_AUCT_ON_DMD_VOL_TDY_RT =       PERIODIC_AUCT_ON_DMD_THEO_PX_RT =       CHG_NET_REG_SES_PRV_RG_SES_CL_RT =       CHG_PCT_REG_SES_PRV_RG_SES_CL_RT =       ACTUAL_TRADED_PRICE_RT =       MIN_DYNMC_BID_ORDR_LIMT_PX_RT =       MAXMM_DYNMC_BID_ORDR_LIMT_PX_RT =       MIN_DYNMC_ASK_ORDR_LIMT_PX_RT =       MAXMM_DYNMC_ASK_ORDR_LIMT_PX_RT =       MKTDATA_EVENT_TYPE = SUMMARY      MKTDATA_EVENT_SUBTYPE = NEWDAY      DELTA_AVAT_30_DAY_INTERVAL =       DELTA_AVAT_1_DAY_INTERVAL =       DELTA_AVAT_5_DAY_INTERVAL =       DELTA_AVAT_10_DAY_INTERVAL =       DELTA_AVAT_20_DAY_INTERVAL =       DELTA_AVAT_100_DAY_INTERVAL =       DELTA_AVAT_180_DAY_INTERVAL =       DELTA_ATAT_1_DAY_INTERVAL =       DELTA_ATAT_5_DAY_INTERVAL =       DELTA_ATAT_10_DAY_INTERVAL =       DELTA_ATAT_20_DAY_INTERVAL =       DELTA_ATAT_30_DAY_INTERVAL =       DELTA_ATAT_100_DAY_INTERVAL =       DELTA_ATAT_180_DAY_INTERVAL =       REALTIME_15_SEC_PRICE_PCT_CHG =       REALTIME_ONE_MIN_PRICE_PCT_CHG =       REALTIME_FIVE_MIN_PRICE_PCT_CHG =       REALTIME_15_MIN_PRICE_PCT_CHG =       REALTIME_ONE_HOUR_PRICE_PCT_CHG =       REALTIME_VOLUME_5_DAY_INTERVAL =       CURRENT_SESSION_RT = 4      IMPLIED_BID_PRICE_RT =       IMPLIED_ASK_PRICE_RT =       IMPLIED_BID_SIZE_RT =       IMPLIED_ASK_SIZE_RT =       IS_DELAYED_STREAM = false  }  }  

I use this to check the datetime and emit a trade event:

                    if (message.HasElement(LAST_TIME))                      {                          if (message.GetElementAsDatetime(LAST_TIME).IsValid())                          {                              DateTime time = message.GetElementAsDatetime(LAST_TIME).ToSystemDateTime();                                if (message.HasElement(LAST) && message.HasElement(SIZE))                              {                                  double last = message.GetElementAsFloat64(LAST);                                  int last_size = message.GetElementAsInt32(SIZE);                                  long volume = message.GetElementAsInt64(VOLUME); ...  

I receive:

'Bloomberglp.Blpapi.NotFoundException: LAST_TRADE_PRICE_TIME_TODAY_RT has no value in MarketDataUpdate.'

I have tried converting to string first and checking if empty and checking null. Any ideas would be helpful...

Create Normal users and Prenium users and constrain access firebase data with this groups in ionic application

Posted: 27 Jun 2022 08:02 AM PDT

I'm developing an app with Firebase and ionic, I would like to restrict access to posts in the app with the role of a user (Premium or Normal)

Example of my data in Firebase :

{"post1" : {"text": "hi all users", "access":["normal", "premium"]},  "post2": {"text": "hi premium users", "access":["premium"]}  

How can I do it with real time dataset Firebase and ionic (Javascript)? What is the most secure way?

How To Convert Spring Boot Entity to Angular Object

Posted: 27 Jun 2022 08:01 AM PDT

I'm trying to use Angular and Spring Boot to show a list of Rule objects. I am not using a JPA Repository to respond to the GET request, so I think I have to 'manually' convert my list of Rule objects on the Spring Boot side to a JSON so that httpClient.get<Rule[]>() can convert it to a list of Rule objects on the Angular side. However, this is currently not working, and my rule objects are not showing up on my webapp.

I'm not using a repository because I'm querying the database on the Spring Boot side, and doing some business logic to only display rules that fall under a certain criteria, and adding some information about the rules that is not in the database.

How do I correctly convert the list of rules to a JSON? Is this even the right approach?

Thank you!

Rule.java:

@Entity  @Table(name = "MSG_DOM")   public class Rule implements Serializable{      private static final long serialVersionUID = 1L;      private String fireType;      private boolean multipleDrivers;        @Id      @Column(name = "MSG_CD", unique = true, nullable = false)          private String messageCode;        @Column(name = "MSG_TYP_CD", unique = false, nullable = false)          private String messageTypeCode;        @Column(name = "BUS_RUL_CD", unique = false, nullable = false)          private String busRuleCode;        @Column(name = "MSG_EXTR_USER_TXT", unique = false, nullable = false)          private String externalMessageText;        @Column(name = "MSG_INTRL_USER_TXT", unique = false, nullable = false)          private String internalMessageText;        public Rule(){}        public String getMessageCode(){          return messageCode;      }            public void setMessageCode(String messageCode){          this.messageCode = messageCode;      }        ...  

RuleController.java:

@RestController  @RequestMapping("/api/v1")  public class RuleController {        //get all rules      @CrossOrigin(origins = "http://localhost:4200")      @RequestMapping(value = "/rules", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE})      @ResponseBody      public Rule[] getAllRules() {          RuleListService ruleListService = new RuleListService();          List<Rule> ruleList = ruleListService.listRules();          Rule[] rules = new Rule[ruleList.size()];          for (int i = 0; i < ruleList.size(); ++i) rules[i] = ruleList.get(i);          return rules;      }  }  

RuleListService.java:

public class RuleListService {        ApplicationContext context =  new AnnotationConfigApplicationContext(BeanConfig.class);            public List<Rule> listRules() {          RuleList lister = context.getBean(RuleList.class);          ArrayList<HashMap<String, Rule>> ruleMaps = lister.loadRuleMap();          ArrayList<Rule> ruleList = new ArrayList<Rule>();          for(HashMap<String, Rule> ruleMap: ruleMaps) {               ruleList.addAll(ruleMap.values());          }          return ruleList;      }    }  

rule.ts:

export class Rule {        constructor(                  private _serialVersionUID : number,                  private _fireType: string,                  private _multipleDrivers: boolean,                  private _messageCode: string,                  private _messageTypeCode: string,                  private _busRuleCode: string,                  private _externalMessageText: string,                  private _internalMessageText: string,) {                  }        getSerialVersionUID() : number {          return this._serialVersionUID;      }        setSerialVersionUID(value: number) {          this._serialVersionUID = value;      }        ...  

rule.service.ts:

@Injectable({    providedIn: 'root'  })  export class RuleService {    private baseUrl = "http://localhost:8080/api/v1/rules"        constructor(private httpClient: HttpClient) {}      getRuleList(): Observable<Rule[]> {      return this.httpClient.get<Rule[]>(`${this.baseUrl}`).pipe(          catchError(this.handleError)      );    }      private handleError = (error: Response) => {      if (error.status === 400) {        return throwError(() => new Error("Bad Input"));      }      if (error.status === 404) {        return throwError(() => new Error("Not Found"));      }        return throwError(() => new Error("App Error"));    }  }  

rule-list.component.ts:

export class RuleListComponent implements OnInit {      rules: Rule[];    ruleTest: Rule;      constructor(private ruleService: RuleService) { }      ngOnInit(): void {      this.getRules();    }      private getRules() {      this.ruleService.getRuleList().pipe(          map((actions: Rule[]) =>            actions.map(action => { return action as Rule;} )        )).subscribe(rules => this.rules = rules);    }  }  

rule-list.component.html:

<h2> Rule List </h2>  <table class = "table table-striped">      <thead>          <tr>              <th> MSG_CD </th>              <th> MSG_TYP_CD </th>              <th> BUS_RUL_CD </th>              <th> MSG_EXTR_USER_TXT </th>              <th> MSG_INTRL_USER_TXT </th>              <th> Fire Type </th>              <th> Multiple Drivers </th>           </tr>      </thead>      <tbody>          <tr *ngFor = "let rule of rules" >              <td> {{rule.getMessageCode()}} </td>              <td> {{rule.getMessageTypeCode()}} </td>              <td> {{rule.getBusRuleCode()}} </td>              <td> {{rule.getExternalMessageText()}}</td>              <td> {{rule.getInternalMessageText()}} </td>              <td> {{rule.getFireType()}} </td>              <td> {{rule.getMultipleDrivers()}} </td>          </tr>      </tbody>  </table>  

UPDATE: I'm still not seeing the data in the table, and have gotten this error from the dev console on my browser:

ERROR TypeError: rule_r1.getMessageCode is not a function      at RuleListComponent_tr_20_Template (rule-list.component.html:16:18)  

I tried changing the variables to public in the Rule.ts constructor, and accessing the variables directly instead of calling get() methods like so, {{rule._messageCode}}, for all table fields, and while it (obviously) got rid of the error, I still did not see data in the table.

The table has been populated with rows indicating there is actually a Rule[] being sent and received correctly, but there is no data in any row.

I've also updated all included code, since many changes have been made.

Table Screenshot

Visual Studio Project migration to Android Studio with Gradle

Posted: 27 Jun 2022 08:02 AM PDT

I'm not an android developer, but I have little experience with andoid. :)

Th Problem
Playstore now requires .adb file type to be used for submission

  • Apparently I've discovered that the only way to generate a bundle is by converting my project into an android studio project with gradle or through command line with build tool.

So I tried the buildtool first, but I had a hardtime with last part which was zipping your source code in different parts using apt2, this would've been the last part and I wouldve been able to generate a .adb file already. But the tool is for windows only. I tried the import Profile / Debug apk aswell to archive it into .adb but I ranto a gradle issue this time. To make story short, Is there a way I can properly import and migrate my visual studio project into android that would totally work this time?

I need to import a visual Studio Project (w/o) gradle into a Gradle Visual Studio project type so I can archive a bundle .adb file.

THe project structure is like this (Client Just bought this template app)

MyApp_V2.6.1 [Folder]    API [Folder]      SomeDLLFiles.dll      SomeOtherDLLFiles.dll    MyApp [Folder]      properties[Folder]        AndroidManifest.xml       The Rest of the folders      MyApp.cs      etc.  

How to define the order of next/head elements in Nextjs

Posted: 27 Jun 2022 08:01 AM PDT

For CSS in my nextjs project I am using styled-jsx (https://github.com/vercel/styled-jsx).

All styled JSX tags (<style jsx>) will be appended at the end of the HTML <head> element.

However I have another native (non styled-jsx) HTML <style> tag that contains several CSS overrides. If I place my <style> tag in the nextjs <Head> component it will be placed in the HTML <head> element but above the other styled-jsx style tags. This will cause that the other styled-jsx <style jsx> tags will override my styles defined in my normal <style> tag. I want to achieve the other way around.

  import Head from 'next/head';    <Head>      <style dangerouslySetInnerHTML={{ __html: props.css }} />    </Head>  

I already tried to put my style tag outside of the <head> element but this is no option for me right now.

How can I put my native HTML <style> tag at the end of the HTML <head> element so other styles will be overridden?

How to Create a Free iOS Development Provisioning Profile [closed]

Posted: 27 Jun 2022 08:02 AM PDT

I'm developing an app for learning purpose. Recently got to now that i can test the app in device without paying $99. I R&D on this but couldn't get succeed.Please, let me know if any way. Thanks.

No comments:

Post a Comment