Friday, June 25, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Python docx extracting Font name and size

Posted: 25 Jun 2021 12:04 PM PDT

I want to code a program in python which checks some properties of an MS Word file (.docx) like margins and font name and font size. (before moving forward I should note that Honestly, I have no clue what am I doing)

for the font part I've faced real problems:
according to: https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html

"A style can inherit properties from another style, somewhat similarly to how Cascading Style Sheets (CSS) works. Inheritance is specified using the base_style attribute. By basing one style on another, an inheritance hierarchy of arbitrary depth can be formed. A style having no base style inherits properties from the document defaults."

so I tried this code:

d = Document('1.docx')  d_styles = d.styles    for st in d_styles:      if st.name != "No List": #Ignoring The Numbering Style          print(st.type, st.name, st.base_style)          #print(dir(st.base_style), '\n') there is no such thing as font in dir(st.base_style)  

st.base_style returns "None"

so based on "A style having no base style inherits properties from the document defaults" the answer should lie down in this part. But I don't know how to reach it.

Codes below also returned "None":

for st in d_styles:      if st.name != "No List": #Ignoring The Numbering Style          print(st.font.name)  #Outputs: None  
for para in d.paragraphs:      for r in para.runs:          print (r.font.name)  #Outputs: None  
for para in d.paragraphs:      print(para.style.font.name)  #Outputs: None  

I've used these Sources:
https://python-docx.readthedocs.io/en/latest/api/style.html
https://python-docx.readthedocs.io/en/latest/user/styles-understanding.html

Pause UIViewAnimation when app goes background and resume in foreground mode

Posted: 25 Jun 2021 12:04 PM PDT

Maybe question is duplicate, but didn't get the answer what I need. I am animating a view using UIViewAnimation with completion block. when app goes to background mode need to pause the animation and resume it from where it paused in foreground mode. I am using bellow methods for pause and resume:-

func resume() {      let pausedTime: CFTimeInterval = layer.timeOffset      layer.speed = 1.0      layer.timeOffset = 0.0      layer.beginTime = 0.0      let timeSincePause: CFTimeInterval = layer.convertTime(CACurrentMediaTime(), from: nil) - pausedTime      layer.beginTime = timeSincePause  }  func pause() {      let pausedTime: CFTimeInterval = layer.convertTime(CACurrentMediaTime(), from: nil)      layer.speed = 0.0      layer.timeOffset = pausedTime  }  

Those two methods works fine if app is in foreground. but if app goes to background, animation finished and completion block called first then pause method called but not worked as animation already finished. I used UIApplication.willEnterForegroundNotification and UIApplication.didEnterBackgroundNotification

According to this answer use Core Animation instead of UIViewAnimation and then the resume/pause will work. But I didn't get the way to use CABasicAnimation instead of UIView animation.

        UIView.animate(withDuration: duration, delay: 0.0, options: [.curveLinear], animations: {[weak self] in          if let _self = self {              _self.frame.size.width = width          }      }) { [weak self] (finished) in          // do something after finished animation      }  

If use Core Animation how can I do it? else is there any solution for UIView animation background pause and foreground resume.

is this tree a valid binary search tree [1, 7, 11, 17, 21, 29, 74, 89, 91, 101, 132, 157]

Posted: 25 Jun 2021 12:04 PM PDT

for the mentioned below code in leetcode the output is mentioned as false

But i have used this javascript code to check validation and its returning true.

I want to understand whether my assumption of binary search tree is wrong or is there some end case i'm missing in my code pasted here?

need to understand how?

var arr = [1, 7, 11, 17, 21, 29, 74, 89, 91, 101, 132, 157];    function Node(data, left = null, right = null) {    this.data = data;    this.left = null;    this.right = null;  }    let bstNode = createBSTRecurrsive(arr);  console.log(bstNode);  function createBSTRecurrsive(arr){    if(arr.length == 0){      return null;    }    let middle = parseInt(arr.length / 2);    let root = new Node(arr[middle]);    root.left = createBSTRecurrsive(arr.slice(0, middle));    root.right = createBSTRecurrsive(arr.slice(middle + 1));    return root;  }    isvalidBST(bstNode);  function isvalidBST(node){    if(node == null){      return true;    }    let stack = [];    let temp = null;    while(node != null || stack.length != 0){      while(node != null){        stack.push(node);        node = node.left;      }      node = stack.pop();      if(temp != null && node.data <= temp.data){        console.log(node);        console.log(temp);        return false      };      temp = node;      node = node.right;    }    return true;  }  

How to set clientDeleteProhibited, clientRenewProhibited, and clientUpdateProhibited EPP status codes in AWS Route 53?

Posted: 25 Jun 2021 12:04 PM PDT

An external vulnerability scanner flagged a domain I manage through AWS Route 53 as not having the clientDeleteProhibited, clientRenewProhibited, and clientUpdateProhibited EPP status codes set.

I confirmed this via whois:

Good whois entry for compliant domain

# whois.registrar.amazon.com  # ...  Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited  Domain Status: clientRenewProhibited https://icann.org/epp#clientRenewProhibited  Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited  Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited  

Bad entry for non compliant domain

# whois.registrar.amazon.com  # ...  Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited  

How can I configure AWS Route 53 to enable these status codes?

How do I fix "NameError: name 'bs4' is not defined?

Posted: 25 Jun 2021 12:04 PM PDT

I have beautifulsoup4 installed, and am running python 3.8 on windows 10. How should I fix this?

I'm trying to understand what the below code means, I know it ignores ssl certificate errors but I am not sure how it does that

Posted: 25 Jun 2021 12:03 PM PDT

ctx = ssl.create_default_context()  ctx.check_hostname = Falseenter code here  ctx.verify_mode = ssl.CERT_NONE  

I don't understand what the syntax the individual lines of code do

How do I extract number from string and replace it?

Posted: 25 Jun 2021 12:03 PM PDT

I am not sure how to do it,I am trying to get the numbers from string and replace them with (Number) I am trying to make this by using regex: var num = post.content.replace(/[^0-9]/g, '') but I don't get the numbers in a array,it's just a large"string" of them:enter image description here

This is what I want to "highlight":enter image description here

Using where clause within a partition

Posted: 25 Jun 2021 12:03 PM PDT

I have huge pageview level table, where each session has multiple pageviews.

Session -> Pageviews - 1 : M

From the pageviews table, I need to consolidate the data into one row per session with meta data like FirstPageview, LastPageview, #ofvisitstoLogin

  1. Firstpageview is defined as the very first pageview for a session (this can be login)

  2. Lastpageview is defined as a pageview that is not /login (this cannot be login, if it is pick the pageview before this)

  3. #ofvisitstologin is defined as the #oftimesthesession landed on login

visitorid sessionid timestamp webpagepath
abc 123 2021-01-01 10:30:00 homepage
abc 123 2021-01-01 10:30:50 login
abc 123 2021-01-01 10:31:00 page2
abc 123 2021-01-01 10:32:50 page3
abc 123 2021-01-01 10:33:00 page2
abc 123 2021-01-01 10:35:50 login

The output that I want,

visitorid sessionid FristPageview LastPageview #ofvisitstoLogin
abc 123 homepage page2 2

Is it possible to do this with window functions? Without using subqueries / joins because this is a huge table and it affects performance.

Sample query that I have,

select        visitor_id,        session_id,       first_value(webpage_path) over (partition by visitor_id, session_id order by timestamp asc) as first_pageview,        last_value(webpage_path) over (partition by visitor_id, session_id order by timestamp asc) as last_page_view,        sum(iff(webpage_path = 'login', 1, 0)) over (partition by visitor_id, session_id timestamp asc) as noofvisitstologin   from pageviews;  

But this code doesn't work because for the last_page_view column will be "login" if i run this code. But i need it to be "page2" instead.

Is this achievable without using subqueries / self join?

Is there a tool to migrate large amount of data to Oracle NoSQL Database Cloud Service?

Posted: 25 Jun 2021 12:03 PM PDT

I am still pretty new to the NoSQL cloud service. I have a pretty large dataset to upload to the service for performance tests. I exported the data from the other database in JSON format. It is about 2 GB in size.

Is there a tool to do bulk data migration to Oracle NoSQL Database Cloud Service? I hope to use an automated migration tool without having to write scripts or codes.

Procecs Builder email alert not triggered

Posted: 25 Jun 2021 12:03 PM PDT

In the formula if I hardcode the First Name of User ('Hopper') who is assigned the System Administrator profile, the email alert is triggered.

Process Builder Email Alert enter image description here

AND (           ISNEW(),         [Opportunity].RecordType.DeveloperName ="Dealer_Opportunity" ,         [Opportunity].CreatedBy.FirstName = "Hopper"      )  

However, if I change the formula to 'Role Name' and the user who is assigned to the role creates a New Oportunity, the Email Alert is not triggered.

   AND (       ISNEW(),     [Opportunity].RecordType.DeveloperName ="Dealer_Opportunity" ,     [Opportunity].CreatedBy.UserRole.DeveloperName  = "Business_Development_Manager_West"    )                      

SwiftUI: forcing focus based on state

Posted: 25 Jun 2021 12:02 PM PDT

I'm trying to have a feature where a button enables the digital crown. There are multiple tabs with this button, and I want to be able to scroll between the tabs and keep the mode/crown enabled.

enter image description here enter image description here

So for above, my goal is the user could touch 'Enable Crown' and be able to swipe between tabs, keeping the digital crown mode enabled.

I believe that means maintaining focus on an element that has digitalCrownRotation() and focusable().

I got this working somewhat with the code below: if the 2nd tab is not active yet and I enable the crown and swipe to tab #2, the default focus modifier triggers #2 button to get focus and get the crown input.

But after that the buttons lose focus. I've tried various tricks and can't get it working. Complete code is at https://github.com/t9mike/DigitalCrownHelp3.

import SwiftUI    class GlobalState : ObservableObject {      @Published var enableCrown = false  }    struct ChildView: View {      @State var crownValue = 0.0      @ObservedObject var globalState = ContentView.globalState      @Namespace private var namespace      @Environment(\.resetFocus) var resetFocus            let label: String        init(_ label: String) {          self.label = label      }            var body: some View {          ScrollView {              Text(label)              Button("\(globalState.enableCrown ? "Disable" : "Enable") Crown") {                  globalState.enableCrown = !globalState.enableCrown              }              .focusable()              .prefersDefaultFocus(globalState.enableCrown, in: namespace)              .digitalCrownRotation($crownValue)              .onChange(of: crownValue, perform: { value in                  print("crownValue is \(crownValue)")              })          }          .focusScope(namespace)          .onAppear {              print("\(label), enableCrown=\(globalState.enableCrown)")              resetFocus(in: namespace)          }      }  }    struct ContentView: View {      static let globalState = GlobalState()            var body: some View {          TabView {              ChildView("Tab #1")              ChildView("Tab #2")          }      }  }  

How do you align navigation to the right with bootstrap?

Posted: 25 Jun 2021 12:03 PM PDT

We are trying to have our navigation items aligned to the right of our page. We have used a container class as well as align-items-end to no avail. We will admit that this section is pretty hacked together and we don't quite understand everything that's going on. What we're trying to accomplish is to have the top of our page have a cover cover image with our navigation to the right, included in the container, we want a heading and two buttons. We also need our navigation collapse at the small (mobile) breakpoint.

This is our design from Photoshop and what we want our end design to look like. This is our design from Photoshop and what we want our end design to look like.

This is what our current code renders. This is what our current code renders. What are we doing wrong?

.cover {    min-height: 500px;    background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url(img/moco-trucks.png);    background-position: center;    background-repeat: no-repeat;    background-size: cover;    color: #fff;    position: relative;  }    .navbar-dark .navbar-nav .nav-link {    color: #fff;  }    .navbar-dark:hover,  .navbar-dark:focus,  .navbar-dark:active {    color: rgba(199, 84, 40, 1)  }    .nav-item,  .nav-link {    color: #fff;    text-transform: uppercase;  }    .nav-pills .nav-link.active,  .nav-pills .show>.nav-link {    color: #fff;    background-color: #c75428;  }    .nav-pills .nav-link.active:hover,  .nav-pills .show>.nav-link {    color: #fff;    background-color: #a64723;  }    .nav-link:hover,  .nav-link:focus,  .nav-link:active {    color: #c75428;  }
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">    <!-- container with bg img -->  <div class="cover">    <div class="container justify-content-end">      <!-- NAV Here -->      <nav class="navbar navbar-expand-sm navbar-dark" aria-label="responsive navbar">        <a class="navbar-brand" href="index.html"><img src="img/the-other-side-moving-storage-color-white.png" width="75%" height="75%"></a>        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#responsive-navbar" aria-controls="responsive-navbar" aria-expanded="false" aria-label="Toggle navigation">            <span class="navbar-toggler-icon"></span>          </button>        <div class="collapse navbar-collapse" id="responsive-navbar">          <ul class="navbar-nav me-auto mb-2 mb-sm-0">            <li class="nav-item">              <a class="nav-link" href="denver-moving-services.html">Moving</a>            </li>            <li class="nav-item">              <a class="nav-link" href="denver-storage-company.html">Storage</a>            </li>            <li class="nav-item">              <a class="nav-link" href="receiving-and-delivery.html">Furniture Delivery</a>            </li>            <li class="nav-item">              <a class="nav-link" href="about-us.html">About</a>            </li>            <li class="nav-item">              <a href="free-estimate.html"><button class="btn btn-tosa" type="submit">Free Estimate</button></a>            </li>          </ul>        </div>      </nav>    </div>    <!-- Nav end -->    <!-- FS Hero -->    <div class="container-xl mb-4">      <div class="row text-center">        <div class="col-12">          <h1 class="py-5">Denver Moving and Storage</h1>          <a href="free-estimate.html"><button type="button" class="btn btn-tosa mx-3">Free Estimate</button></a>          <a href="about-us.html"><button type="button" class="btn btn-outline-tosa mx-3">Our Story</button></a>        </div>      </div>    </div>    <!-- End FS Hero -->  </div>  <!-- End Cover -->

How can i use lambda function and re.search to get substrings from a list of filenames in python

Posted: 25 Jun 2021 12:03 PM PDT

I have a list of filenames from a certain directory ,

list_files = [filename_ew1_234_rt, filename_ew1_456_rt, filename_ew1_78946464_rt]

I am trying to use re.search on this as follows filtered_values = list(filter(lambda v: re.search('.*(ew1.+rt)', v), list_files))

Now when I print filtered values it prints the entire filenames again, how can i get it to print only certain part of filename

Here is what i see

filename_ew1_234_rt

filename_ew1_456_rt

filename_ew1_78946464_rt

Instead i would like to get

ew1_234_rt

ew1_456_rt

ew1_78946464_rt

How can i do that?

Why I'm getting Network error while fetching public api React?

Posted: 25 Jun 2021 12:03 PM PDT

I'm trying to fetch my client API but it's getting network error while it showing data when I check it on the new tab

API Response on new tab New Tab Picture

Here's the codesandbox link

https://codesandbox.io/s/amazing-monad-igg82?file=/src/App.js

Open folder path

Posted: 25 Jun 2021 12:03 PM PDT

I am creating an .exe application that registers companies every time I create a company folders are created where I save images, company notes, etc.

In this application I have a function where it opens a folder of the registered company depending on the selected id and within this folder I save images, the problem is that when I create a new company and try to open the folder of the new company it opens another folder that already has a saved image and since the new registered company has not yet saved its image, it does not open it for me, it redirects me to another company that has already saved an image

When registering the new companies I want to open their folder even if there is nothing there

This is the function to open the folder.

import os  import subprocess  def FileExplorer(Direction):  f = open("FileExplorer.bat", "w")  f.write("@echo." + "\n")  #f.write("chdir C:\\" + "\n")  #f.write('MOVE "' + Origin + '" "' + Destiny + '"' + "\n")  f.write("explorer "+ Direction + "\n")  f.write("@echo.")  f.close()  # currentDirectory = os.getcwd()  to_run = 'FileExplorer.bat'  subprocess.call(to_run, shell= True)  os.remove('FileExplorer.bat')    def LogoFolder(self):      id = self.ui.lineEdit.text()      if id:          pathIcon = os.path.abspath(os.path.join(self.pathLogo, "../"))          if os.path.exists(pathIcon):              FileExplorer(pathIcon)  

This is the code to create the folders.

  lenID = abs(len(id) - 5)              nameid = ""              for i in range(lenID):                  nameid += "0"              nameid += id              self.pathID = os.getcwd() + "\\Backup\\Data\\" + nameid              self.pathimages = os.getcwd() + "\\Backup\\Data\\" + nameid + "\\Contacts"              pathlogo = os.getcwd() + "\\Backup\\Data\\" + nameid + "\\Logo"              pathimeeting = os.getcwd() + "\\Backup\\Data\\" + nameid + "\\Meeting"              pathnote= os.getcwd() + "\\Backup\\Data\\" + nameid + "\\Notes.txt"              pathID = os.path.join(os.getcwd() + "\\Backup\\Data\\" + nameid)              ####### CREATE FOLDER              if not os.path.exists(pathID):                  os.mkdir(pathID)              if not os.path.exists(self.pathimages):                  os.mkdir(self.pathimages)              if not os.path.exists(pathlogo):                  os.mkdir(pathlogo)              if not os.path.exists(pathimeeting):                  os.mkdir(pathimeeting)              if not os.path.exists(pathnote):                 with open(pathnote, 'w'): pass              self.ui.label_2.setText(self.pathID)              self.Cargar(self.pathimages)              self.Logo(pathlogo)              self.Notes(self.pathID)  

Here is an image to make it a little better understood

enter image description here

enter image description here

Seaborn scatterplot can't get hue_order to work

Posted: 25 Jun 2021 12:03 PM PDT

I have a Seaborn scatterplot and am trying to control the plotting order with 'hue_order', but it is not working as I would have expected (I can't get the blue dot to show on top of the gray).

x = [1, 2, 3, 1, 2, 3]  cat = ['N','Y','N','N','N']  test = pd.DataFrame(list(zip(x,cat)),                     columns =['x','cat']                   )  display(test)    colors = {'N': 'gray', 'Y': 'blue'}  sns.scatterplot(data=test, x='x', y='x',                   hue='cat', hue_order=['Y', 'N', ],                  palette=colors,                 )  

enter image description here

Flipping the 'hue_order' to hue_order=['N', 'Y', ] doesn't change the plot. How can I get the 'Y' category to plot on top of the 'N' category? My actual data has duplicate x,y ordinates that are differentiated by the category column.

ArrayList with enums

Posted: 25 Jun 2021 12:03 PM PDT

I need help to be able to return a list of attributes from an enum.

It currently generats an error.

The enum:

public enum EnumServices {        GYM,      SWIMMING_POOL,      SECURITY,      SUM,      STORAGE,      GARAGE  }  

The code I'm writing in another class:

@Override  public List<EnumPropertyType> findAllPropertiesTypes() {      return List <Property> EnumPropertyType = new ArrayList();      propertiesTypeList.add("GYM");      propertiesTypeList.add("SWIMMING_POOL");      propertiesTypeList.add("SECURITY");      propertiesTypeList.add("SUM");      propertiesTypeList.add("STORAGE");      propertiesTypeList.add("GARAGE");  }  

What's wrong there?

How to match substring of key in dart

Posted: 25 Jun 2021 12:04 PM PDT

I have map of strings which looks like this:

 var networks= {      '62':'n1',      '75,74,76,73':'n2',      '71,65,66':'n3',      '78':'n4'    };   

I have string '0776556688'and I want to see if the third and fourth digits match any key.

This returns false: networks.containsKey(p.substring(2,4)); but 76 is a key.

How can I make this return true?

c++ Save application window to file yield 'incorrect' area?

Posted: 25 Jun 2021 12:03 PM PDT

I'm slowly making progress in my c++ application. I would like to 'automate' the repetitive manual screen capture I go through every time in support of my debugging process. I'm relatively new to c++ so I found this snippet that seems to work fine for me, except it's not quite capturing my application area :

RECT rectWindow;  GetWindowRect(hWnd, &rectWindow);   // hWnd defined in global scope    int x1, y1, x2, y2, w, h;    x1 = rectWindow.left;   // x1 = 780  y1 = rectWindow.top;    // y1 = 385  x2 = rectWindow.right;  // x2 = 1780  y2 = rectWindow.bottom; // y2 = 1055    // width and height  w = x2 - x1;    // w = 1000  h = y2 - y1;    // h = 670    // copy window to bitmap  HDC     hWindow = GetDC(hWnd);  HDC     hDC = CreateCompatibleDC(hWindow);  HBITMAP hBitmap = CreateCompatibleBitmap(hWindow, w, h);  HGDIOBJ old_obj = SelectObject(hDC, hBitmap);  BOOL    bRet = BitBlt(hDC, 0, 0, w, h, hWindow, x1, y1, SRCCOPY);    CImage image;  image.Attach(hBitmap);  image.Save(L"C:\\TEMP\\window.bmp", Gdiplus::ImageFormatBMP);    // clean-up  SelectObject(hDC, old_obj);  DeleteDC(hDC);  ::ReleaseDC(NULL, hWindow);  DeleteObject(hBitmap);  

Below is a manual screen capture of my application window :

result of manual screen capture

Now, this (saved in JPEG to meet SO min size requirements) is what I'm getting :

BMP image re-saved as JPEG

Not quite what I expect. So I edited the Bit Block call this way :

BOOL    bRet = BitBlt(hDC, 0, 0, w, h, hWindow, 0, 0, SRCCOPY);  

And this gives me "almost" the correct capture :

Almost correct result

What am doing wrong?

How to setup Gitlab CI job artifacts for a C# project?

Posted: 25 Jun 2021 12:03 PM PDT

This is how I would do it using Github:

jobs:    run-tests:        runs-on: ubuntu-latest            defaults:        run:          working-directory: ./MyApp        steps:      - uses: actions/checkout@v2            - name: Setup .NET        uses: actions/setup-dotnet@v1        with:          dotnet-version: 5.0.x        - name: Restore dependencies        run: dotnet restore              - name: Build project        run: dotnet build --no-restore              - name: Run tests        run: dotnet test --no-build  

This time on Gitlab my project solution file is in the root directory of the repository. I created a .gitlab-ci.yml file and started with

image: mcr.microsoft.com/dotnet/sdk:5.0    stages:    - restore-dependencies    - build-solution    - run-tests    restore-dependencies:    stage: restore-dependencies    script:      - dotnet restore    build-solution:    stage: build-solution    script:      - dotnet build --no-restore    run-tests:    stage: run-tests    script:      - dotnet test --no-build  

The first job passes but the second one fails because it can't find the restored files from the first job. I found this in the docs

https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html

so I added

artifacts:    paths:      - .  

to the restore-dependencies job and the build-solution job. Unfortunately this didn't help, the second job is still not able to find a resource file in ...\TestProject1\obj\project.assets.json

How can I fix the pipeline configuration?

Python Web Scraping in Pagination in Single Page Application

Posted: 25 Jun 2021 12:03 PM PDT

I am currently researching on how to scrape web content using python in pagination driven by javascript in single page application (SPA).

For example, https://angular-8-pagination-example.stackblitz.io/

I googled and found that using Scrapy is not possible to scrape javascript / SPA driven content. It needs to use Splash. I am new to both Scrapy and Splash. Is this correct?

Also, how do I call the javascript pagination method? I inspect the element, it's just an anchor without href and javascript event.

Please advise.

Thank you,

Hatjhie

KivyMD why app on pc looks different on mobile

Posted: 25 Jun 2021 12:03 PM PDT

Here is the pitures of PC app and Mobile app: PC - https://imgur.com/GzGHEjR Mobile - https://imgur.com/GqudNbt what i need to do to make this work? do i need to run the mobile app everytime to make changes?

kv file here (im not sure how to indent):

FloatLayout:  canvas:      Color:          rgba: 66/255, 66/255, 66/255, 1      RoundedRectangle:          pos: (5, 5)          size: self.width -10, self.height -10          radius: [50]      MDLabel:      text: 'Amount'      bold: True      theme_text_color: 'Custom'      text_color: 1, 1, 1, 1      halign: 'center'      pos_hint: {'center_x':0.15, 'center_y':0.6}    MDTextFieldRound:      id: amount_text      text: '0'      size_hint: 0.15,0.05      pos_hint: {'center_x':0.20, 'center_y':0.53}      line_color: 76/255, 182/255, 172/255, 1      foreground_color: 1, 1, 1, 1      normal_color: 76/255, 182/255, 172/255, 1      MDLabel:      text: 'From'      bold: True      theme_text_color: 'Custom'      text_color: 1, 1, 1, 1      halign: 'center'      pos_hint: {'center_x': 0.38, 'center_y':0.6}    MDFillRoundFlatButton:      id: menu_button1      text: 'USD'      font_size: 20      pos_hint: {'center_x': 0.45, 'center_y': 0.53}      size_hint: 0.23, 0.05      md_bg_color: 76/255, 182/255, 172/255, 1      on_press: app.menu1.open()      MDLabel:      text: 'To'      bold: True      theme_text_color: 'Custom'      text_color: 1, 1, 1, 1      halign: 'center'      pos_hint: {'center_x': 0.72, 'center_y':0.6}    MDFillRoundFlatButton:      id: menu_button2      text: 'ILS'      font_size: 20      pos_hint: {'center_x': 0.8, 'center_y': 0.53}      size_hint: 0.23, 0.05      md_bg_color: 76/255, 182/255, 172/255, 1      on_press: app.menu2.open()      MDRaisedButton:      pos_hint: {'center_x': 0.62, 'center_y': 0.53}      size_hint: (None, None)      width: dp(2100)      md_bg_color: 66/255, 66/255, 66/255, 1      on_press: app.change()        Image:          source: 'convert.png'      MDFillRoundFlatButton:      text: 'Convert'      pos_hint: {'x':0.8, 'center_y':0.4}      md_bg_color: 100/255, 170/255, 210/255, 1      on_press: app.convert()      MDTextField:      text: '0'      id: result      pos_hint: {'center_x':0.5, 'center_y':0.3}      size_hint: 0.3, 0.2      font_size: 32      halign: 'center'      line_color_normal: 76/255, 182/255, 172/255, 1      readonly: True  

It looks like your post is mostly code; please add some more details.

Mac M1 why node js is not running in OS terminal but in IDE terminals?

Posted: 25 Jun 2021 12:02 PM PDT

On a M1 MacBook Air i installed node 14.x and 16.x by NVM (NVM was installed by homebrew)

If I run node -v on iTerm or OS terminal I always get zsh: killed node -v

But if I run the same command within the integrated terminal of either VSCode, Rubymine or Marta, node runs fine yielding version number. (And I can develop using node, too)

Can someone explain why this is happening. What are the differences between the different terminals? Don't the all use same zsh in the background?

Pandas csv parser not working properly when it encounters `"`

Posted: 25 Jun 2021 12:03 PM PDT

Problem statement:

Initially what I had

I have a CSV file with the below records:-

data.csv:-

 id,age,name   3500300026,23,"rahul"   3500300163,45,"sunita"   3500320786,12,"patrick"   3500321074,41,"Viper"   3500321107,54,"Dawn Breaker"  

When I tried to run script.py on this with encoding 'ISO-8859-1', it's running fine

# script.py  import pandas as pd  test_data2=pd.read_csv('data.csv', sep=',', encoding='ISO-8859-1')  print(test_data2)  

Result1


Now what I have:-

But when I got a feed of the same file with " at the front of every record, the parser behaved awkwardly. After the data change, new records looks like below:-

id,age,name  "3500300026,23,"rahul"  "3500300163,45,"sunita"  "3500320786,12,"patrick"  "3500321074,41,"Viper"  "3500321107,54,"Dawn Breaker"  

And after running the same script (script.py) for this new data file, I am getting the below result

Result2

Character " comes under ISO-8859-1 Character Set only so this can't be an issue anyway. It should be the parser, can't really get it why isn't the parser only focusing on , which I specifically passed as a separator to read_csv().

References: ISO-8859-1 Character set

I am curious to know the reason why pandas was not able to parse it properly or does it has any special connection with ".

SQL select complete row with largest value in GROUP BY

Posted: 25 Jun 2021 12:04 PM PDT

Given the following table:

account item quantity pending sequence update_time
1 1 20.0 0.0 1 (some time)
2 1 10.0 0.0 2 (some time)
3 1 100.0 0.0 3 (some time)
1 1 20.0 5.0 4 (some time)
2 1 10.0 10.5 4 (some time)
3 1 100.0 100.0 6 (some time)
1 1 25.0 0.0 7 (some time)
2 1 20.5 0.0 8 (some time)
3 1 200.0 0.0 9 (some time)

I want to create a query that returns the complete row with the highest sequence grouped by account, item

The statements result for the data above should be:

account item quantity pending sequence update_time
1 1 25.0 0.0 7 (some time)
2 1 20.5 0.0 8 (some time)
3 1 200.0 0.0 9 (some time)

Currently the best I know how to do is this:

select account, item , max(sequence) from foo group by account, item;  

I don't know how to also select the quantity, pending and update_time for top row with the top sequence.

GA4 + GTM: Remove URL query params from all page data

Posted: 25 Jun 2021 12:03 PM PDT

How do I remove URL params from getting pushed to GA4 through GTM? I have tried many solutions but none seem to be working. Which key in "Fields to Set" do I need to use so GTM replaces the url query param from all dimensions like page_path, page_location, path_referrer?

SceneKit, manually control skeleton from skinner

Posted: 25 Jun 2021 12:03 PM PDT

Apple have demo with control 3d robot with 3d pose estimation. Everything connects together and works like magic. No SceneKit used.
https://developer.apple.com/documentation/arkit/content_anchors/capturing_body_motion_in_3d

I'm trying control same robot manually in SceneKit. Come up with inconvenient approach:

let rightHand = skeleton?.childNode(withName: "right_hand_joint", recursively: true)  rightHand?.rotation = SCNVector4(0, 1, 0, .pi / 2.0)  rightHand?.parent?.rotation = SCNVector4(0, 1, 0, .pi / 2.0)  

3D Skeleton

Is there some other approach, where I can set location of the joints and it will automatically calculates angles for skeleton? All other example that I found loads some animations from .dae files.

Is it possible to turn the access_logs block on and off via the environment_name variable?

Posted: 25 Jun 2021 12:04 PM PDT

I'm looking at using the new conditionals in Terraform v0.11 to basically turn a config block on or off depending on the evnironment.

Here's the block that I'd like to make into a conditional, if, for example I have a variable to turn on for production.

access_logs {      bucket = "my-bucket"      prefix = "${var.environment_name}-alb"  }  

I think I have the logic for checking the environment conditional, but I don't know how to stick the above configuration into the logic.

"${var.environment_name == "production" ? 1 : 0 }"  

Is it possible to turn the access_logs block on and off via the environment_name variable? If this is not possible, is there a workaround?

Using XOR with pointers in C

Posted: 25 Jun 2021 12:03 PM PDT

Last week, our teacher gave us an assignment to make a double linked list in C without using two pointers in the struct; we have to implement it just using one pointer to point to the next and previous node on the list. I'm convinced that the only way of doing so is using XOR to merge the next and previous direction, and then point to that "hybrid" memory allocation, and if I need the directions of prev or next, I can use XOR again to get one of the memory values I need.

I designed the algorithm and I thought it was going to work, but when I tried to implement the solution, I encountered with a problem. When I tried to compile the program, the compiler told me that I couldn't use XOR (^) to pointers:

invalid operands to binary ^ (have 'void *' and 'node *')  

Here is the function to add a node at the front of the list:

typedef  struct node_list{    int data;    struct node_list *px;  }  node;    node* addfront ( node *root, int data ){     node *new_node, *next;      new_node = malloc ( sizeof ( node ));     new_node -> data = data;      new_node -> px = (NULL ^ root);//this will be the new head of the list      if ( root != NULL ){           // if the list isn't empty      next = ( NULL ^ root -> px );  // "next" will be the following node of root, NULL^(NULL^next_element).      root = ( new_node ^ next );    //now root isn't the head node, so it doesn't need to point null.    }  }  

I read that in C++, XOR to pointers is valid. Any ideas of how could implement this in C? I also read somewhere that I needed to use intptr_t, but I didn't understand what to do with it.

What's the ColdFusion 9 script syntax for cfsetting?

Posted: 25 Jun 2021 12:03 PM PDT

I'm trying to convert an Application.cfc to script. The original had this:

<cfcomponent displayname="Application" output="false">       <cfset this.name               = "testing">       <cfset this.applicationTimeout = createTimeSpan(0,1,0,0)>       <cfset this.sessionManagement  = true>       <cfset this.sessionTimeout     = createTimeSpan(0,0,30,0)>         <cfsetting requesttimeout="20">       ...  

I can't figure out how to convert the cfsetting tag to script. The following attempts don't work:

setting requesttimeout="20"; // throws a "function keyword is missing in FUNCTION declaration." error.  setting( requesttimeout="20" ); // throws a "Variable SETTING is undefined." error.  

It looks like Railo may be supporting it (link), but I can't find an equivalent for the cfsetting tag in ColdFusion's documents

No comments:

Post a Comment