is there a magic method for logical and and or in python?
I thought they are __and__ and __or__ but turns out they are for bitwise comparisons not logical ones. Are there such methods for the logical comparators?
Join the discussion →I thought they are __and__ and __or__ but turns out they are for bitwise comparisons not logical ones. Are there such methods for the logical comparators?
Join the discussion →How to implement drag-select (make HTML elements selectable by area mouse selecting)? I'm interested in the element selecting like it is in file explorers (of Windows, Linux) and many other sites that provide a file explorer behaviour (dropbox.com, google.drive, mega.nz, js-fileexplorer demo). I mean the selecting when you create a rectangular area by mouse move with all elements are touched by this area are "selected" (for example, an extra CSS class is added to them). How to do it? Best approach?
Join the discussion →In RStudio, when you define vectors, data frames, lists, etc., you can see a preview of the data in the data viewer (in the upper-right corner of the picture, where you can see a num [1:4] 1 2 3 4, etc.). Is there an extension or feature in Visual Studio Code that does the same? I have not been able to find one. Searching online and among the VS Code extensions was unsuccessful. I suspect that "data viewer" may be the wrong keyword.
Join the discussion →I found that we can build/reconstruct an external pointer from a memory address, see this example where I take a pointer from a data table object and rebuild it: # devtools::install_github("randy3k/xptr") iris_dt <- data.table::as.data.table(iris) ptr1 <- attr(iris_dt, ".internal.selfref") ptr1 #> <pointer: 0x13c00d4e0> typeof(ptr1) #> [1] "externalptr" address <- xptr::xptr_address(ptr1) address #> [1] "0x13c00d4e0" ptr2 <- xptr::new_xptr(address) identical(ptr1, ptr2) #> [1] TRUE Obviously xptr::new_xptr("0x13c00d4e0") is not stable between sessions, I am aware that the above is not allocati
Join the discussion →I'm trying to use OpenSearch to connect to my OpenSearch domain on AWS. I set env for AWS. However, I'm encountering an authentication/authorization failure. Here's my code: public class Example { public static void main(final String[] args) throws IOException { SdkHttpClient httpClient = ApacheHttpClient.builder().build(); try { OpenSearchClient client = new OpenSearchClient( new AwsSdk2Transport( httpClient, "search-*****-3ovub4o4gncugluu6t2tquptnu.eu-central-1.es.amazonaws.com", Region.EU_CENTRAL_1, AwsSdk2TransportOptions.builder().build())); InfoResponse info = client.info(); System.out.p
Join the discussion →Let's say I have a json data of multiple vendors in a large number of categories. I need to make post api calls for top 10 vendors of these hundreds of categories. How can I do that in a scalable manner? Each category's post api call has a specific request body. How to map the specific json to each api call's expected request body? I was thinking something like : json.stream .parallel() .map((x) -> { reqBody = jackson mapper for the request body; return reqBody; }) .forEach((body)-> make post call); I thought of polymorphism, but with large number of categories, it's difficult to have a common
Join the discussion →I am trying to get data form Census Track data in Anaconda and jupyter-nootbook using Pandas, but I am keep getting error. My code: import pandas as pd import numpy as np import requests import geopandas as gpd year = '2021' variable = 'B09019_003E' with open (r"pathToKeyFile/census_api.txt", "r") as f: c = f.read(); url='https://api.census.gov/data/{0}/acs/acs5?get=NAME,{1}&for=tract:*&in=state:12%20county:057&key={2}'\ .format(year, variable, c) response = requests.request("GET",url) response.raise_for_status() print(response.json) temp = pd.DataFrame(response.json()[1:], columns=response.js
Join the discussion →I am currently testing a Service performing HTTP requests with WebClient on Spring. When I'm mocking the service I get a NullPointerException on my body when I'm testing a method which performs a POST request. Here is the error : java.lang.NullPointerException: Cannot invoke "org.springframework.web.reactive.function.client.WebClient$RequestHeadersSpec.retrieve()" because the return value of "org.springframework.web.reactive.function.client.WebClient$RequestBodySpec.body(org.reactivestreams.Publisher, java.lang.Class)" is null Here is my code : import com.bluelagoon.payetonkawa.dolibarr.entiti
Join the discussion →Best practice to manage multiple stacks with Terraform in replacement of CDK Hi all. In my previous company, we manage the AWS Resources with CDK CloudFormation. Basically, there are three AWS accounts for one project: Dev account: For development and verification purpose. Any CDK and application code changes like AWS Lambda can be deployed from developer's local machine directly. The developer can check if the AWS Resources are created with his/her changes after that deployment from AWS console. QA account: A test account before deployed to prod environment. Prod account: A production environ
Join the discussion →I am very new to running perl scripts and I am running into problems that I suspect are due to the assignment of variables. Here is the beginning of the original script: #!/usr/bin/perl -w ##################################### # gbstrim.pl # John Garbe # June 2016 # # ##################################### =head1 NAME gbstrim.pl - - Trim padding and/or cut site residue from beginning of reads - Trim sequencing adapter from ends of reads - Trim all reads to length NOTE: this doesn't handle paired-end data =head1 SYNOPSIS gbstrim.pl --enzyme1 bamhi --enzyme2 psti --read R1 [--threads 1] [--minlen
Join the discussion →I am trying to run the below command but I am getting an error message: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Install-Module -Name PackageManagement,PowerShellGet -AllowClobber -Force -SkipPublisherCheck Error message: WARNING: The version '1.4.8.1' of module 'PackageManagement' is currently in use. Retry the operation after closing the applications. I am running on a windows server and on PowerShell 5.1. I've tried to remove the module and uninstall the module and I get the same error, the server has also had a reboot and there are no other users on i
Join the discussion →How can I set a default value in a CDS view for a fiori elements app (based on annotations)? What I tried. I want to have the current date as a default value. @Consumption.filter: { defaultValue: '@Environment.systemDateTime' } and also @Consumption.filter.defaultValue: '@Environment.systemDateTime') and any other Environment date function and session. When I set in the default value a static value it work. When I use the environment thing I get also the error One parameter has an invalid value: parameter IS_EXPRESSION-DATE has the invalid value
Join the discussion →I found these two methods to add environment variables: Add environment variables in terminal.integrated.env.osx for terminal. Add environment variables in launch.json for debugging. But no similar config options exist for VSCode Process. Some plugins often need to access specific environmental variables. In this case, I can only set up an environment variables in Terminal.App, and then open through the code command. I hope to add this environment variable in the VS Code setting file.
Join the discussion →We use Oracle for our databases so have a lot of .pak and .bod files in our Azure Repo. Currently, when you create a pull request the diff view will show it with no syntax highlighting. I'm trying to get ADO to treat them as .sql files as they are essentially the same and that is how we used to be able to see the syntax on gitlab. Is there any way to do this on ADO?
Join the discussion →Screenshot demonstrating the issue I have two errors in this file, and both are showing up in the Problems panel. All good. There is a warning too, however, on line 8. It's a warning about the member dummy implicitly having an "any" type, and I notice it's not showing up in the Problems panel. Why is that, and how can I make sure things like this show up in the panel? I checked the filters for the Problems panel, thinking that maybe the warning was being filtered. The Errors, Warnings, and Infos checkboxes are all enabled though, so that's not the issue. Here's a smaller repro: class Foo { bar
Join the discussion →My goal is to scrape a 13 F resource and output the text. I'm getting "Request successful!" and yet also getting "Number of filings found: 0" I tried this code: !pip install pexpect import pexpect import json import requests # Set the API endpoint URL , using placeholder token! endpoint = "https://api.sec-api.io?token=010101" # Set the search parameters params = { "query": { "query_string": { "query": "name:\"Bridgewater Associates, LP\"" } }, "from": "0", "size": "10", "sort": [ { "filedAt": { "order": "desc" } } ], "range": { "filedAt": { "gte": "2021-01-01", "lte": "2021-03-15" } } } # Send
Join the discussion →I've got a gauge to measure the number of unprocessed objects sitting in a queue. This queue is being polled by multiple instances, each of which records the size of the queue on each poll. The problem is visualising this information using PromQL. I want to see the size of the gauge whenever it is measured, no matter which instance measured it. If I just query the raw gauge metric I'll get a line on the graph for each instance. Is there any way to simply see the value of the gauge ignoring the instance label? I don't want to aggregate them or anything - since each instance is measuring the sam
Join the discussion →Seems like since the Google Trends webiste update, I haven't been able to use Pytrends at all. Is there anyone who can help me with that? Thanks! It's giving me error code 429 straight away.
Join the discussion →パーク24が運営するカーシェアサービス「タイムズカー」のシステムが不正アクセスを受け、およそ660万アカウントの個人情報が漏洩した。約160万件には運転免許証や学生証の画像など本人確認書類の情報が含まれる。悪用されるリスクが高い個人情報を大量に抱えながら、あまりにずさんな管理だったと言わざるを得ない。サ...
Join the discussion →I am trying to convert a webm video to mov format without losing quality and transparency using the following command: ffmpeg -c:v libvpx-vp9 -i input.webm ouput.mov The video gets converted, but it loses transparency and the background of video is black. I also tried the following command: ffmpeg -c:v png -i input.webm output.mov But it gives me the following error output: libavutil 58. 3.100 / 58. 3.100 libavcodec 60. 4.100 / 60. 4.100 libavformat 60. 4.100 / 60. 4.100 libavdevice 60. 2.100 / 60. 2.100 libavfilter 9. 4.100 / 9. 4.100 libswscale 7. 2.100 / 7. 2.100 libswresample 4. 11.100 / 4
Join the discussion →I'll be in South Korea for a couple of weeks and would love to rent a car there to drive around the country. What is the best navigation app I can use there (with English interface of course)? It seems like GMaps is completely useless, it can't make any driving routes.
Join the discussion →Problem I am trying to use image optimization for local files inside the public directory in a SSG Next.js project. There have been quite a few discussions on Github about introducing the possibility to use the next/image for image optimization at build time. However, at this moment, the next/image component does not work with the static site export. See: https://github.com/vercel/next.js/discussions/19065 Solutions Attempts / Ideas From what I could find, there are a few different actions that can be taken: 1. Set the unoptimized flag in the next.config.js file to completely disable image opt
Join the discussion →I have a situation where I need to create a computed property from a pinia store getter - import { computed} from 'vue' import { storeToRefs } from 'pinia' import {useMyStore} from './../stores/mystore' export default { setup() { const { sessionUser } = storeToRefs(useMyStore()) const fullName = computed( () => `${ sessionUser.value.value.firstName } ${ sessionUser.value.value.lastName }` ) return { fullName } } } Obviously the value.value is clunky, and I'd rather not move the computed property down into the store itself. I know why the vale.value is necessary, but is there any better way to
Join the discussion →As you can see from my code, I've written a simple program with the turtle module to randomly draw lines with a random color. The turtle will randomly move forward or backward with a random distance which is chosen from a list. What I would like to do is to prevent the turtle to go outside the window border. I've tried different things, searched on this website, also asked to chatGpt but none solution found solved the problem. Can someone fix my code explaining to me what I'm doing wrong? import random import turtle from turtle import Turtle, Screen my_screen = Screen() my_screen.setup(800, 60
Join the discussion →I'm experimenting to determine if the pathlib module is an improvement over the os for directory traversal. To my surprise, I am getting better readings from the os module when compared to pathlib. Which is something I was not expecting. Is it because the os module is dumb enough to not care if the path string represents a file or a directory or a link etc.? So speed vs. better control? Perhaps I am not using pathlib the way it should be used for this. Here's the code: import os import sys import pathlib import time import pdb def TraverseDir(path=None, oswalk=None): if path is None: path = pa
Join the discussion →In Vs-Code the plugin "KUBERNETES" shows the error (Kubectl command failed) when it tries to load the kubernetes that are loaded/running in my host (Linux - Ubuntu). Correction in VS-Code using Kubernetes extension (CMD/CTRL + SHIFT + P) Search for: Open User Settings (JSON) click on Preferences: Open User Settings (JSON) add "vs-kubernetes.enable-snap-flag": true and save the file "settings.json" Capture of the solution when Kubernetes does not recognize the cluster in the host (Linux) I found the solution here: https://github.com/vscode-kubernetes-tools/vscode-kubernetes-tools/issues/522#iss
Join the discussion →I'm using mux-player-react on a next.js site to implement a background looped movie (agobay.com). Unfortunately the video reloads after each loop. On slower connection, it starts first with a poor quality version and reloads the good one later. But this happens on each loop again. How can I prevent this (caching video?) thanks for help <MuxPlayer className={styles.videoMob} playbackId={'xxxx'} streamType="on-demand" loop muted autoPlay />
Join the discussion →I have this code that does it using SVD. But I want to know how to do the same using PCA. Online, all I can find is that they are related, etc., but I am not sure how they are related and how they are different in code, doing the exact same thing. I just want to see how PCA does this differently than SVD. import numpy as np points = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) # Centering the points mean_point = np.mean(points, axis=0) centered_points = points - mean_point # Calculating the covariance matrix covariance_matrix = np.cov(centered_points, rowvar=False) # Performing the SVD U, s, V
Join the discussion →Details about my system; Ubunttu 22.04.2 LTS x86_64 pyqtgraph v0.13.1 pyhton v3.10 The code I'm trying to run on line 56; from pyqtgraph.Qt import QtGui, QtCore import pyqtgraph as pg app = QtGui.QApplication([]) The Error I get; AttributeError: module 'pyqtgraph.Qt.QtGui' has no attribute 'QApplication'. is QApplication no longer supported in pyqtgraph? Not sure on what to do, I got this source code from github and I don't completely understand what the author was doing. Edit: I get a similar error on line 58. win = pg.GraphicsWindow(title="plotting") AttributeError: module 'pyqtgraph' has no
Join the discussion →Has anyone written Python code to traverse a Snowflake Role hierarchy? A role can be granted a role which can be granted a role. Nested roles are possible. In Python, I want to start with a specific role Query all grants to the role that are roles store each of those in a unique list for each of those roles execute a SQL statement that will query all roles granted to that role and traverse down the hierarchy, not missing a single role and also not traversing a role that has already been queried or that is in the list to be queried Something recursive to crawl this tree using Python would be he
Join the discussion →