Wednesday, September 8, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Xamarin: Sizing Issues when dynamically adding rows to a Grid

Posted: 08 Sep 2021 09:31 AM PDT

I am new to Xamarin and I'm trying to figure out some of the basic functionality.

I have a simple content page containing a ScrollView with a nested StackLayout, then other nested controls within the StackLayout:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"           x:Class="TestApp.Views.ScrollGrow">      <ScrollView x:Name="myScrollView" BackgroundColor="LightBlue" VerticalOptions="FillAndExpand">      <StackLayout x:Name="MainStack" BackgroundColor="YellowGreen" VerticalOptions="FillAndExpand">          <Label Text="Start of StackLayout"></Label>          <Button Text="Populate Grid" Clicked="Button_Clicked" x:Name="btnFill" BackgroundColor="Black" TextColor="White"></Button>          <Grid x:Name="myGrid" BackgroundColor="Yellow" VerticalOptions="FillAndExpand"></Grid>          <Label Text="Bottom of StackLayout"></Label>      </StackLayout>    </ScrollView>    </ContentPage>  

I am attempting to dynamically add rows to the Grid on a button click:

using System;  using Xamarin.Forms;  using Xamarin.Forms.Xaml;    namespace TestApp.Views  {      [XamlCompilation(XamlCompilationOptions.Compile)]  public partial class ScrollGrow : ContentPage  {        public ScrollGrow()      {          InitializeComponent();      }        private void Button_Clicked(object sender, EventArgs e)      {          Device.BeginInvokeOnMainThread(() =>          {              for (int i = 0; i <= 35; i++)              {                  FillMyGrid(i);              }                         });      }        private void FillMyGrid(int theCounter)      {          myGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto, });          var testLabel = new Label();          testLabel.Text = "Test row number: " + theCounter;          testLabel.TextColor = Color.Black;          Grid.SetRow(testLabel, theCounter);          Grid.SetColumn(testLabel, 0);          myGrid.Children.Add(testLabel);      }      }  }  

Unfortunately, the size of the StackLayout doesn't appear grow when the Grid grows. Before Example: https://i.imgur.com/3Ydfchc.jpg After Example: https://i.imgur.com/Y89IDRe.jpg

What am I missing here? Can someone explain to me why this isn't working and what the correct way to do this would be?

Thanks!

Arthur

How to access api-platform from a remote web browser?

Posted: 08 Sep 2021 09:31 AM PDT

I wish to install api-platform using the recommended API Platform Distribution, and access it via a remote web browser. Other services on the server are already using ports 80, 443, and 5432, and will need to continue using them. The project is still in development and not production and the options described under Deployment do not seem appropriate. How is this accomplished?

Steps I've taken I've implemented the following and it mostly works, however, has two shortcomings as described at the bottom of this post, and I am evidently doing something wrong:

  1. Clone and install api-platform.
git clone https://github.com/NotionCommotion/api-platform.git  cd api-platform  docker-compose build --pull --no-cache  cp api/.env.test api/.env.local  
  1. Edit app/.env.local to change example\.com to mysitename.com (for unknown reasons, I needed to remove the backslash)
  2. Edit docker-compose.yml to change caddy.ports.published for HTTP, HTTPS, and HTTP/3 from 80, 443, and 443 to 8080, 8443, and 8443 respectively.
  3. Edit docker-compose.override.yml to change database.ports.published from 5432 to 5433.
  4. Add a new file .env which only contains SERVER_NAME=mysitename.com. Note that for reasons unbeknownst to me, this must be performed after executing docker-compose build --pull --no-cache.
  5. Add /etc/httpd/conf.d/mysitename.com-le-ssl.conf in order to create a virtual host to redirect to the docker's caddy web server (which uses self-signed certificates) and restart httpd.
<IfModule mod_ssl.c>  <VirtualHost *:443>      ServerName mysitename.com      ProxyPreserveHost On      ProxyRequests Off      SSLProxyEngine On      SSLProxyVerify none      SSLProxyCheckPeerCN Off      SSLProxyCheckPeerExpire Off      SSLProxyCheckPeerName Off      ProxyPass / https://127.0.0.1:8443/      ProxyPassReverse / https://127.0.0.1:8443/      ErrorLog /var/log/httpd/mysitename.com-error.log      CustomLog /var/log/httpd/mysitename.com-access.log combined      Include /etc/letsencrypt/options-ssl-apache.conf      SSLCertificateFile /etc/letsencrypt/live/mysitename.com/fullchain.pem      SSLCertificateKeyFile /etc/letsencrypt/live/mysitename.com/privkey.pem  </VirtualHost>  </IfModule>  
  1. Execute docker-compose up -d

I am able to access it remotely as https://mysitename.com, however, have the following two shortcomings (and potentially to be discovered more):

  1. While POST/PUT/DELETE/PATCH requests update the database, a 500 Mercure Failed to send an update error is returned. GET requests work without error.
  2. Upon attempting to access it on the local machine using https:\localhost, I get a proxy error, and Docker's logs show nothing but Apache's logs provides the following. While this is not a showstopper, I would like to know how to discover more details about the error.
[Wed Sep 08 09:21:24.243297 2021] [proxy_http:error] [pid 770511:tid 140649290520320] (103)Software caused connection abort: [client ::1:32774] AH01102: error reading status line from remote server 127.0.0.1:8443, referer: https://localhost/  [Wed Sep 08 09:21:24.243336 2021] [proxy:error] [pid 770511:tid 140649290520320] [client ::1:32774] AH00898: Error reading from remote server returned by /docs, referer: https://localhost/  

Modify background color of mark_text()

Posted: 08 Sep 2021 09:31 AM PDT

I am using Altair to display a choropleth map. When trying to add labels to the map using mark_text(), I am unable to change the background color of these text boxes. I am following the code example on the London Tube Lines listed on the Altair website:

In principle, setting a background color for a text box should be possible in Vega Lite, as shown here.

Grateful for any hint.

valueerror invalid model reference, how can i reference correctly

Posted: 08 Sep 2021 09:31 AM PDT

I had to change a number of my ManyToMany relations to reference a string instead of importing the model into the file so to avoid a number of circular importing errors.

but when trying to run, now I am getting this error.

ValueError: Invalid model reference 'dsi.administration.libraries.Library'. String model references must be of the form 'app_label.ModelName'.  

I don't know what would be the best way to reference this and I'd love to get anyone's input on this.

the reference in question

    models.ManyToManyField("dsi.administration.libraries.Library", verbose_name='library choices')    

settings.py installed modules

SHARED_APPS = (      "storages",      "django_tenants",  # mandatory      'dsi.events.event',      'dsi.administration.libraries',      'dsi.account'  )  

the app folder structure

├── dsi  │   ├── account  │   │   ├──__init__.py  │   │   ├── models.py  │   ├── events  │   │   ├── event  |   │   │   ├── __init__.py  |   │   │   ├── models.py  │   │   ├──__init__.py  │   ├── administration  │   │   ├── libraries  |   │   │   ├── __init__.py  |   │   │   ├── models.py  │   │   ├── general  |   │   │   ├── __init__.py  |   │   │   ├── models.py  │   │   ├── __init__.py  │   ├── __init__.py  │   ├── urls.py  │   └── settings.py  ├── manage.py  

Headless Chromium support for wide-gamut colours in css

Posted: 08 Sep 2021 09:30 AM PDT

I am maintaining a simple application that is using puppeteer with headless Chromium to take screenshots. One of requirements is that we take a screenshot with background color with wider color gamut than sRGB.

We managed to run headless chromium instance with forced color profile display-p3-d65, but there seems to be no way to actually declare color in css outside of standard sRGB gamut (e.g. color() is supported by WebKit (and Safari), but not by Chromium and Chrome).

Is there a way to actually declare colours in css with wide gamut and render it in chromium?

Vertical lines in 3D Scatter Plot in plotly.js

Posted: 08 Sep 2021 09:30 AM PDT

I am trying to figure out a way to create separate vertical lines with a 3d scatter plot in plotly.js. Currently, the only way I have been able to get the desired effect is to create a separate trace for each line. This works great for a few traces, but sometimes I will need to have 1000+ lines.

Relevant codepen: https://codepen.io/brga16/pen/QWgdZGJ

var traces = [];    for (var x = 0; x < 5; ++x) {    for (var y = 0; y < 5; ++y) {      traces.push({        type: 'scatter3d',        mode: 'lines',        x: [x, x],        y: [y, y],        z: [0, Math.random() - 0.5],        opacity: 1,        line: { width: 6 },      });    }  }  

Another possibility is toggling on/off the color transparency to keep all the lines in one trace (and have the connecting lines be transparent), but I wasn't able to find a way to immediately turn the alpha layer on/off to achieve the desired effect. Here's another codepen with an attempt to do that: https://codepen.io/cbuq/pen/rNwjrym

Any suggestions on achieving a similar effect that will scale well? Thanks!

Drawing A Rotated Path2D Object on canvas

Posted: 08 Sep 2021 09:30 AM PDT

I have a canvas where i want to draw a rotated svg.

In order to achieve this, i created a Path2D object and used the context.fill() option to draw the svg.

Moreover, I used context.translate(x , y) inorder to position the svg.

Now, the issue i how to rotate this?

I found some solutions where it stated that first use context.translate(x , y) to set the transformation point and then use context.rotate(deg) to rotate.

Now, both the translate are in conflict.

Here is the code that I have tried so far. This code rotates the svg element. But from its top right corner. I want it to be rotated from center:

Codepen link - https://codepen.io/asiancat54x/pen/jOwyeaR

Here is the code snippet

<!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>Document</title>  </head>  <body>      <canvas></canvas>        <script>          const canvas = document.querySelector("canvas")            const ctx = canvas.getContext("2d")            const path = new Path2D()            path.addPath(new Path2D('M 25.214844 0.0664062 C 23.191406 0.332031 20.324219 1.554688 17.460938 3.378906 C 15.777344 4.441406 14.132812 5.679688 12.535156 7.082031 C 11.585938 7.917969 11.566406 7.929688 11.273438 7.929688 C 11.140625 7.929688 10.589844 7.824219 10.046875 7.691406 C 9.230469 7.492188 8.996094 7.457031 8.628906 7.472656 C 7.753906 7.519531 7.9375 7.367188 3.777344 11.53125 C 1.277344 14.035156 0.0546875 15.300781 0.0273438 15.402344 C -0.0351562 15.664062 0.0429688 15.851562 0.253906 15.941406 C 0.351562 15.988281 1.636719 16.222656 3.089844 16.445312 C 6.042969 16.90625 6.269531 16.917969 6.859375 16.648438 C 7.042969 16.5625 7.28125 16.429688 7.378906 16.355469 C 7.484375 16.273438 7.632812 16.207031 7.707031 16.207031 C 7.808594 16.207031 8.582031 16.949219 10.773438 19.140625 C 12.378906 20.75 13.703125 22.113281 13.703125 22.164062 C 13.703125 22.21875 13.636719 22.335938 13.5625 22.429688 C 13.34375 22.683594 13.132812 23.152344 13.054688 23.542969 C 12.984375 23.886719 12.996094 24.015625 13.402344 26.621094 C 13.636719 28.113281 13.851562 29.421875 13.878906 29.535156 C 13.945312 29.761719 14.082031 29.851562 14.355469 29.851562 C 14.527344 29.851562 14.851562 29.539062 18.292969 26.097656 C 21.648438 22.761719 22.066406 22.324219 22.210938 22.007812 C 22.496094 21.398438 22.492188 21.167969 22.183594 19.863281 C 22.027344 19.191406 21.925781 18.660156 21.949219 18.589844 C 21.972656 18.519531 22.285156 18.136719 22.644531 17.726562 C 26.28125 13.621094 28.867188 9.066406 29.644531 5.394531 C 29.792969 4.734375 29.808594 4.5 29.8125 3.613281 C 29.8125 2.660156 29.808594 2.5625 29.660156 2.117188 C 29.285156 1.003906 28.535156 0.320312 27.402344 0.0820312 C 26.996094 -0.0078125 25.792969 -0.0195312 25.214844 0.0664062 Z M 23.464844 4.5625 C 25.449219 5.203125 26.210938 7.632812 24.957031 9.285156 C 24.0625 10.472656 22.503906 10.855469 21.179688 10.199219 C 20.101562 9.675781 19.472656 8.65625 19.472656 7.460938 C 19.472656 6.601562 19.753906 5.910156 20.371094 5.304688 C 21.183594 4.488281 22.367188 4.203125 23.464844 4.5625 Z M 23.464844 4.5625'))            path.addPath(new Path2D("M 6.871094 18.929688 C 5.667969 20.199219 4.289062 22.570312 3.445312 24.839844 C 3.039062 25.953125 2.84375 27.003906 3.027344 27.183594 C 3.113281 27.273438 3.285156 27.210938 4.402344 26.683594 C 4.914062 26.441406 5.910156 26.019531 6.613281 25.746094 C 8.675781 24.933594 9.160156 24.6875 9.96875 24.0625 C 10.480469 23.65625 11.269531 22.910156 11.328125 22.777344 C 11.351562 22.714844 11.335938 22.589844 11.28125 22.480469 C 11.226562 22.378906 10.375 21.472656 9.371094 20.476562 C 7.671875 18.792969 7.527344 18.65625 7.339844 18.65625 C 7.175781 18.65625 7.089844 18.707031 6.871094 18.929688 Z M 6.871094 18.929688 "))            var rotation = 0            canvas.width = innerWidth            canvas.height = innerHeight            const animate = () => {              requestAnimationFrame(animate)                ctx.fillStyle = "rgba(0 , 0 , 0 , 0.1)"                ctx.fillRect(0 , 0 , canvas.width , canvas.height)                ctx.fillStyle = "white"                ctx.translate(70 , 70)                ctx.rotate(rotation)                rotation += 0.1                ctx.fill(path)                ctx.resetTransform()          }            animate()          </script>  </body>  </html>

C++ unordered_map weird size allocation

Posted: 08 Sep 2021 09:31 AM PDT

I am experimenting with this code with a lockfree programming and running into weird problems.

This is a dinning philosophers problem, and I am trying to implement that in a lockfree way.

I am reserving the size of unordered_map and making sure that it is not relocating objs during runtime. But unfortunately what I see that during runtime size of Philosopher::umap is weirdly assigned, (in example below, I am restricting it to 10, but during runtime it is changing to 30-40). Can someone help me understand what is going on here.

#include <iostream>  #include <thread>  #include <string>  #include <vector>  #include <memory>  #include <atomic>  #include <chrono>  #include <tuple>  #include <unordered_map>    class Eater {  public:      virtual void Eating() = 0;      ~Eater() {        }  };    class Dreamer {  public:      virtual void Dreaming() = 0;      ~Dreamer() {}  };    class Gamer {  public:      virtual void Gaming() = 0;      ~Gamer() {                }  };    class Philosopher : public Dreamer, public Eater {  private:      const uint32_t id_;  public:      static std::atomic<uint32_t> gen;      static std::unordered_map<uint32_t, std::tuple<uint32_t, uint32_t>> umap;        Philosopher()          : id_(++gen) {              umap.emplace(id_, std::make_tuple(0,0));      }        Philosopher(const Philosopher& that) : id_(that.id_) {      }        Philosopher(Philosopher&& that) : id_(that.id_) {      }        virtual void Eating() override {          umap[id_] = std::make_tuple(1+std::get<0>(umap[id_]), std::get<1>(umap[id_])); // this is failing - despite, seperate thread working on separate memory location      }        virtual void Dreaming() override {          umap[id_] = std::make_tuple(std::get<0>(umap.at(id_)), 1+std::get<1>(umap.at(id_))); // this is failing - despite, seperate thread working on separate memory location      }        ~Philosopher() {      }  };  std::unordered_map<uint32_t, std::tuple<uint32_t, uint32_t>> Philosopher::umap;  std::atomic<uint32_t> Philosopher::gen(0u);    class Engine : public Gamer {  private:      uint32_t m_count_philosophers_;      std::vector<std::shared_ptr<std::thread>> m_vthread_;  public:      Engine(uint32_t n)          : m_count_philosophers_(n) {              m_vthread_.reserve(n);      }      virtual void Gaming() override {          std::atomic<uint32_t> counter(0u);          while(counter++ < m_count_philosophers_) {              m_vthread_.emplace_back(std::make_shared<std::thread>([&]() mutable {                                      Philosopher philosopher;                                      std::chrono::duration<double> elapsed_seconds;                                      auto start = std::chrono::steady_clock::now();                                      while(elapsed_seconds.count() < 2) {                                          philosopher.Eating();                                          philosopher.Dreaming();                                          auto finish = std::chrono::steady_clock::now();                                          elapsed_seconds = finish - start;                                      }                                   }));          }            for(auto &iter : m_vthread_) {              iter->join();          }      }  };    int main() {        auto N = 10u;        Philosopher::umap.reserve(N); // there are no more than N elements in the unordered_map      Engine eng(N);      eng.Gaming();        for (auto &i : Philosopher::umap)      {          std::cout << "phi: " << i.first << " eating: " << std::get<0>(i.second) << ", dreaming: " << std::get<1>(i.second) << "\n";      }        return 0;  }  

Having a connection issue with Jupyter Notebook. Feeling hopeless at this point since nothing's working

Posted: 08 Sep 2021 09:30 AM PDT

Image of an error message I see when I start up the notebook: connection error

These are the three error messages I'm getting in my console. Any help will be greatly greatly appreciated.

1: 'main.min.js?v=7af39fe9ec3585e958e8637ace5e96fe0bf3ced51a8b8b5875c571f941299779fe746bf74f02bab0f3c6e08281d6ecadafcb5b08120e98f081c9c7dd824bdfdc:37971 WebSocket connection to 'ws://localhost:8888/api/kernels/5a8140ac-685e-4174-a5bd-ac19c41dc01e/channels?session_id=7f9e44450ab44258871538c45cf75462' failed: '

2: 'DevTools failed to load source map: Could not load content for http://localhost:8888/static/notebook/js/main.min.js.map: Connection error: net::ERR_CONNECTION_REFUSED'

3: 'main.min.js?v=7af39fe9ec3585e958e8637ace5e96fe0bf3ced51a8b8b5875c571f941299779fe746bf74f02bab0f3c6e08281d6ecadafcb5b08120e98f081c9c7dd824bdfdc:24909 Uncaught (in promise) XhrError: error at wrap_ajax_error (main.min.js?v=7af39fe9ec3585e958e8637ace5e96fe0bf3ced51a8b8b5875c571f941299779fe746bf74f02bab0f3c6e08281d6ecadafcb5b08120e98f081c9c7dd824bdfdc:24909) at Object.settings.error (main.min.js?v=7af39fe9ec3585e958e8637ace5e96fe0bf3ced51a8b8b5875c571f941299779fe746bf74f02bab0f3c6e08281d6ecadafcb5b08120e98f081c9c7dd824bdfdc:24965) at c (main.min.js?v=7af39fe9ec3585e958e8637ace5e96fe0bf3ced51a8b8b5875c571f941299779fe746bf74f02bab0f3c6e08281d6ecadafcb5b08120e98f081c9c7dd824bdfdc:2) at Object.fireWith [as rejectWith] (main.min.js?v=7af39fe9ec3585e958e8637ace5e96fe0bf3ced51a8b8b5875c571f941299779fe746bf74f02bab0f3c6e08281d6ecadafcb5b08120e98f081c9c7dd824bdfdc:2) at l (main.min.js?v=7af39fe9ec3585e958e8637ace5e96fe0bf3ced51a8b8b5875c571f941299779fe746bf74f02bab0f3c6e08281d6ecadafcb5b08120e98f081c9c7dd824bdfdc:2) at XMLHttpRequest. (main.min.js?v=7af39fe9ec3585e958e8637ace5e96fe0bf3ced51a8b8b5875c571f941299779fe746bf74f02bab0f3c6e08281d6ecadafcb5b08120e98f081c9c7dd824bdfdc:2)'

Convert string of numbers to array of numbers? [closed]

Posted: 08 Sep 2021 09:30 AM PDT

I have a string of numbers

let numbers = ["54321"]  

I want to turn it into

let numbersToArray = [5,4,3,2,1]  

I've tried split, push and other ways to but seem to crack it

React app not navigating programmatically, having to refresh page with link in address bar for it to navigate

Posted: 08 Sep 2021 09:31 AM PDT

Here is my code:

import {Redirect, withRouter} from 'react-router-dom';    class App extends React.Component{      constructor(props){          super(props);          this.state = {              account: {                  email: "",                  password: ""              },              token: "",              authenticated: false          };        }            confirm = async (email) => {          let result;          let stateAccount;          let authToken;          let storedCookie;            try {              //confirming passcode              result = await axios.post(`http://localhost:5000/some/endpoint/in/api`, {email});                stateAccount = this.state.account              stateAccount.email = email;              this.setState({stateAccount});                  console.log(result);                if (this.state.account.email === result.data.Email && this.state.account.password === result.data.OTPCode) {                  console.log(`Permisson Granted!`);                                       authToken = result.headers.accesstoken;                  this.setState({token: authToken});                    //checking localStorage for the access token                  storedCookie = localStorage.getItem("accessToken");                } else {                  console.log(`Not permitted!`);              }                  let history = this.props.history;                    //check the accessToken, if not found/expired/tampered with then                if(storedCookie){                  console.log("You can proceed");                  history.push({pathname: "/somelink/list", state: {stateAccount}});                }else{                  console.log("Token Mismatch - Permission Denied!");              }                }catch(error){              console.log(`You cannot proceed!`);          }  }                notLoggedInhomePage = () =>{            if(!this.state.authenticated) {              return (                  <form onSubmit={this.handleSubmit}>                      <br/>                                                <label>Email Address</label>                          <input type="text" value={this.state.account.email} onChange={this.handleChange} name="email"/>                                                    <label>Password</label>                          <input type="password" value={this.state.account.password} onChange={this.handleChange} name="password" />                        <div>                      <br/>                      <button type="submit"  onClick={() => {                          this.confirm(String(this.state.account.email));                      }}>Sign In</button>                  </form>              );          }      }        render(){  return(      <Router>          <Switch>              {/** It does not redirect to the page when using ProtectedRoute component */}              <Route path="/somelink/list" exact component={SomeComponent} authenticated={storedToken} />          </Switch>      </Router>      );    }              }      export default withRouter(App);  

When I click on the sign in button, The url changes to /somelink/list

however, the view does not change. In order for it to change, I have to manually refresh the page with the /somelink/list in the address bar.

printing the object:

Object:  action: "PUSH"  block: ƒ block(prompt)  createHref: ƒ createHref(location)  go: ƒ go(n)  goBack: ƒ goBack()  goForward: ƒ goForward()  length: 9  listen: ƒ listen(listener)  location:  hash: ""  key: "jtc0yl"  pathname: "/somelink/list"  search: ""  

Here is a snippet of the code above that checks if token is in localStorage:

if(storedCookie){      console.log("You can proceed");      history.push({pathname: "/somelink/list", state: {stateAccount}});    }else{      console.log("You cannot proceed!");  }  

How to have it programmatically navigate to that endpoint automatically upon login, without the need to manually refresh the page ?

IntelliJ Checkout Git Branches

Posted: 08 Sep 2021 09:30 AM PDT

I've just discovered that you may checkout branches within IntelliJ, without having to open the terminal. My question is: When we use the option to checkout to a certain branch, does it execute a git pull automatically? Or do we have to open the terminal and do it ourselves?

How to creat multiple columns of dummies for intervals in R

Posted: 08 Sep 2021 09:31 AM PDT

data$Distance_100<-0  data$Distance_100[data$Distance<100]<-1    data$Distance_200<-0  data$Distance_200[data$Distance>=101&data$Distance<200]<-1    data$Distance_300<-0  data$Distance_300[data$Distance>=201&data$Distance<300]<-1    data$Distance_400<-0  data$Distance_400[data$Distance>=301&data$Distance<400]<-1    data$Distance_500<-0  data$Distance_500[data$Distance>=401&data$Distance<500]<-1  

The outcome must be multiple columns. This code creat just one column data$DistanceCut5 = cut(data$Distance, breaks=c(0,100,200,300,400,500))

Unable to connect to oracle cloud autonomous database from linux environment

Posted: 08 Sep 2021 09:30 AM PDT

I am using a Node JS application that has Oracle Autonomous Database as a backend. It works perfectly on my local machine and I am able to connect it well without any issue. I tried deploying Node JS project to Azure WebAppService on Linux server.

Initially after deployment I my project was not able to find the Oracle client and so after searching a lot I was able to fix that problem by below steps

 mkdir /opt/oracle  cd /opt/oracle  wget https://download.oracle.com/otn_software/linux/instantclient/1912000/instantclient-basic-linux.x64-19.12.0.0.0dbru.zip  unzip instantclient-basic-linux.x64-19.12.0.0.0dbru.zip  cd /opt/instantclient_19_12  cd /opt/instantclient_19_12/network/admin  wget https://mywalleturl/walts.zip  unzip walts.zip  apt-get install libaio1  export LD_LIBRARY_PATH=/opt/instantclient_21_1:$LD_LIBRARY_PATH  

with this I was able to solve client issue. I have wallet files which I received from oracle which I have placed in admin folder

but now the problem is when I make any request I am getting this error

data:{"message":"db.doConnect is not a function","stack":"TypeError: db.doConnect is not a `function\n`  

what I understood with this message is I am not able to connect to my cloud database and I am not sure how to solve this can anyone help me with it its been 2 weeks now with this problem.

In Node JS project I am using simpleoracle library to connect my oracle cloud anonymous database

How to Read a value from appsettings.json and mix it with the values ​returned by Entity Framework

Posted: 08 Sep 2021 09:30 AM PDT

Good morning, I have a Project in Asp.net Core 5 which has a Core project with entities. My question is, I need to know how to mix a property of the News Class with a value that is hosted in another ASP.Net Core API project. That is, when returning the value from Entity you must be able to mix the values ​​of appsettings.json + the image field

that is, in the GetNoticiacastList () method I need the FullPath property to mix with the values ​​of the appsettings and the value of the image property. to form a URL of the

my appsettings.json

"AppSettings": {  "virtualpath": "//google.com/photos/"  

},

My class:

    public class Noticia  {      public int  id{ get; set; }      public string Titulo { get; set; }      public string Imagen { get; set; }      public string FullPath { get; set; }  }  

My NoticiaRepository:

     public async Task<IEnumerable<Noticia>> GetNoticiacastList()      {          var listadoNoticia = await _context.Noticia.ToListAsync();          return listadoNoticia ;      }  

How to initialize bootstrap 4.6 collapse with javascript?

Posted: 08 Sep 2021 09:30 AM PDT

Bootstrap 4.6 docs mention that we can enable/initialize the collapse menu with eaither data- attributes or javascript. I assume data-target is still necessary to link a button to the collapsable element. This leaves me with data-toggle="collapse", which I assume further is equivalent of the javascript initilization. So lets try it out:

$("#demo").collapse() //doesn't work    $("#demo").collapse({    toggle: false  }) //doesn't work either!!    $("#demo").collapse("toggle"); //doesn't do nothing
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>    <div class="container-fluid">    <button id="mybtn" type="button" class="btn btn-primary"  data-target="#demo">Simple collapsible</button>    <div id="demo" class="collapse">      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.    </div>  </div>

As you can see, I am unable to initialize the collapse function through javascript alone. So my question is:

  1. How to enable/initialize bootstrap 4.6 collapse without data- attributes, using javascript?
  2. What does passing the options object in the initialization do? Especially what's the difference between passing {toggle: false} and {toggle: true}? Can I pass {toggle: "collapse"}?

Can we build Carrom Board game in flutter?

Posted: 08 Sep 2021 09:31 AM PDT

can we build a carrom pool game clone in flutter?

i know about the flutter flame but i can't find any tutorial where any one build some thing like that

How to write more shortly?

Posted: 08 Sep 2021 09:31 AM PDT

I want to write more shortly. It might be written in one line. How can I do that?

    this.xxx = smt.filter(item => item.Id === this.smtStatus.ONE);      this.yyy = smt.filter(item => item.Id === this.smtStatus.TWO);      this.zzz = smt.filter(item => item.Id === this.smtStatus.THREE);  

Which array methods should I use?

Thanks for your help!

I wanna make a form with Phone Number authentication in flutter with custom fields

Posted: 08 Sep 2021 09:30 AM PDT

I wanna make a form with Phone Number authentication in flutter with custom fields and want to store data in the firebase database. I know how to do Phone Number authentication and how to make forms in the flutter but the issue is I wanna get OTP at registration for a new user. Need help I am stuck in this. Here is my form picture

Thanks in advance.

Java Spring API - continous status

Posted: 08 Sep 2021 09:31 AM PDT

I have a question regarding how to build a Java Spring API that can continuously update the frontend with a status. How I want this to go about is that I can via a POST-request "update" the status of our application, and this to then be information that is obtainable from the frontend with a GET-request. The POST-request is to be used from within a VM.

Just to try and make myself clear:

  1. Frontend "subscribes" to some sort of connection, identified by a user-id.
  2. A POST-request to the backend is fired from within a VM.
  3. This new status is broadcast to the correct connection (based on user-id) in out frontend application.

How would I go about to build this?

Our backend is a Java Spring Boot REST API and out frontend is a React webapplication.

why does valgrind throw a conditional jump error? [closed]

Posted: 08 Sep 2021 09:31 AM PDT

I have been trying many different things to figure out the error:

==14541== Conditional jump or move depends on uninitialised value(s)                    ==14541==    at 0x4011AC: main (so4.c:15)              

It does not work, line 15 is some conditional test (it could be a while or an if, to give a couple of examples)

#include <stdio.h>    int main(void)  {     int numbers[4];     numbers[0] = 1;     numbers[1] = 3;     numbers[2] = 4;     int num = 0;     for(int i = 0; i < 4; i++)     {      num *= 10;      num += numbers[i];     }     if (num)     {        printf("num %d\n", num);     }  }  

The while loop is where it gives the Valgrind error

For context the numbers is an array that holds a number and I am trying to combine them so {1,3,4} should result in 134.

Trying to run additive transform_filter operations depending on separate interval selection endpoints in altair / vega-lite

Posted: 08 Sep 2021 09:31 AM PDT

I work with data of sizes of particles of two classes (A and B) from n samples. I want to scatter-plot A against B as the percentages of particles that are within any possible size sub-range.

For interactively selecting these size sub-ranges, I use two auxiliary plots (one for each class) where I added interval selections in order to set and move around the desired ranges.

current state of the chart: scatter point not don't react to selection

From another question here I already learned that aggregation operations can not be updated by interval selections (which is a vega-lite issue). So I prepared my dataframe to contain pre-calculated percentage values for any possible size bin and any possible combination of size bins of A and B. Now, I "only" need to find a way to filter this extended dataset down to what is currently selected in the auxiliary plots.

Example of the dataframe structure:

      sample      A     lower_A    upper_A       B      lower_B     upper_B     0      S3      20.1         0       100       97.7         0         100   1      S3      20.1         0       100        0.9       100         200  ...    ...       ...       ...       ...        ...       ...         ...  673     S2       6.0       300       500        2.5       200         500  674     S2       6.0       300       500        0.9       300         500  

The code is using a transform_calculate to get the endpoints of the selection (inspired from here) and a transform_filter to use the extracted values to filter the dataset on the columns representing the upper and lower size boundaries of the percentages of A and B (inspired from here).

To prevent empty selections from the filtering when interval boundaries are not at values which exist in the dataset (the lower and upper size limits are discrete at 0, 100, 200, 300, 400 and 500), the calculated endpoints are fix to the next full hundred by ceil() or floor(), as it was suggested below. However, the points that get plotted seem not to react to what intervals are selected. In the data view of the vega-lite editor, I can see that the rows that result from the filtering are always fixed at lower_ 0 and upper_ 100, independent of what is selected.

It seems to me that the problem must be in the way I am trying to get the endpoints from the selections: (isDefined(brush1.y) ? (brush1.y[0]) : 1)

Example including a working toy dataframe:

import pandas as pd  import altair as alt      df = pd.DataFrame({'sample':['S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S3','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S1','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2','S2'],'A':[20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,1.6,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.1,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,20.9,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,16.5,78.2,78.2,78.2,78.2,78.2,78.2,78.2,78.2,78.2,78.2,78.2,78.2,78.2,78.2,78.2,77.4,77.4,77.4,77.4,77.4,77.4,77.4,77.4,77.4,77.4,77.4,77.4,77.4,77.4,77.4,70.1,70.1,70.1,70.1,70.1,70.1,70.1,70.1,70.1,70.1,70.1,70.1,70.1,70.1,70.1,95.3,95.3,95.3,95.3,95.3,95.3,95.3,95.3,95.3,95.3,95.3,95.3,95.3,95.3,95.3,96.3,96.3,96.3,96.3,96.3,96.3,96.3,96.3,96.3,96.3,96.3,96.3,96.3,96.3,96.3,92.8,92.8,92.8,92.8,92.8,92.8,92.8,92.8,92.8,92.8,92.8,92.8,92.8,92.8,92.8,98.4,98.4,98.4,98.4,98.4,98.4,98.4,98.4,98.4,98.4,98.4,98.4,98.4,98.4,98.4,99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5,99.5,98.8,98.8,98.8,98.8,98.8,98.8,98.8,98.8,98.8,98.8,98.8,98.8,98.8,98.8,98.8,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,58.1,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,56.5,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,53.6,75.2,75.2,75.2,75.2,75.2,75.2,75.2,75.2,75.2,75.2,75.2,75.2,75.2,75.2,75.2,75.4,75.4,75.4,75.4,75.4,75.4,75.4,75.4,75.4,75.4,75.4,75.4,75.4,75.4,75.4,76.3,76.3,76.3,76.3,76.3,76.3,76.3,76.3,76.3,76.3,76.3,76.3,76.3,76.3,76.3,78.3,78.3,78.3,78.3,78.3,78.3,78.3,78.3,78.3,78.3,78.3,78.3,78.3,78.3,78.3,78.6,78.6,78.6,78.6,78.6,78.6,78.6,78.6,78.6,78.6,78.6,78.6,78.6,78.6,78.6,82.3,82.3,82.3,82.3,82.3,82.3,82.3,82.3,82.3,82.3,82.3,82.3,82.3,82.3,82.3,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,17.2,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,18.9,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,22.6,20.2,20.2,20.2,20.2,20.2,20.2,20.2,20.2,20.2,20.2,20.2,20.2,20.2,20.2,20.2,22.0,22.0,22.0,22.0,22.0,22.0,22.0,22.0,22.0,22.0,22.0,22.0,22.0,22.0,22.0,28.7,28.7,28.7,28.7,28.7,28.7,28.7,28.7,28.7,28.7,28.7,28.7,28.7,28.7,28.7,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,3.1,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0],'lower_A':[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300],'upper_A':[100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,300,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500],'B':[97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9,97.7,0.9,0.2,0.5,0.4,97.7,98.6,98.8,99.3,0.9,1.1,1.6,0.2,0.6,0.5,91.3,4.7,1.8,1.2,0.6,91.3,96.1,97.9,99.0,4.7,6.5,7.7,1.8,3.0,1.2,90.3,6.5,1.7,0.9,0.4,90.3,96.8,98.5,99.4,6.5,8.2,9.1,1.7,2.5,0.9],'lower_B':[0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300,0,100,200,300,400,0,0,0,0,100,100,100,200,200,300],'upper_B':[100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500,100,200,300,400,500,200,300,400,500,300,400,500,400,500,500]})      brush1 = alt.selection_interval(name="brush1", encodings=['y'])  brush2 = alt.selection_interval(name="brush2", encodings=['x'])      scatter = alt.Chart(df  ).transform_calculate(      b1l='floor((isDefined(brush1.y) ? (brush1.y[0]) : 1) / 100) * 100',      b1u='ceil((isDefined(brush1.y) ? (brush1.y[1]) : 1) / 100) * 100',      b2l='floor((isDefined(brush2.x) ? (brush2.x[0]) : 1) / 100) * 100',      b2u='ceil((isDefined(brush2.x) ? (brush2.x[1]) : 1) / 100) * 100',  ).mark_point().encode(      x = 'B',      y = 'A',      tooltip = 'sample'  ).transform_filter(      '(datum.lower_A == datum.b1l) &&'      '(datum.upper_A == datum.b1u) &&'      '(datum.lower_B == datum.b2l) &&'      '(datum.upper_B == datum.b2u)'  )          A = alt.Chart(df).mark_line().encode(      x = 'mean(A)',      y = alt.Y('lower_A', axis=alt.Axis(title='Select size range for A'))  ).transform_filter(      '(datum.lower_A == datum.lower_B) &&'      '(datum.upper_A == datum.upper_B)'  ).add_selection(      brush1  ).properties(      height = 300,      width = 100  )      B = alt.Chart(df).mark_line().encode(      x = alt.X('lower_B', axis=alt.Axis(title='Select size range for B')),      y = 'mean(B)'  ).transform_filter(      '(datum.lower_A == datum.lower_B) &&'      '(datum.upper_A == datum.upper_B)'  ).add_selection(      brush2  ).properties(      height = 100,      width = 400  )      A | scatter & B  

Can someone spot if I am doing something wrong here? Or give hints if I should tackle it in a completely different way?

Accordion header not working when clicked

Posted: 08 Sep 2021 09:31 AM PDT

Hoping someone can help. Below is a javascript accordion. It works just the way I want for most part. See JS Fiddle below, accordion opens up when clicking on the red background however, I need it to open when clicked anywhere (red and blue). It's probably simple but can't work out why it doesn't work, would apppreciate some assistance.

https://jsfiddle.net/xgjmnpt4/

<div class="a-btn" style="background:red">      <span style="left: 0"></span>      <div class="row is-vertical-align" style="background:blue">        <div class="col-4">          cards      </div>        <div class="col-2 text-center">        1      </div>        <div class="col-2 text-center">        20      </div>        <div class="col-2 text-center">        50      </div>        <div class="col-2 text-center">        100      </div>      </div>    </div>    <div class="a-panel">      <div class="row pb-2">        Lorem Ipsum     </div>      <div class="row">        <div class="col-4">          Card        </div>        <div class="col-4">          cards        </div>      </div>    </div>  
function initAcc(elem, option){      document.addEventListener('click', function (e) {          if (!e.target.matches(elem+' .a-btn')) return;          else{              if(!e.target.parentElement.classList.contains('active')){                  if(option==true){                      var elementList = document.querySelectorAll(elem+' .a-container');                      Array.prototype.forEach.call(elementList, function (e) {                          console.log(elementList);                          e.classList.remove('active');                      });                  }                              e.target.parentElement.classList.add('active');              }else{                  e.target.parentElement.classList.remove('active');              }          }      });  }    initAcc('.accordion', true);    .accordion {      width: 100%;      height: auto;  }  .accordion .a-container {      width: 100%;      padding-bottom: 5px;  }  .accordion .a-container .a-btn {      margin: 0;      position: relative;      padding: 15px 60px 15px 30px;      width: 100%;      color: #191919;      font-weight: 400;      display: block;      font-weight: 500;      cursor: pointer;      transition: all 0.3s ease-in-out;      border-radius: 0px;      border: 1px solid rgba(211, 231, 235, 1);      font-size: 1.6rem;        font-family: sans-serif;      color: #333;  }  .accordion .a-container .a-btn span {      display: block;      position: absolute;      pointer-events: none;      height: 2.4rem;      width: 2.4rem;      right: 2rem;      padding-left: 0.5rem;      border-radius: 2rem;      top: 1.8rem;  }  .accordion .a-container .a-btn span:after {      content: '';      width: 1.4rem;      height: 0.3rem;      border-radius: 0.2rem;      background-color: #333;      position: absolute;      top: 6px;  }  .accordion .a-container .a-btn span:before {      content: '';      width: 1.4rem;      height: 0.3rem;      border-radius: 0.2rem;      background-color: #333;      position: absolute;      top: 0.6rem;      transform: rotate(90deg);      transition: all 0.3s ease-in-out;  }  .accordion .a-container .a-panel {      width: 100%;      color: #191919;      opacity: 0;      height: 0;      overflow: hidden;      padding: 0px 10px;      border: 1px solid rgba(211, 231, 235, 1);      border-top: 0;  }  .accordion .a-container.active .a-btn {      color: #191919;  }  .accordion .a-container.active .a-btn span::before {      transform: rotate(0deg);  }  .accordion .a-container.active .a-panel {      padding: 30px;      opacity: 1;      height: auto;  }  

EDIT: Below answer from Phoenix works, however not with multiple accordions. Would be great if someone could assist please.

Thanks.

Serverless Localstack lambda functions send requests to AWS when endpoints are specified

Posted: 08 Sep 2021 09:31 AM PDT

I have a pretty normal localstack setup, with this part in the docker-compose.yml file

  localstack:      container_name: "localstack"      image: localstack/localstack      hostname: localstack      networks:        - ms-estates      ports:        - "127.0.0.1:53:53"        - "127.0.0.1:53:53/udp"        - "127.0.0.1:443:443"        - "127.0.0.1:4566:4566"        - "127.0.0.1:4571:4571"      environment:        - AWS_DEFAULT_REGION=eu-central-1        - SERVICES=apigateway,lambda,sqs,secretsmanager,s3,cloudformation,sts,iam,route53        - DEBUG=1  #      - LAMBDA_EXECUTOR=docker-reuse        - LAMBDA_REMOTE_DOCKER=false        - LAMBDA_REMOVE_CONTAINERS=true        - LAMBDA_DOCKER_NETWORK=ms-estates        - AWS_XRAY_SDK_ENABLED=true        - DOCKER_HOST=unix:///var/run/docker.sock        - DATA_DIR=/tmp/localstack/data        - START_WEB=1        - HOSTNAME_EXTERNAL=localstack      volumes:        - '/var/run/docker.sock:/var/run/docker.sock'        - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"        - ./localstack:/docker-entrypoint-initaws.d  

and this is the serverless-localstack part I have in the serverless.yml file:

custom:    localstack:      stages:        - local      lambda:        mountCode: True  #    endpointFile: localstack_endpoints.json      endpoints:        SecretsManager: http://localstack:4566        secretsmanager: http://localstack:4566  

You see I even tried different cases and endpointsFile property with the same result.

The problem I'm having is that when I try to connect to the Secrets Manager (or any other service) my code is still trying to knock to the AWS service

  constructor() {      this.secretsManager = new SecretsManager();    }  

This part is going to try to reach this URL secretsmanager.eu-central-1.amazonaws.com

How can I make my code talk to the local service instances without "if env" hacks?

In Starbasic Macros, in LibreCalc, I cant make a string to be passed as expression

Posted: 08 Sep 2021 09:31 AM PDT

In Starbasic Macros, in LibreCalc, I cant make a string to be passed as expression.

  • splitColours(1) returns the name of string
  • cLightYellow returns the value of the variable

How I convert String as an expression ?

         cLightYellow    = RGB(24,194,205)           cLightPurple    = RGB(224,194,205)           cLightGreen     = RGB(175,208,149)           cBlue           = RGB(114,159,207)           cOrange         = RGB(232,162,2)           cGreen          = RGB(63,175,70)           cBlack          = RGB(49,64,4 )        Const oColours = "cLightYellow|cLightPurple|cLightGreen|" _                         & "cBlue|cOrange|cGreen|cBlack"                                               splitColours   = Split(oColours, "|")          ' print splitColours(1) returns the name of string  ' print cLightYellow returns the value of the variable  

Scanf skips variable and reuses old one

Posted: 08 Sep 2021 09:31 AM PDT

Im going through the C Programming Absolute Beginners Guide 3rd edition to learn programming and im having issues at Chapter8ex2.c where my program gets the cost and then is supposed to get the topping it instead passes by that and reuses the first variable instead of using the correct second one.

here is my code

// This is a sample program that asks users for some basic data and prints it on   // the screen in order to show what was entered  #include <stdio.h>    int main()  {      char topping[24];      int slices;      int month, day, year;      float cost;        // The first scanf will look for a floating-point variable, the cost of the pizza      // If the user doesn't enter a $ before the cost, it could cause problems        printf("How much does a pizza cost in your area?");      printf("enter as $XX.XX)\n");      scanf(" $%f", &cost);        // The pizza topping is a string, so your scanf doesn't need an &        printf("What is your favorite one-word pizza topping?\n");      scanf(" %s", topping);        printf("How many slices of %s pizza", topping);      printf("can you eat in one sitting?\n");      scanf("%i", &slices);        printf("What is today's date (enter it in XX/XX/XX format).\n");      scanf(" %i/%i/%i", &month, &day, &year);        printf("\n\nWhy not treat yourself to dinner on %i/%i/%i", month, day, year);      printf("\nand have %i slices of %s pizza!\n", slices, topping);      printf("It will only cost you $%.2f!\n\n\n", cost);        return(0);   }  

here is the code being run

How much does a pizza cost in your area?enter as $XX.XX)  15.00  What is your favorite one-word pizza topping?  How many slices of 15.00 pizzacan you eat in one sitting?  

How can I fix "AttributeError: 'dict' object has no attribute 'append'" in Twython

Posted: 08 Sep 2021 09:31 AM PDT

Im working on learning some python and I wanted to write a script that would pull my followers usernames from my twitter and save it to a file.

The script comes from this website https://www.silkstream.net/blog/2014/06/playing-with-followers-with-twython-csv.html

the code i've typed up is below

from twython import Twython  import datetime    app_key = ""  app_secret = ""  oauth_token = ""  oauth_token_secret = ""    twitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)  #twitter.update_status(status = "Testing a script dont mind this tweet")    followers = []  datestamp = datetime.datetime.now().strftime("%Y-%m-%d")  username = input("what is your username: ")  next_cursor = -1  while(next_cursor):      get_followers = twitter.get_followers_list(screen_name=username,count=200,cursor=next_cursor)      for followers in get_followers["users"]:          followers.append(follower["screen_name"].encode("utf-8"))          next_cursor = get_followers["next_cursor"]    followers_text = open(username+"-"+datestamp+".txt","a")  followers_text.write("%s has %s followers (%s)):" % (str(username),str(len(followers)),str(datestamp))+"".join(followers))  followers_text.close()  

when I run the program I get this output

File "first.py", line 19, in <module>  followers.append(follower["screen_name"].encode("utf-8"))  AttributeError: 'dict' object has no attribute 'append'  

If I comment out line 19 it actually runs but i get this weird output in the saved file

idid_strnamescreen_namelocationdescriptionurlentitiesprotectedfollowers_countfriends_countlisted_countcreated_atfavourites_countutc_offsettime_zonegeo_enabledverifiedstatuses_countlangstatuscontributors_enabledis_translatoris_translation_enabledprofile_background_colorprofile_background_image_urlprofile_background_image_url_httpsprofile_background_tileprofile_image_urlprofile_image_url_httpsprofile_banner_urlprofile_link_colorprofile_sidebar_border_colorprofile_sidebar_fill_colorprofile_text_colorprofile_use_background_imagehas_extended_profiledefault_profiledefault_profile_imagefollowinglive_followingfollow_request_sentnotificationsmutingblockingblocked_bytranslator_type  

it looks like it thinks something is a dictionary(or at least that's my guess) but I don't have any in there do I?

tkinter not updating value

Posted: 08 Sep 2021 09:31 AM PDT

in my code below im using tkinter to display two values. the first value updates just fine but the second one dosent seem to update. ive structured them the same so i figured it should update. is there any reason that it wont?

#!/usr/bin/env python3  # imports  import requests  import time  from tkinter import *  import urllib.request, json    # variables  def get_coinbase_price():      url = 'https://api.coinbase.com/v2/prices/USD/spot?'      req = requests.get(url)      data = req.json()      bit = (data['data'][0]['amount'])      thelabel.config(text = "1 BTC = %s USD" % bit)      root.after(1000, get_coinbase_price)      def get_nicehash_stats():      with urllib.request.urlopen(              "https://api.nicehash.com/api?method=stats.provider.ex&addr=37sCnRwMW7w8V7Y4zyVZD5uCmc9N1kZ2Q8") as url:          data = json.loads(url.read().decode())      total = 0      for val in data['result']['current']:          total += float(val['data'][1])      secondlabel.config(text="Nicehash stats = %s " % total)      root.after(1000, get_nicehash_stats)        # gui workspace  root = Tk()  thelabel = Label(root, text="")  secondlabel = Label(root, text="")  thelabel.pack()  secondlabel.pack()  root.after(1000, get_coinbase_price)  root.after(1000, get_nicehash_stats)  root.mainloop()  

How would I distribute python code?

Posted: 08 Sep 2021 09:31 AM PDT

Im working on a python project of mine and i wanted it to be able to run like a application. so i made a gui for it and i want to distribute it for other people to use. but i used packages like requests and tkinter. how would i make the program more portable? so people could just click on the .py file and my gui would just come up.

#!/usr/bin/env python3  # imports  import requests  import time  from tkinter import *  import random    # variables  test = 'https://api.nicehash.com/api?method=stats.provider.ex&addr=37sCnRwMW7w8V7Y4zyVZD5uCmc9N1kZ2Q8&callback=jQuery111304118770088094035_1506738346881&_=1506738346882'  url = 'https://api.coinbase.com/v2/prices/USD/spot?'        # def function to update  def update_bitcoin_ui():        # update the data sourced form the website      req = requests.get(url)      data = req.json()      bit = (data['data'][0]['amount'])        # update the gui to reflect new value      thelabel.config(text = "1 BTC = %s USD" % bit)        # verify the Ui is updating      #thelabel.config(text=str(random.random()))      root.after(1000, update_bitcoin_ui)    # gui workspace  root = Tk()  thelabel = Label(root, text = "")    # set more of the gui and launch the ui  thelabel.pack()  root.after(1000, update_bitcoin_ui)  root.mainloop()  

EDIT: i found what i was looking for. i was looking for something to the effects of pyinstaller

How to make sure docker's time syncs with that of the host?

Posted: 08 Sep 2021 09:30 AM PDT

I have dockers running on Linode servers. At times, I see that the time is not right on the dockers. Currently I have changed the run script in every docker to include the following lines of code.

yum install -y ntp  service ntpd stop  ntpdate pool.ntp.org  

What I would ideally like to do however is that the docker should sync time with the host. Is there a way to do this?

No comments:

Post a Comment