Posts

Showing posts from October, 2021

I am struggling with c++ [closed]

I am doing this assignment but I am not sure if I am doing the right thing. See the questions below. And some of my solutions. Scenario A group of geologist are interested in a C++ application that is capable of accepting and processing data related to sites that they monitor across the island. A value between 1 and 10 (inclusively) is used to represent a geologist’s observation for an activity at a site. At minimum, each geologist will observe 10 sites for 10 days. Using an array, the minimum data for a geologist’s site could be represented as follow: 1 2 3 4 5 6 7 8 9 10 1 5 7 10 3 10 2 2 5 7 10 2 6 5 10 5 7 1 6 10 5 4 3 8 2 7 5 6 2 1 4 2 4 4 9 10 8 8 4 8 8 2 5 5 5 6 7 5 10 2 10 1 4 6 6 6 1 5 6 10 2 8 7 2 8 3 7 8 2 3 7 6 3 1 1 9 6 8 1 1 5 8 10 7 2 2 7 1 9 3 1 10 9 2 5 1 2 5 8 10 5 7 6 3 1 1 8 8 2 10 A For example, at site 1 on day 1 (A11) and at site 9 on day 7 (A97), the values 5 and 1 are seen respectively – indicating the geologist’s rating for an activity at site 1 and site

argument for 's' must be a bytes object in Python 3.8

Why am I getting the error argument for 's' must be a bytes object when trying to run the lambda function? I'm following the usage example but I'm getting this error. Any explanation to this issue and how to resolve it? { "errorMessage": "Failed sending data.\nERROR: argument for 's' must be a bytes object", "errorType": "Exception", "stackTrace": [ " File \"/var/task/AlertMetricSender.py\", line 5, in lambda_handler\n sender.send()\n", " File \"/var/task/modules/ZabbixSender.py\", line 91, in send\n self.__active_checks()\n", " File \"/var/task/modules/ZabbixSender.py\", line 79, in __active_checks\n response = self.__request(request)\n", " File \"/var/task/modules/ZabbixSender.py\", line 59, in __request\n raise Exception(\"Failed sending data.\\nERROR: %s\" % e)\n" ] } ZabbixSend

Getting errors with opencv and mediapipe for making Hand Tracking Module in Python 3.7.9

I am getting the following error whenever I try to run my code, I am following a tutorial for hand tracking, I followed the steps correctly but I still to have some sort of error. Link to Video: https://www.youtube.com/watch?v=01sAkU_NvOY&t=2100s Traceback (most recent call last): File "C:/Users/aryan/Desktop/user/Study/Com_vis/Hand_T_M.py", line 56, in <module> main() File "C:/Users/aryan/Desktop/user/Study/Com_vis/Hand_T_M.py", line 41, in main detector = handDetector() File "C:/Users/aryan/Desktop/user/Study/Com_vis/Hand_T_M.py", line 12, in __init__ self.detectionCon, self.trackCon) File "C:\Users\aryan\Desktop\user\Study\Com_vis\venv\lib\site-packages\mediapipe\python\solutions\hands.py", line 127, in __init__ outputs=['multi_hand_landmarks', 'multi_handedness']) File "C:\Users\aryan\Desktop\user\Study\Com_vis\venv\lib\site-packages\mediapipe\python\solution_base.py", line 260,

Fetch more than 100,000 records in Redshift

I have a requirement to fetch more than 400,000 records from Redshift and export it to Excel. But in Redshift, maximum limit is 100,000. So I am unable to fetch records in one go to Excel. Please help me with this, how I can do this. Note:- I am using Aginity Workbench for Redshift Tool for querying data. Thanks in Advance. from Recent Questions - Stack Overflow https://ift.tt/3nIC19r https://ift.tt/eA8V8J

PHP Problem : 8th and 9th entrance of the highway doesn't work

so i have a problem with my PHP code. It's simply the highway calculator, when you entrance in the highway, you receive a ticket with 4 numbers : the first two is the number of the entrance of the highway (0 to 9), and the last two is the vehicle (10 for motorbike, 11 for car and 12 for truck). When i enter the ticket 0711, i have this : Ticket highway . But when i enter the ticket 0811 or 0911, i have this : Ticket highway 2 and i don't know why please guys help me. (i'm very bad in english i'm french so i'm sorry if you don't understand anything). This is my code : <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> table{ border-collapse: colla

How to plot a time after conversion

Image
I want to convert one column to time and then plot it. What I did is this: df = pd.read_csv('vv.txt',sep=" ",names=list(["time", "size", "type"])) df.time = df.time.apply(lambda X: "{0:02.0f}:{1:02.0f}".format(*divmod(float(X) * 60, 60))) df["time"] = pd.to_datetime(df["time"], format='%H:%M' ).apply(pd.Timestamp) df["time"] = df["time"].map(lambda x: x.strftime("%H:%M")) plt.scatter(df['time'], df['size']) and it shows this as a result, no X-axis is showing right. How can I solve this? from Recent Questions - Stack Overflow https://ift.tt/3vXLAVI https://ift.tt/2Y3ecQY

Analise string see if vowels and 2 consecutive letters

how can i analise a string one by on, then see if it has 2 vowels (non-capital), and see if it as at least two consecutive letters of the alphabet (non-capital as well) e.g.: aabcd is valid cdefgh not valid from Recent Questions - Stack Overflow https://ift.tt/31gJ5Tf https://ift.tt/eA8V8J

Number of restricted arrangements

I am looking for a faster way to solve this problem: Let's suppose we have n boxes and n marbles (each of them has a different kind). Every box can contain only some kinds of marbles (It is shown it the example below), and only one marble fits inside one box . Please read the edits. The question is: In how many ways can I put marbles inside the boxes in polynomial time? Example: n=3 Marbles: 2,5,3 Restrictions of the i-th box (i-th box can only contain those marbles): {5,2},{3,5,2},{3,2} The answer: 3, because the possible positions of the marbles are: {5,2,3},{5,3,2},{2,5,3} I have a solution which works in O(2^n), but it is too slow. There are also one limitation about the boxes tolerance, which I don't find very important, but I will write them also. Each box has it's own kind-restrictions, but there is one list of kinds which is accepted by all of them (in the example above this widely accepted kind is 2). Edit: I have just found this question but I am not

Why is argument null not asignable to paramenter of type setStateAction in typescript?

I want to pass empty object as initial state for isAdmin , but it's not assignable. const Admin = () => { const [isAdmin, setIsAdmin] = useState({}); useEffect(() => { const user = getCurrentUser(); if (user && user.role === 'admin') { setIsAdmin(user); } else { setIsAdmin(null); } }, []); from Recent Questions - Stack Overflow https://ift.tt/2XYFbwU https://ift.tt/eA8V8J

Parametrize a function with a variable. Then delete the variable

I would like to make the following code run: mu = 5 rnorm2 <- function(N) rnorm(N, mean = mu, sd = 1) And then be able to use the rnorm2 function regardless of the presence of the mu variable in the environment. In other words, set the value of the 'mean' argument with the "mu" value once and for all. Is that possible ? from Recent Questions - Stack Overflow https://ift.tt/3EpkHgm https://ift.tt/eA8V8J

How to use Electron-Forge Typescript + webpack plugin with Electron-Builder

Image
I have started the application with npx create-electron-app my-new-app --template=typescript-webpack . I want to use electron-builder because of the packaging options. The application runs in development mode correctly thanks to webpack-dev-server. However, in the packaged application I get a white screen (Not receiving static files?) It's worth noting that when I open the packaged application and have the development server running in the background it WORKS. But when I end the terminal I start to see errors in the packaged app. Here is my package.json { "name": "@cloudapp", "productName": "@cloudapp", "version": "1.3.6", "author": { "name": "cloudapp" }, "description": "cloudapp application description", "main": ".webpack/main", "scripts": { "start:app": "npm start", "start": &quo

How to spread evenly two view types with different sizes in RecyclerView?

Image
I've added a new view type for the native ad view in my RecyclerView but I can't figure out how to spread the items evenly across the entire screen. After every 12th element, the new view type should be inserted. This is what I want: And this is what I get: The result from the 2nd picture is achieved using this code: gridLayoutManager = new GridLayoutManager(mActivity, 6); gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { switch (emotesAdapter.getItemViewType(position)) { case AD_TYPE: return gridLayoutManager.getSpanCount(); case CONTENT_TYPE: return 1; default: return -1; } } }); recyclerView.setLayoutManager(gridLayoutManager); Any ideas? from Recent Questions - Stack O

Why is JFrame methods not showing in autocomplete in Eclipse JAVA [duplicate]

issue in the picture method is working here So when working with JFrame there are many methods, some show while other don't after the (.) for some reason but when physically typed out they do work. Very inconvenient for learning process. All autocomplete option in the setting are checked. Images for reference. Sorry if the term "method" is not the correct one in this insistence. from Recent Questions - Stack Overflow https://ift.tt/3Ek6TDR https://ift.tt/eA8V8J

How to fix JFrame color problem on MacBook Pro? [closed]

Run-on Mac: Run on Mac Run-on Window: Run on Window How can I fix this problem? When I run Java Gui on my MacBook Pro, the label is invisible. But it runs fine on the window. from Recent Questions - Stack Overflow https://ift.tt/3CjXPOS https://ift.tt/eA8V8J

How payment api's can bill automatically?

Image
Is there Mobile API for Android that have an option to charge clients automatically or in the end of the month? And also can handle wallet information? (I don't want to keep card information on my own server) For example taxi apps that charges automatically in the end of ride (card information was entered before), or even Google Ads that charges in the end of the month. Which payment services they are use? from Recent Questions - Stack Overflow https://ift.tt/3mr6QQG https://ift.tt/3Bzl8Tn

Accepting multiple user inputs in C

I am writing a program in C that accepts user input in either of these formats: string, int string, int, int or float Some examples of valid inputs: Susan 5 David 10 24 Sarah 6 7.5 How do I accomplish this in C? Here is the code I have so far: #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> int main() { char name[10]; int num1; int num2; if(scanf("%s %d", name, &num1) != 2 || scanf("%s %d %d", name, &num1, &num2) != 3) { printf("Failure"); } else { printf("Pass"); } } This intends to print "Failure" if there is invalid user input and "Pass" if the user input is valid. The issue here is this code forces me to enter both formats in order to print "Pass." So if I input "Susan 5" I would have to input "David 10 24" in order to print "Pass" even though I

pyspark - read csv with custom row delimiter

how can I read a csv file with custom row delimiter (\x03) using pyspark? I tried the following code but it did not work. df = spark.read.option("lineSep","\x03").csv(path) display(df) from Recent Questions - Stack Overflow https://ift.tt/3jRYqzT https://ift.tt/eA8V8J

How Do I Space Out the Labels on the Y axis in ggplot2?

Image
I need to increase the spacing between my labels on the y-axis (see picture below). I have also included the code that I have used to make the plot in ggplot2. Thanks for your help! ggplot(who6, aes(total_cases, country))+geom_col(width = .25, position = position_dodge(width = 60*60*24)) from Recent Questions - Stack Overflow https://ift.tt/3bn57pf https://ift.tt/2ZJuXkX

How to check if multiple records exists php mysql pdo

I am designing a school timetable and this is my first time. So I send multiple records for multiple classes from HTML to php.For instance teacher1 geography Monday Start 11:35 grade 7and then techer2 geography Monday Start 12:15 grade 4. If the data am sending times for same class same day or same teacher exists then the system should skip that and insert only that which does not exist. but now my code checks and if it finds one of the records exists , it does not proceed. I want it to process with the one which does not exist and ignore the one which exits. I need help and below is my code . $usercode1 = "7892Hga"; $recieved_by = ($_SESSION['username']); $errors = []; // Array to hold validation errors $data = []; // array to pass back data $teacherid = $_POST['teacherid']; $subjectid = $_POST['subjectid']; $locationid = $_POST['locationid']; $start_time = $_POST['start_time']; $end_time = $_POST['end_time']; $courseid = $

How to return validation message using Enum class in spring boot?

I am not asking "how to validate enums". Let's say I have request body like this one: public class VerifyAccountRequest { @Email(message = "2") private String email; } What i am trying to do, instead of hardcoded way, i just want to return message's value from enum class. But IDEA is saying "Attribute value must be constant" public enum MyEnum { EMAIL("2", "info"), public String messageCode; public String info; } public class VerifyAccountRequest { @Email(message = MyEnum.Email.code) // NOT_WORKING private String email; } I can also define "2" in the interface, but i don't want to do that: public interface MyConstant { String EMAIL = "2"; } public class VerifyAccountRequest { @Email(message = MyConstant.EMAIL) // WORKS, BUT I HAVE TO USE ENUM !!! private String email; } is it possible to return message value using enum class ? from Recent

Ingress not binding to Load Balancer

Image
I have my A record on Netlify mapped to my Load Balancer IP Address on Digital Ocean, and it's able to hit the nginx server, but I'm getting a 404 when trying to access any of the apps APIs. I noticed that the status of my Ingress doesn't show that it is bound to the Load Balancer. Does anybody know what I am missing to get this setup? Application Ingress: apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: d2d-server spec: rules: - host: api.cloud.myhostname.com http: paths: - backend: service: name: d2d-server port: number: 443 path: / pathType: ImplementationSpecific Application Service: apiVersion: v1 kind: Service metadata: name: d2d-server spec: selector: app: d2d-server ports: - name: http-api protocol: TCP port: 443 targetPort: 8080 type: ClusterIP Ingress Controller: apiVersion: apps/v1 kind: D

check if there is such a directory

I want to check if there is such a directory in path C:\inetpub\wwwroot\Server/views/admin/files/session/starter/14 or not using async await: So I wrote this: const fs = require('fs'); const directoryExist = await fs.promises.access(directory); But the code above doesn't move after the second line ?!! How can I do such a simple task? from Recent Questions - Stack Overflow https://ift.tt/31g5j7R https://ift.tt/eA8V8J

RichEdit doesn't show pictures

Image
I created a simple RTF-document in WordPad, here is the screenshot: It seems, that all format things of RTF work properly except pictures, which replaced by empty string. Here is RichEdit screenshot: I tried both .bmp and .png. I also tried different version of RichEdit libraries: Riched20.dll and Msftedit.dll. Inside my .rtf file there is a string {\*\generator Riched20 10.0.19041} , I suppose it's a library and SDK version and in Visual Studio I use the same. from Recent Questions - Stack Overflow https://ift.tt/2ZBi1wV https://ift.tt/3Cu0sO6

How to create left, right, and center frames with pack?

I have a left and right frame right now and tried creating a center frame but the problem is the left frame takes up more space and pushes the center frame to the right so any widgets I put in it aren't actually centered. Is there any way to make it work? self.leftside = ttk.Frame(self) self.leftside.pack(expand=True, fill=BOTH, side=LEFT, anchor=W) self.center = ttk.Frame(self) self.center.pack(expand=True, fill=BOTH, side=LEFT, anchor=CENTER) self.rightside = ttk.Frame(self) self.rightside.pack(expand=True, fill=BOTH, side=RIGHT, anchor=E) from Recent Questions - Stack Overflow https://ift.tt/3BmIVpK https://ift.tt/eA8V8J

How are before_script/afters_script executed in relation to the script commands?

I understand what the before_script does. It executes commands to run before a job's commands get executed. But how does that actually work under the hood? Is it one "entity" that runs all the commands defined in the before_script script and after_script in the same process ? Or are these being executed by different processes (subshells?) sequentially? If for instance in the before_script a command is run that in a normal setting, running in the background, could last the duration of the script would that be killed once the scope of before_script is finished? from Recent Questions - Stack Overflow https://ift.tt/2Y0ZolS https://ift.tt/eA8V8J

Monaco Editor + Blockly: highlight new code [closed]

Is it possible, with Monaco editor, to hightlight new code injected in editor ? I see everywhere how to highlight lines, how to use diffEditor, but I want to highlight any modification, even a value, and not all the line where the modification occurs. I'm developping another tool helping newbies programm graphically microntrollers ( https://github.com/BlocklyDuino/BlocklyDuino-v2 ), so any new block on workspace creates an event that parse all blocks, that translation in code and inject it in Monaco eitor. In older project, everything was created "manually" with HTML fields ( https://code.kniwwelino.lu/ or https://ardublockly.embeddedlog.com/demo/index.html ), comparaison of old and new code listening each new block on workspace. I found something about modifying text edited ( Monaco Editor: only show part of document ), but I need something more precise, only each word and not all the line. From https://jsfiddle.net/renatodc/s6fxedo2/ , what is interecting is the modi

Hibernate native query also gets JPA select

I have a two database tables, "A" and "B" with @OneToMany(mappedBy = "a") on a List<B> field in entity A, and a @ManyToOne on field B.a. I ran into the "N+1" problem when doing default queries on A, so I am trying a native query such as: @Query(value="select * from A as a left join B as b " + "on a.ID = b.b ", nativeQuery=true) This works in the sense that the data is mapped back to the entities as expected. My problem is that I can see that Hibernate is doing a separate select for each B rather than using the results of the join. That is, I see in the console a sequence of: The select that I specified For each instance of A, another select for B using the ID from A In other words, I've still got the "n+1" problem. I figured that the @OneToMany and @ManyToOne annotations might be causing Hibernate to do these extra selects, but when I take them out, my IDE (IntelliJ) says:

Lua code Editing Fortnite issues with MoveMouseRelative

MoveMouseRelative moves very fast but I noticed that when I make my mouse move up then right it often gets a shortcut. So I miss some squares when I edit. So instead of going up then right it seems to go across. I tried to add more sleep time in the movemouse or between two moves. In first case it moves too slowly and in the second it stills taking shortcuts. This code is what is working the best (less worse), I make several up or down movements in order that smaller shortcuts are taken. But I'm sure it can be improved with a more simple code (less lines) and having à good drawing of the edit. How can that be fixed please? ---------------- -- Boutton 8 edit en rond ou du haut vers le bas mur ou escalier - MB8 round edit or up and down stair and wall ---------------- -- CapsLock OFF -- Edit en rond - Round edit if not IsKeyLockOn("capslock")then if (event == "MOUSE_BUTTON_PRESSED" and arg == 8) then

A component is changing the uncontrolled value state of Select to be controlled

I'm trying to create a edit form to edit data from database by id. I tried this: import React, {FormEvent, useEffect, useState} from "react"; import TextField from "@material-ui/core/TextField"; import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"; import { TicketFullDTO, TicketStatusTypesDTO, } from "../../service/support/types"; import { getTicket, getTicketStatusTypes, updateTicket, } from "../../service/support"; import { useHistory, useParams } from "react-router-dom"; import InputLabel from "@mui/material/InputLabel"; import Select from "@mui/material/Select"; import MenuItem from "@mui/material/MenuItem"; import { FormControl } from "@mui/material"; import { Moment } from "moment"; import { RouteParams } from "../../service/utils"; export

Unable to install pgAdmin 4 in ubuntu 21.10

I am facing some issues when I tried to install pgAdmin4 in the latest ubuntu version 21.10. I have Installed the public key for the repository using following command sudo curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add But when I tried to create the repository configuration file using the following command I am getting an error mentioned below. sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update' ERROR LOG 404 Not Found [IP: 2604:1380:2000:7501::69 443] Hit:11 http://us.archive.ubuntu.com/ubuntu impish-backports InRelease Get:12 http://us.archive.ubuntu.com/ubuntu impish-updates/main amd64 DEP-11 Metadata [7,972 B] Get:13 http://us.archive.ubuntu.com/ubuntu impish-updates/universe amd64 DEP-11 Metadata [2,008 B] Reading package lists... Done E: The repository 'https://ftp.postgresql.org/pub/pgadm

Create array of objects from sorting another array of objects

I want to create an array of objects, and the first elements from the each data object to be a separate object, the second element from the each data object to be another separate object and so on... let array = [{ data: { center1: "1", storage1: "1", system1: "1", } }, { data: { center2: "2", storage2: "2", system2: "2", } } ] Expected result: [ { center1: "1", center2: "2"}, { storage1: "1", storage2: "2"}, { system1: "1", system2: "2"} ] And this is what I tried do to but is not working really well:) const rows = []; array.forEach((item, index) => { for (let key in item.data) { rows.push({index : key + ': ' + item.data[key]}); } }); The output is this: [ {index : 'center1: 1'}, {index : 'storage1: 1'}, {index : &

how to use input forms within iframes with Puppeteer?

I'm a little bit new to puppeteer and have been getting along with it quite well until I have encountered iframes and inputting data into them. I'm trying to interact with an input named credit-card-number on the checkout.game.co.uk/payment page. I have tried the following: const iframe1 = await page.frames().find(frame => frame.src =="https://flex.cybersource.com/cybersource/assets/microform/0.4.0/iframe.html?keyId=03MksUg0hQKucIBmvTgEVkD7Vxh8h9S0"); await iframe1.type('input', '4111', { delay: 500 }); For credit card number, how can I input numbers into this box? Additionally, any feedback on how I can smarten up the code since I have been told to use functions but not sure how they all combine with puppeteer. My Code: const puppeteer = require('puppeteer'); (async () => { //go to page and add to cart const browser = await puppeteer.launch({ headless: false }); const page = await browser.newPage(); await page.goto(

Keras - MulOp type mismatch

I get the following error while trying to compile my keras model. I've researched stackoverflow and the problem was posted several times. I tried the fixes suggested there, but nothing worked. Maybe someone can spot the problem. TypeError: in user code: C:\Users\User\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_math_ops.py:6245 mul "Mul", x=x, y=y, name=name) C:\Users\User\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py:558 _apply_op_helper inferred_from[input_arg.type_attr])) TypeError: Input 'y' of 'Mul' Op has type float32 that does not match type float64 of argument 'x'. This is my code: from tensorflow import keras import numpy as np import matplotlib.pyplot as plt num_classes = len(label_encoder.classes_) def make_model(input_shape): bias = tf.cast(np.log(pos/neg),tf.float64) output_bias = tf.keras.initializers.Constant(bias) input_layer = keras.layers.Input(input_shape) con

Oracle BETWEEN from subquery

Is something like this possible? SELECT * FROM [TABLE1] WHERE [FIELDA] BETWEEN (SELECT [FIELDB], [FIELDC] FROM [TABLE2] WHERE [set of conditions to ensure single record]); Instead of doing: SELECT * FROM [TABLE1] WHERE [FIELDA] BETWEEN (SELECT [FIELDB] FROM [TABLE2] WHERE [set of conditions to ensure single record]) AND (SELECT [FIELDB] FROM [TABLE2] WHERE [set of conditions to ensure single record]); Thanks, from Recent Questions - Stack Overflow https://ift.tt/3BvTUNw https://ift.tt/eA8V8J

Get DNS script has missing output in report

<# Gets the various dns record type for a domain or use -RecordType all for all and -Report to file output. Use like .\get-dnsrecords.ps1 -Name Facebook -RecordType all or .\get-dnsrecords.ps1 -name facebook -RecordType MX #> param( [Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = "Specifies the domain.")] [string]$Name, [Parameter(Mandatory = $False, HelpMessage = "Which Record.")] [ValidateSet('A', 'MX', 'TXT', 'All')] [string]$RecordType = 'txt', [Parameter(Mandatory = $false, HelpMessage = "DNS Server to use.")] [string]$Server = '8.8.8.8', [Parameter(Mandatory = $false, HelpMessage = "Make a csv report in c:\Reports")] [Switch]$Report ) IF ($Name -notlike "*.*") { $Name = $Name + '.com' } If ($Report) { $filename = [environment]::getfolderpath(&

YouTube API - how to fetch all playlists of a channel, even the ones who were added from other channels

I stumbled across this problem as I wanted to transfer all playlists (my own and those who I added from other channels) to another channel. The code I use returns only my own playlists and not the ones I added to my channel from another channel. I tested this behaviour in the target account which contains a private playlist I created and two playlists from another channel. The script I created uses oauth in order to 'see' my private playlist, but is not able to find the certainly public playlist from the other channel. My code: request = youtube.playlists().list( part="snippet,contentDetails,status", channelId="UC_x5XG1OV2P6uZZ5FSM9Ttw", maxResults=25 ) maxResults does not play a role here as I only have got all together three playlist on the test account. The playlist from another channel is clearly visible when I use the "Library" link and scroll down to "Playlists". I would appreciate any hint to s

How to make a syntax highlighter that highlights symbols

I wanted to make a syntax highlighter that highlights symbols. Look at the example: function hello(){ return "hello"; } I want to highlight all the symbols: {([</!&|\>])};.,:=+*-@$~_^?%'" And I made a little one that highlighted strings. When I wanted to make one that highlights symbols I got confused. Now I want to know What topics should I learn to make it? Any example, github repo, tutorial, topic or ...? EDIT: I found the way to do that but I still have problem. My code is the following: function syntaxue(){ var codes = document.getElementsByClassName("syntaxue"); for (var i=0; i < codes.length; i++){ var data = codes[i].innerHTML; data = data.replace(/([^\w\s&;])/g, '<span class="sym">$1</span>'); data = data.replace(/(&lt;)/g, '<span class="sym">$1</span>'); data = data.replace(/(&gt;)/g, '<span class="sym">$1</span&

Checking value of drop down is not in another drop down. Custom Validation using YUP

Im have 3 drop downs in a React Formik form, each with the same set of options. I want to provide some custom validation using YUP to ensure that each of these drop downs has a unique value selected. The Formik values being set on each field take the shape of {id: somevalue, text: someText } I have tried setting up my validation object as below: const { values } = useFormikContext(); const validation = Yup.object({ picker1: Yup.object() .test('test-name', 'Value must be Unique', function (value) { return !((values["picker2"] && values["picker2"].id === value.id) || (values["picker3"] && values["picker3"].id === value.id)); }), ... repeat for other pickers }) The problem I am having is that the formik value is always null for the pickers when the test function executes, presumably because the value of values is scoped to when the funct

Close collapse panel onClick - Ant Design Collapse

So make the panel close automatically after clicking on the button using onClick function. I found this useful post but I have no idea what went wrong after adding into my code. Here's my custom collapse code in ./CustomCollapse.js : const CustomCollapse = (props) => { const [open, setOpen] = useState(true); useEffect(() => { setOpen(props.isOpened) }, [props.isOpened]) const setFun1= () => setDisabled(prev => !prev); const setFun2= () => () => setOpen(prev => !prev); const combineFunc = () =>{ setFun1(); setFun2(); } return ( <StyledCollapse activeKey={open} onChange={combineFunc()}> <AntCollapse.Panel header={props.header} key="1" showArrow={false} bordered={false} extra={ <span> <span style=> {followed ? <div id={styles.emptyBox}><p>+10</p></div> : <img src={tickIcon} alt=&

How can I disable deletion of inline objects when using django-reverse-admin?

Image
This is my ModelAdmin : class ComputerAdmin(ReverseModelAdmin): list_display = ('employee', 'ip', 'mac', 'name', 'hardware') list_filter = ('employee__branch', ) inline_type = 'tabular' inline_reverse = ['hardware', ] show_full_result_count = False This is how it shows when adding a new computer: As you can see, I don't want to have the delete column and delete icon, because I have a foreign key so only one element is allowed. How can I do that? Does django-reverse-admin have anything like has_delete_permisison for inlines only and not the whole ModelAdmin ? I have already searched in documentation with no results, which is why I am posting here. I updated my code as below: class HardwareInline(admin.TabularInline): model = Hardware def has_delete_permission(self, request, obj=None): return False class EmployeeAdmin(admin.ModelAdmin): list_display = ('group',

Nested grouping in Mongodb

I am working on grouping the MongoDB documents and updating the sample in the below link https://mongoplayground.net/p/c2s8KmavPBp I am expecting the output to look like [ { "group" : "one", "details":[{ "avgtime" : 9.359833333333333, "title": "Scence 1" },{ "avgtime" : 9.359833333333333, "title": "Scence 2" },{ "avgtime" : 9.359833333333333, "title": "Scence 3" }] }, { "group" : "two", "details":[{ "avgtime" : 9.359833333333333, "title": "Scence 1" }] } ] How to rename the field _id to the group and merge the two elements containing title: scence 1 and display their average time Note: Question and sample link updated from Recent Questions - Stack Overflow https://ift.tt/3CpskD7 https://ift.t

unable to download the csv file in via rest api

I'm trying to download the CSV content file using the REST API in Codeigniter 4 but it not working, I'm fetching the data from the database which I need to download via rest API. In the controller I found this: return $this->response->download('test.csv', $data); // $data is string Front in angular: const headers = new HttpHeaders().append('responseType', 'blob'); this.http.get(path, { headers }).subscribe( (res) => {}, (error) => {console.error(error)} ); But not working, am I missing something? Please guide me. from Recent Questions - Stack Overflow https://ift.tt/3Bp2zBi https://ift.tt/eA8V8J

ISupportsErrorInfo.InterfaceSupportsErrorInfo(REFIID riid) implementation

I am a babysitter now overlooking a huge old-time (started in last century) code base for Windows, using C++ and C#, largely using COM as a glue. I noticed that ISupportsErrorInfo::InterfaceSupportsErrorInfo() implementations (around 400 of them, wow) are just naive, exactly as here : STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) { static const IID* arr[] = { &IID_IStore, }; for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++) { if (InlineIsEqualGUID(*arr[i], riid)) return S_OK; } return S_FALSE; } It looks to me that, once upon a time, someone (MVP, evangelist) has written a book about COM and then everybody later just copied these lines without thinking. First of all, why do I need an array if I only have one item in it? Without an array, I don't need a for-loop. To me, it looks like one line will be fine, eg. return MyCoolHelper::InterfaceSupportsErrorInfo(riid, IID_IStore); Maybe you have seen a d

Is there a way in Flutter to scan a QR Code and also take a picture of the image?

Is there a way in Flutter to scan QR codes that enables you to take the picture of what is being scanned? How can this be implemented? The problem I am running into is whenever I successfully scan a QR Code and then try to take a picture with the camera of the phone, it is in use (by the QR Code library). If I then shut down the library and turn on the camera, there is a black screen, delay, and a refocusing of the camera. Terrible user experience. from Recent Questions - Stack Overflow https://ift.tt/2ZtuqTJ https://ift.tt/eA8V8J

Python: Get the first "encountered" duplicated character in a string

I am wondering if there is a more efficient way to resolve the following coding test: Problem: Get the first duplicate char ENCOUNTERED in a string only if more than one dup char is detected, else return None' Examples: #1 'abbcdefa' = return 'b' because it is the first encountered string, while the duplicate 'a' appears much later than the duplicate 'b' #2 'abcdefa' = None (because a is the only dup char in string) def first_dup_char(A): seen, dups = [], [] for i in A: if i in seen: dups.append(i) else: seen.append(i) # if dups list items > 1 then return the first dup else print None return dups[0] if len(dups) > 1 else 'None' My solution above works by utiizing two lists. I wanted to use set() and dict, but unfortunately both of them are unordered, unless I miss something? from Recent Questions - Stack Overflow https://ift.tt/3EwwzNT https://ift.tt/eA8V8J

Can Project Loom be used from Kotlin?

I am just getting started at playing with Project Loom... Given the Java code which seems to work correctly try (ExecutorService executor = Executors.newVirtualThreadExecutor()) { IntStream.range(0, 16).forEach(i -> { System.out.println("i = " + i + ", Thread ID = " + Thread.currentThread()); executor.submit(() -> { var thread = Thread.currentThread(); System.out.println("Thread ID = " + thread); }); }); } When IntelliJ converts this to Kotlin I get Executors.newVirtualThreadExecutor().use { executor -> IntStream.range(0, 16).forEach(IntConsumer { i: Int -> println("i = $i, Thread ID = ${Thread.currentThread()}") executor.submit(Runnable { println("Thread ID = ${Thread.currentThread()}") }) }) } private fun ExecutorService.use(block: (ExecutorService) -> Unit) { which seems to compile fine, but when executed, nothing

Batch script to monitor a service and automatically start the service if stopped. Need the output of to a logfile

Batch script to monitor a service and automatically start the service if stopped. Need to write the output of the net start command into a logfile. Executed the below script but failed to get the output into the log net start | find /i "bits" if "%errorlevel%"=="1" ( echo Service "Print Spooler" starting at %time% on %date% by Script %0>>C:\Users\DivyaBhargavMuddu\Desktop\ServiceRestart.Log sc config "spooler" start=auto FOR /F "tokens=*" %%F IN ('net start spooler ') DO ( Set var=%%F) Set /P var =< "C:\Users\DivyaBhargavMuddu\Desktop\ServiceRestart.Log" ) from Recent Questions - Stack Overflow https://ift.tt/3Gta3qO https://ift.tt/eA8V8J

A question about using an improved convolutional neural network for sentiment classification

Image
For the changes to CNN proposed in the paper "Detecting Dependency-Related Sentiment Features for Aspect-level Sentiment Classification": After extracting the features in the convolutional layer, the features are multiplied by the dependency weights proposed in the text to obtain the weighted features, and then input to the pooling Floor. Dependency weighting is a real value that quantitatively measures the dependency-relatedness between a word and the aspect term in a sentence. Dependency weighting of each word is calculated by inputting syntactic distance between it and the aspect term to some decreasing functions. The shortest path algorithms can calculate syntactic distances between all word pairs. On the dependency parse tree, words with smaller syntactic distance to the aspect term are more closely related than the other words. The dependency parse tree can be annotated manually according to dependency grammar or created automatically by parsers. I would like to ask

Need to know exact geolocation where Google stores Cloud Storage content

Due to the nature of our business, we basically need to disclose where in the globe the files uploaded by our users are located. In other words, we need the exact address where the data storage that keeps these files is located. We're using Google Firebase's Cloud Storage and, even though they mention which city each location option refers to , we are unable to check the exact address. The bucket that corresponds to our Google Cloud Storage is currently configured as: us (multiple regions in United States) , which I suppose makes it even worse to pinpoint where the data resides. But that is an easy fix: we can simply start from scratch selecting a specific region as our storage location. The main issue, however, is that, even if selecting a specific location, we can't really know the address where those files will be stored. Has anyone ever come across something like this? I tried getting support in my project's Google Cloud Platform, but apparently I need to p

Trying to change a button colour on CSS?

Image
so I'm trying to add some additional CSS on Wordpress and override the colour of this form button but nothings happening. Am I entering the right code in here? ] 1 When I inspect the button this comes up.. <form id="mc4wp-form-1" class="mc4wp-form mc4wp-form-1527" method="post" data-id="1527" data-name="Get Started"><div class="mc4wp-form-fields"><div class="input-group"> <div class="input-icon"><i class="far fa-paper-plane"></i></div> <input type="email" placeholder="Your email address" class="form-control" name="email" data-error="e-mail field is required" required=""> <button type="submit" value="Subscribe" class="item-btn">Subscribe</button> </div></div><label style="display: none !important;">Leave this

Control/Customize Component name minification in Production React

Image
Background I often use " React Developer Tools " to understand the component structure of various website that I like and take inspiration from. Though, lot of websites have random names for the components, few websites have distinguishable names which can be helpful for aspiring React Developers or hobbyists. One such website is https://www.joshwcomeau.com . Below is a screenshot from one of the pages in his website. The name of few of the components explains itself what it is going to render. And since this is his blog, where he talks about various tips and tricks for React Development, it becomes helpful to have a look at this. Question Now when I develop a website using create-react-app( CRA ), all my component names are minified to a couple of random letters by Webpack. How can I control this behavior? Note: My main question is - How to control this behavior in any React application (not just CRA ). I know that Josh uses Next.js for his blog, so does any framework li