Posts

Showing posts from February, 2021

How do I make make multiple RecyclerViews for with the same data?

I created a calendar app that stores tasks as well as their description and time . It makes use of a RecyclerView to arrange the given data. But I want to create a new RecyclerView that can retrieve this same data and display it on the activity_main layout as a listview . Like the arrow shows on the picture, that's where I want to display the listview Would I need to create another RecyclerView or make use of the one I have? How can I achieve it? Please respond as soon as possible. Thank you very much. from Recent Questions - Stack Overflow https://ift.tt/37P5x6n https://ift.tt/eA8V8J

Return every row that contains the most occurring value

Image
This question may seem similar to a common question that asks to return the most occurring value. However, I need to list every row containing the value that occurs most often. In my example there is a zipCode that appears 3 times (the most out of any zip code). I would like to list every occurrence of that zip code without having to know which zip code has the most occurrences at the time of the query. My Query: SELECT *, COUNT(zipCode) AS NumOccurrences FROM customers GROUP BY zipCode ORDER BY NumOccurrences DESC LIMIT 1 Returns: What I want to return: Without using this query obviously: SELECT * FROM customers WHERE zipCode = 10001 I want to return each of the 3 occurrences of that zip code and not just the first instance of it. Without having to use the query above because I may not now which zip code occurs the most at the time of the query. from Recent Questions - Stack Overflow https://ift.tt/3dRslpV https://ift.tt/37VfIWT

DevExpress components require ASPxHttpHandlerModule registered in the web.config file

Image
My friend has created a project in asp.net and I am trying to run one of its '.aspx' pages on my side in Visual Studio 2019 but it is giving me this error when I run the project: DevExpress components require ASPxHttpHandlerModule registered in the web.config file. Full exception: He is using DevExpress controls; I have downloaded DevExpress 20.2 and my web.config is also all set, but when I try to run it's giving me the same error. Here is my web.config file: <?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit https://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <configSections> <sectionGroup name="devExpress"> <section name="themes" type="DevExpress.Web.ThemesConfigurationSection, DevExpress.Web.v20.2, Version=20.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d7...

Add Network Image to Flutter BottomNavigationBar (google_nav_bar)

i am using google_nav_bar.dart package for BottomNavigationBar. And, I want to use Network Image as icon in it. I tried a lot of resources but nothing is working. Please help me out. Package: https://pub.dev/packages/google_nav_bar My Code Snippet where I want to use NetworkImage. GButton( icon: LineIcons.user, text: 'Profile', ), from Recent Questions - Stack Overflow https://ift.tt/3uE063X https://ift.tt/eA8V8J

Insert to Multiple tables using Select statment?

I am trying to do mysql copy & paste statement. I have MySQL table like this: Table 1: Employee empid F_Name L_Name Email 1 Nitin Varpe fedexnit@gmail.com 2 Prashant Bankar pbankar@yahoo.com Table 1: salary salaryid empid Month Salary 1 1 Feb 2021 fedexnit@gmail.com 2 2 Feb 2021 pbankar@yahoo.com Suppose if I click copy and paste button I should get following output: Table 1: Employee empid F_Name L_Name Email 1 Nitin Varpe fedexnit@gmail.com 2 Prashant Bankar pbankar@yahoo.com 3 Nitin Varpe fedexnit@gmail.com 4 Prashant Bankar pbankar@yahoo.com Table 1: salary salaryid empid Month Salary 1 1 Feb 2021 1000 2 2 Feb 2021 2000 3 3 Feb 2021 1000 4 4 Feb 2021 2000 It should insert to the same table with different id. I used INSERT INTO Employee SELECT stat...

Mocha sidebar vscode extension is not auto refreshing the tests

I have just installed the mocha-sidebar extension in vs code. I am using the following config in my settings.json file: { "mocha.files.glob": "test/**/*.spec.js", "mocha.requires": [], "mocha.env": { "NODE_ENV": "test" }, "mocha.sideBarOptions": { "lens": true, "decoration": true, "autoUpdateTime": 1000, "showDebugTestStatus": true } } If I click the green play button in the extension window it runs the tests correctly and shows the results in the sidebar. If I now update the test to make it fail the previously green circle next to the test changes to yellow, but nothing else happens. I would expect the test to be shown with a red circle (failing), I would also expect the test in the test file to have a red dot next to the failing test, but this remains green. I have to run the tests by pressing the green play button again from the sidebar. The other...

How do I suppress expected Axios error messages when testing error states with react-testing-library?

I'm working on adapting some React code of mine to use @testing-library/react , react-query , and msw to mock network calls that I make using axios . So far (after some brainbending) I've got it working with this code! (yay!) The test in question (simplified): import React from 'react'; import { rest } from 'msw'; import { setupServer } from 'msw/node'; import { screen, waitFor, waitForElementToBeRemoved } from '@testing-library/react'; import { queryCache } from 'react-query'; import userEvent from '@testing-library/user-event'; import Login from '../Login'; import { render, queryClient } from '~/testhelpers/helpers.integration'; // #endregion imports const server = setupServer( // ...default setup for successful request; not relevant here ); beforeAll(() => server.listen()); afterEach(() => server.resetHandlers()); afterAll(() => server.close()); describe('rendering', () => { des...

React Native Firebase Cloud Messaging throwing errors on build for RN 0.63.4

I followed the instructions from here but the compilation is showing these errors. I'm guessing it's some sort of version incompatibility, but I believe I'm on the latest version of react-native-firebase . When I build the app, these errors show up: ❌ /Users/matt/Desktop/myapp/node_modules/react-native-firebase/ios/RNFirebase/messaging/RNFirebaseMessaging.m:91:51: expected a type - (void)applicationReceivedRemoteMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage { ^ ❌ /Users/matt/Desktop/myapp/node_modules/react-native-firebase/ios/RNFirebase/messaging/RNFirebaseMessaging.m:99:28: expected a type didReceiveMessage:(nonnull FIRMessagingRemoteMessage *)remoteMessage { ^ ❌ /Users/matt/Desktop/myapp/node_modules/react-native-firebase/ios/RNFirebase/messaging/RNFirebaseMessaging.m:278:50: expected a type - (NSDictionary*)parseFIRMessagingRemoteMessage:(FIRMessagingRemoteMessage ...

error: no match for call to '(const std::ranges::__sort_fn)

I was practicing vectors and ranges in c++ 20 was stuck at following state. #include <iostream> #include <vector> #include <random> #include <ranges> #include <algorithm> namespace ranges = std::ranges; struct Model { double next_event_time; }; std::vector<Model> generate_examples(int number) { // A uniform random number generator object // Used as the source of randomness std::default_random_engine generator; // Calls () operator on generator to get uniformly-distributed integers // then transforms the obtained values to output the disired distribution // Will uniformly generate values between 0 ~ 1 std::uniform_real_distribution<double> distribution(0.0, 1.0); std::vector<Model> models; for (auto i = 0; i < number; i++) { models.push_back(Model{.next_event_time = distribution(generator)}); } return models; } Model get_next_model(const std::vector<Model> ...

How to change generated thumbnail color profile

Image
In my iOS app, I'm recording a video. Later I'm generating a thumbnail from that video and saving it on device. My code looks like this: let asset = AVAsset(url: videoUrl) let imageGenerator = AVAssetImageGenerator(asset: asset) imageGenerator.appliesPreferredTrackTransform = true imageGenerator.maximumSize = CGSize(width: 1280, height: 720) let image = try imageGenerator.copyCGImage(at: thumbnailTime, actualTime: nil) let thumbnail = UIImage(cgImage: image) let jpgData = thumbnail.jpegData(compressionQuality: 0.8) try jpgData!.write(to: thumbnailUrl!) The saved image looks good, but it has a color profile set to QuickTime 'nclc' Video (1,1,6) I'm doing exactly the same thing in the Android app, and there color profile is set to sRGB How can I generate a thumbnail on iOS that will have a color profile set to sRGB instead of `QuickTime 'nclc' Video (1,1,6)'? from Recent Questions - Stack Overflow https://ift.tt/37WjsaR https://ift.tt/37Qp6Ll

NameError: name 'mNewCal' is not defined issue

Im having some issue with my code. Im not really sure what's wrong with it. Thank you if mNewCal or fNewCal < 1200: NameError: name 'mNewCal' is not defined sorry if the format is a little weird, stack overflow made it weird. gender = int(input("enter your gender as a number from the following \n Male: 1 \n Female: 2 \n " )) height = int(input("Please enter your height in inches: ")) age = int(input("Please enter your age: ")) weight = int(input("Enter your weight in lbs: ")) exercise = int(input("How much exercise do you do during the week (enter number) \n little to no: 1 \n light: 2 \n moderate: 3 \n heavy: 4 \n ")) if gender == 1: mBMR = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age) elif gender == 2: fBMR = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age) if gender == 1: if exercise == 1: cal = mBMR * 1.2 elif exercise == 2: cal = mBMR * 1.375 elif exercise == 3: ...

How can I build a docker image with it parent folder as workdir?

This probably is a dumb question, but I'm newbie in Docker and I'm struggle with this. I have a project with many subfolders, like the example below: project-folder: folder_1: code1.py Dockerfile requirements.txt folder_2: code2.py Dockerfile requirements.txt folder_data: file1 file2 file3 Then, I would like to do this: Maintain my workdir in project-folder for all containers; Inside each container, I should be able to access the folder_data - I know that I have to specify a volume, I just don't know how to do this without keep my project-folder as workdir; I need to pass my workdir ( project-folder ) to my code1.py Note: my image was created successfully only when I create it within each subfolder, like this Dockerfile: FROM python:3.6-slim COPY . /folder_1 WORKDIR /folder_1 RUN pip install -r requirements.txt CMD ["python3", "c...

a program to change letters in DNA nucleotide

I'm making a program to change the sequence of DNA. When finding the letter "a", replace it with a "t", and opposite. But I've encountered a problem cause when the program runs, it replaces "a" with "t", then replaces "t" with "a" again. How can I fix that? The code: def opposite_nucleotide(dna): dna = dna.replace("a", "t") dna = dna.replace("t", "a") dna = dna.replace("g", "c") dna = dna.replace("c", "g") return dna dna3 = input("Enter the DNA to represent it's oppsite one: ") dna4 = opposite_nucleotide(dna3) print(dna4) from Recent Questions - Stack Overflow https://ift.tt/2ObEJGf https://ift.tt/eA8V8J

Send data from a check label

Good day, I've the following problem, I'm making a form that I sent the data to a Gmail email, the problem is that when choosing a plan, the page throws an error. The mail arrives without any inconvenience and the selected plan but, the page remains with the error. Here I take the data and organize it to be prepared to be sent to Gmail. I'm using the PHPMailer library $mail->Body = "<h3>Nombre : $nombre <br>Empresa : $empresa <br>Direccion : $direccion <br>Contacto: $contacto <br>Email: $email <br>Ciudad : $ciudad <br>PlanA : $planA <br>PlanB : $planB <br>PlanC : $planC <br>PlanD : $planD </h3>"; This is the error that marks the page And This is what I have in the HTML part When sending them, the error on the page jumps. Is there any way to fix it? from Recent Questions - Stack Overflow https://ift.tt/3uOzWM2 https://ift.tt/eA8V8J

Using System.Random over multiple data types - the Haskell way?

I'm trying to learn Haskell in the most "Haskell way" possible, so I'm trying to avoid things like dos and lets that sort of obscure what's actually going on. So I have a data type called Org that in is defined as so: data Org = Org { pos :: Pos2D , color :: Color } deriving (Show) where Color and Pos2D are defined as so: -- Not actually defined like this, it's Graphics.Gloss.Data.Color data Color = Color Float Float Float Float data Pos2D = Pos2D Float Float Now I've implemented UniformRange for Pos2D and Uniform for Color as so: instance UniformRange Pos2D where uniformRM (Pos2D x1 y1, Pos2D x2 y2) g = Pos2D <$> uniformRM (x1, x2) g <*> uniformRM (y1, y2) g instance Uniform Color where uniformM g = G.makeColor <$> uniformRM (0.0, 1.0) g <*> uniformRM (0.0, 1.0) g <*> uniformRM (0.0, 1.0) g <*> return 1.0 Given a tuple o...

Placing items below category in template

So I wrote a small shopping list application using Django. Users may enter their desired items which are stored in a database alongside a category they reside in to make the list presented to the user more clean and giving them (the users) a good overview of what they are going to buy. The goal is to show the user a list which is categorized, something like this: VEGETABLES Paprika Tomatoes VARIOUS Toothpaste Toilet Paper And so on. I have like five categories saved in my database and users may choose one corresponding category once they add an item to the list below which the item will be displayed in the list. These are my database models: from django.db import models class Category(models.Model): name = models.CharField(max_length=20) tag = models.CharField(max_length=2) def __str__(self): return self.name class Item(models.Model): text = models.CharField(max_length=40) count = models.CharField(max_length=100) category = models.Foreign...

MSVC cannot return an object that can be copied but cannot be moved

While fiddling around with copy elision I came across this strange behavior: class Obj { public: Obj() = default; Obj(Obj&&) = delete; Obj(const Obj&) { std::cout << "Copy" << std::endl; } }; Obj f1() { Obj o; return o; // error C2280: move constructor is deleted } Obj f2() { Obj o; return Obj(o); // this however works fine } int main() { Obj p = f1(); Obj q = f2(); return 0; } GCC and Clang accept this code and are able to use copy elision in both cases. In f1() MSVC complains that it cannot return o because the move constructor of Obj is deleted. However, I would expect it to be able to fall back on the copy constructor. Is this a bug in MSVC or is this desired behavior (that I don't understand) and GCC / Clang are too permissive? If I provide a move constructor, MSVC is able to elide the move when compiling as Release . Interestingly MSVC is able to compile f2() . As far as I understand this is due to the mandat...

Parsing a function call (e.g. `exp '(' exp ')'`) in Bison: results in shift/reduce errors (precedence issue)

I'm trying to parse a function call (currently just one argument, but I'll allow for several when I get it working). Suppose exp is defined as %left '+' %precedence CALL exp: exp '+' exp { ... } | exp '(' exp ')' %prec CALL { ... } | LITERAL { ... } ; This creates an ambiguity. If I use -Wcounterexamples then it says that exp '+' exp · '(' exp ')' could be parsed in 2 ways, either shifting or reducing at the '(' . calc.y: warning: shift/reduce conflict on token '(' [-Wcounterexamples] Example: exp '+' exp • '(' exp ')' Shift derivation exp ↳ exp '+' exp ↳ exp • '(' exp ')' Example: exp '+' exp • '(' exp ')' Reduce derivation exp ↳ exp '(' exp ')' ↳ exp '+' exp • It appears that it doesn't know that a call should have a precedence that is...

Discord bot crashes when message contain mention

undefined:1 (@!310599774002872330) ^ SyntaxError: Invalid or unexpected token Commands work fine but whenever it involves a mention/ping it crashes the bot and spits out the above error. from Recent Questions - Stack Overflow https://ift.tt/3b1xk5G https://ift.tt/eA8V8J

Problem applying Decorator Design Pattern to JavaScript code

I have a class named Calculation which I added two functions are addOperationToName() and sayOperation() as examples of the Decorator design pattern. However, when I test it using Jest, I got an error that 'fn is not a function'. Can someone help me? Calculation.js class Calculation { constructor(a, b, op) { this.a = a; this.b = b; this.op = op; } static Create(a, b, op){ return new Calculation(a, b, op); } GetResults() { return this.op(this.a,this.b) } addOperationToName(fn){ return function(name){ const operation = name + ' is a operation'; fn(operation); } } sayOperation(name){ console.log(name); } } module.exports = Calculation; Calculation.test.js const Calculation = require('../src/models/Calculation'); test('Test say name for Product operation', () => { let op = Product; let calculation = new Calculation(1,2,op); let sayTest = calculation.addOperationToName(calculation.sayOperation()); e...

Discord.py copy and paste channels command

@commands.command() @commands.has_guild_permissions(administrator=True) async def copy(self, ctx): if str(ctx.author.id) not in Server.server_data: Server.server_data[str(ctx.author.id)] = Server.create_new_data() if str(ctx.author.id) in Server.server_data: Server.server_data[str(ctx.author.id)] = Server.create_new_data() channels = ctx.guild.text_channels Server.server_data[str(ctx.author.id)]["Channels"].append(str(channels)) embed=discord.Embed(color=discord.Color.blue(), description = f"{ctx.guild.name}'s channels has been saved.") await ctx.send(embed=embed) @commands.command() @commands.has_guild_permissions(administrator=True) async def paste(self, ctx): embed=discord.Embed(color=discord.Color.blue(), description = "All channels have been pasted") channel = Server.server_data[str(ctx.author.id)]["Channels"] ...

How can i disable a TaskQueues or TaskRouter from the web

I am using Twilio TaskRouter. And sometimes, i needed a way to stop a queue from functioning. Is there a way to disable a TaskQueues or TaskRouter from the web? from Recent Questions - Stack Overflow https://ift.tt/2ZYOKcy https://ift.tt/eA8V8J

npm run dev error (django/react/webpack/babel)

I'm following a code along of a django with react project and have run in to an error(s) that I can't get past. When I run npm run dev I get the error: ERROR in ./portfolio/frontend/src/index.js 1:0-35 Module not found: Error: Can't resolve './components/App' in '/home/anthony/Desktop/playground/portfolio/portfolio/frontend/src' resolve './components/App' in '/home/anthony/Desktop/playground/portfolio/portfolio/frontend/src' using description file: /home/anthony/Desktop/playground/portfolio/package.json (relative path: ./portfolio/frontend/src) using description file: /home/anthony/Desktop/playground/portfolio/package.json (relative path: ./portfolio/frontend/src/components/App) no extension /home/anthony/Desktop/playground/portfolio/portfolio/frontend/src/components/App doesn't exist .js /home/anthony/Desktop/playground/portfolio/portfolio/frontend/src/components/App.js doesn't exist .json ...

Reduce bundle size of lodash

Is this correct to create a file in which I'll put all imports? // lodash-helper.js export const isEqual = import('lodash/isEqual'); export const includes = import ('lodash/includes'); export const filter = import ('lodash/filter'); // some-file.component.ts import { isEqual } from 'src/core/helpers/lodash-helper'; // In this file I need only one import from Recent Questions - Stack Overflow https://ift.tt/2O93nY0 https://ift.tt/eA8V8J

What's the ideal way to handle SSL Subject Alternative Names in a CAA record?

Suppose I want to request an SSL certificate from "Example CA" with the following domain names on it: Subject Name: foocorp.com Subject Alt Name: www.foocorp.com Subject Alt Name: images.foocorp.com Subject Alt Name: foocorp.net Subject Alt Name: *.foocorp.net Subject Alt Name: foocorp.biz Subject Alt Name: *.foocorp.biz If I wanted to implement CAA for this certificate, I could see a few ways to construct the DNS records to permit issuance. But it's not immediately clear if each method will work correctly for each domain. Here are the variants I've considered, and my thinking for each. #1: Only implement the record for the domain listed as the Subject Name. If that's all the CA checks, that's all we need: foocorp.com. IN CAA 0 issue "ca.example.com" I have a sneaking suspicion that this won't work, and we have to add CAA records to everything listed in the SAN list for the certificate to be issued. If that's ind...

WebdriverIO version 7, using @cucumber/cucumber v7, using junit v7, the count of tests is not updating

Upgraded to Version 7 for WebdriverIO. In the process upgraded the cucumber framework as well to ver 7 "@wdio/cucumber-framework":"^7.0.7", After upgrading noticed that the test counts are not updating. Unable to use junit reports with Jenkins. I could only get it to work if I downgraded cucumber from version 7 to 6. Using 6.11.1 and it works fine now. Anyone facing same issue? Bit surprising on the official page also - the test counts are showing 0 for examples. tests="0" failures="0" errors="0" skipped="0" Am I missing something here? https://webdriver.io/docs/junit-reporter/ from Recent Questions - Stack Overflow https://ift.tt/3kq6kzM https://ift.tt/eA8V8J

Obtaining eBay OAuth access code after user clicks

So, I am trying to obtain the eBay OAuth access_token into my React app and have gotten stuck because I don't know how to get that back to my app once the access_token comes through. I have created a page in React with a button meant to display an eBay OAuth link after user clicks. However, I am doing all this testing from my local machine, namely localhost:3000 (frontend) and localhost:8000 (express backend). And to bypass the https requirement by ebay (I am using http://localhost:8000 which is a no-no for the eBay redirect url), I am using ngrok to produce links that look like https://8e37hhnc176c.ngrok.io/ which go in the ebay RuName settings. All is well and good until I have to obtain the access_token because by clicking the link created by clicking that initial button, it opens a new page that I cannot access the localstorage or cookie for. I am at a loss as to how to get this back to my redux React frontend app. I thought about having it write this token to a temp file...

How to add cargo (or any executable) to path in Dockerfile for subsequent build steps?

I have the following snippet in my Dockerfile: RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y RUN USER=root cargo new --bin foobar The problem is, the 2nd RUN fails because cargo is not in the path. Is there a way to fix this? I've tried setting the path like this (inspired by this answer ): ENV PATH $HOME/.cargo/.bin:$PATH but this doesn't seem to do the trick from Recent Questions - Stack Overflow https://ift.tt/3sJEH7R https://ift.tt/eA8V8J

Can not convert from String to LocalDate in java

Hello I here for a DateTimeFormatter problem with the language, let me introduce you: I'm reading a CSV file with this String Format: "dd-MMM-yyyy" <--> "28-dic-2017" Then i have to parse each string from a list to LocalDate to handle each with timeAPI methods. When Executed it returns: Exception in thread "main" java.time.format.DateTimeParseException: Text '28-dic-2017' could not be parsed at index 3 at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2051) at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1953) at java.base/java.time.LocalDate.parse(LocalDate.java:429) at com.examen.Presentation.Principal.parseDate(Principal.java:28) at com.examen.Presentation.Principal.main(Principal.java:19) public static LocalDate parseDate(String fecha) { Locale loc = new Locale("es", "ES"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(...

clang-tidy does not recognize standard libraries

I have a simple program that compiles and runs successfully, but I can't get clang-tidy to work. My program: #include <iostream> int main() { return 0; } CMakeLists.txt: cmake_minimum_required(VERSION 3.1) project(myProg CXX) set(CMAKE_CXX_COMPILER "/usr/bin/clang++") set(CMAKE_CXX_STANDARD 14) add_executable(myProg test.cpp) I produce a compile_commands.json using -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to be used with clang-tidy: [ { "directory": "/Users/me/myProj/build", "command": "/usr/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.15 -o CMakeFiles/myProg.dir/test.cpp.o -c /Users/me/myProj/test.cpp", "file": "/Users/me/myProj/test.cpp" } ] This compiles and runs successfully. Now, when I run clang-tidy -p=/Users/me/myProj/build /Users/me/myProj/test.cpp , I get this: test.cpp:1:10: error: ...

Assignment of an array in node.js to process.env variable results in String

When I assign an array variable to say process.env.deviceData , it changes to String. Example: $ node Welcome to Node.js v14.15.5. Type ".help" for more information. > result=['1','2','3'] [ '1', '2', '3' ] > process.env.deviceData=result [ '1', '2', '3' ] > console.log(process.env.deviceData) 1,2,3 undefined > console.log(result) [ '1', '2', '3' ] undefined > typeof process.env.deviceData 'string' > typeof result 'object' Is above expected? If yes, how can I assign array variable to process.env.deviceData ? from Recent Questions - Stack Overflow https://ift.tt/3sA914m https://ift.tt/eA8V8J

MIPS Swapping Operation

Say I have an array with 10 elements and assume the $s1 register is already loaded with the base address. How would I write a simple operation that will swap A[4] and A[9]? So far i've come up with something which consists of using a temp register, but i'm not sure if its correct: lw $t0, 4($s1) sw 4($s1), 9($s1) sw 9($s1), $t0 from Recent Questions - Stack Overflow https://ift.tt/3ktjdcr https://ift.tt/eA8V8J

How to take fs.createWriteStream and upload it to Gapi google drive api create function?

I have a chrome extension that takes file information from a backend node.js server in order to serve google drive files up within the extension. What I am having trouble with in this specific instance is uploading a file saved on the backend to a gapi client on the front end that allows a user to upload it to their google drive. The authentication and everything is fine, the main problem is the upload. Here is my code. background.js(client side): var parentFolder; var fileArray; let classroomUrl = 'https://connect.smartpathed.com/getclassroomparent'; await fetch(classroomUrl) .then(response => response.text()) .then(data => parentFolder = data) .then(data => console.log(parentFolder)); let fileArrayUrl = "https://connect.smartpathed.com/getclassroomarrayselect"; await fetch(fileArrayUrl) .then(response => response.json()) .then(data => fileArray = data) .then(data => console.log(fileArray)); function sleep(milliseconds) ...

Float Property does not work after applied to the html file?

I am trying to make the navigation menu a left vertical menu. But instead of becoming a vertical menu, it look like this: https://i.stack.imgur.com/7J4tS.png[1] . The selector is linked to the right id and tag in the HTML file. Below I have attached the css file. What may the potential issue that cause the float property no working properly on my page. CSS File: * { margin:0; } body { text-align: center; background-color: #f4e1d2; /*change the the background color of the entire page*/ font-family: papyrus, copperplate, serif; } #nav { /*navigation menu*/ background-color: #f18973; height: 80px; /*display:flex; align-items: center;*/ } header { padding: 2.5%; text-align: center; background-color:#bc5a45; } h1 { margin-bottom: 3%; margin-top: 5%; color: #bc5a45; font-size: calc(2px + 2vw); } h2 { margin-top: 3%; margin-bottom: 1%; color: #bc5a45; font-size: calc(5px + 1vw); } h3 { color...

How to search value in Dataset

My Dataset< Row > (java spark) input is : Heros Powers Rank Superman Invisible 1 Batman Strength 2 SpiderMan Strong 3 By knowing the name of my heros, i would like to retrieve the rank. For exemple for Superman, i would like to have the return 1, not all the line but just the value. I don't know how to do by using a spark dataset. Thank for your help ! from Recent Questions - Stack Overflow https://ift.tt/3dRPSqv https://ift.tt/eA8V8J

Slicing and performance

It might be that I don't understand slicing that well. I want to add one list from a particular index to another list. I was wondering, because I read that if you slice a list that you make a (deep)copy of it, which method is faster: method 1 new_lst += old_lst[i:] method 2 while i < len(old_lst): new_list.append(old_lst[i]) i += 1 from Recent Questions - Stack Overflow https://ift.tt/3bNm0cx https://ift.tt/eA8V8J

Getting class atributte in method in python

I have this class and method: class Person(object): def __init__(self, name): self.name = personname self.surname = personsurname def changenameorsurname(self, x, y): self.x = y return AdamSmith = Person ("Adam", "Smith") I want to use method changenameorsurname to change AdamSmith's name or surname but if I use this code I'm getting name error. AdamSmith.changenameorsurname(personname, Dave) Name Error: name personname is not defined. Is there elegant way to reference personname in code like this? Or do I have to make two separate methods like this: def changename(self, y): self.name = y return AdamSmith.changename(Dave) from Recent Questions - Stack Overflow https://ift.tt/3aYfkZV https://ift.tt/eA8V8J

How to change an object attribute inside of a setTimeOut call [duplicate]

I'm creating a "simulation" as a practicing using HTML, CSS and Javascript objects. It's a simulation of testing a smartphone class smartphone { constructor(name, color, weight, screenResolution, camResolution, ram) { this.name = name; this.color = color; this.weight = weight; this.screenResolution = screenResolution; this.camResolution = camResolution; this.ram = ram; this.on = false; } And I'm creating a method which "simulates" the startup of a smartphone: turnOn(){ if (this.on == false){ document.getElementById("status").innerHTML = "Turning on..."; document.getElementById("status").classList.remove("off") document.getElementById("status").classList.add("on") setTimeout(function(){ this.on = true; //Line 26 alert(`${this.name} is on.`) //Line 27 document.getElementById("img").src = "xperia.p...

why command are not recognized by the command prompt?

I have tried several times to type the command 'ls' at the command prompt of Windows 10 but it shows me that the command is not recognized as an internal or external command, an executable program or a batch file. from Recent Questions - Stack Overflow https://ift.tt/3su1unO https://ift.tt/eA8V8J

How to upload large file (~100mb) to Azure blob storage using Python SDK?

I am using the latest Azure Storage SDK (azure-storage-blob-12.7.1). It works fine for smaller files but throwing exceptions for larger files > 30MB. azure.core.exceptions.ServiceResponseError: ('Connection aborted.', timeout('The write operation timed out')) from azure.storage.blob import BlobServiceClient, PublicAccess, BlobProperties,ContainerClient def upload(file): settings = read_settings() connection_string = settings['connection_string'] container_client = ContainerClient.from_connection_string(connection_string,'backup') blob_client = container_client.get_blob_client(file) with open(file,"rb") as data: blob_client.upload_blob(data) print(f'{file} uploaded to blob storage') upload('crashes.csv') from Recent Questions - Stack Overflow https://ift.tt/37PUuK2 https://ift.tt/eA8V8J

lm formula: the difference between `as.factor()` and `as.as.character()`

I was wondering why factor(gpid) doesn't work like as.character(gpid) in my manova() call below? data <- read.csv("https://raw.githubusercontent.com/rnorouzian/v/main/df.csv") # gpid anx socskls assert #1 1 5 3 3 #2 1 5 4 3 #3 1 4 5 4 summary(manova(cbind(anx,socskls,assert) ~ factor(gpid), data = data)) # Df Pillai approx F num Df den Df Pr(>F) #gpid 1 0.073734 0.7695 3 29 0.5205 But when I change gpid to character the output is what it should be: summary(manova(cbind(anx,socskls,assert) ~ as.character(gpid), data = data)) # Df Pillai approx F num Df den Df Pr(>F) # as.character(gpid) 2 0.62209 4.3642 6 58 0.001058 ** from Recent Questions - Stack Overflow https://ift.tt/3b2X8hP https://ift.tt/eA8V8J

Applying .get() function On a Pandas series

I am working on sample dataset to retrieve location information from address(some details are changed for identification purpose); temp2=pd.DataFrame({'USER_ID':[1268,12345,4204,4208], 'IP_ADDR':['142.176.00.83','24.000.63.230','187.178.252.99','187.178.250.99']}) My goal is to get Lattitude and longitude information using the ip2geotools python package. The syntax is follows; !pip install ip2geotools response = DbIpCity.get(a, api_key='free') json_file = response.to_json() where a='142.176.00.83' . Then we get a JSON file like this; '{"ip_address": "142.176.00.83", "city": "Charlotte", "region": "Prince Edward", "country": "CA", "latitude": 46.2, "longitude": -63.131}' I am trying to apply the function on an entire pandas series (vectored form) and retrieve latitude and longitude as two different columns. Her...

StatusCode 400 Bad Request in Entity Framework

I have this function for returning a list of decks in my DeckController that sends a request to my GetDecks function in my DeckDataController that works as expected. However when I try adding other methods I get a status code 400 bad request. //DeckController.cs // GET: Deck/List /// <summary> /// Get a list of all Decks /// </summary> /// <returns>returns a list of Decks</returns> public ActionResult List() { // api string string url = "DeckData/GetDecks"; //http request to the url HttpResponseMessage response = client.GetAsync(url).Result; Debug.WriteLine(response); if (response.IsSuccessStatusCode) { IEnumerable<DeckDto> Decks = response.Content.ReadAsAsync<IEnumerable<DeckDto>>().Result; return View(Decks); } else { return RedirectToAction("Error...

Removing elements from an array of records containing string fields?

Check the example below... I have an array TSrvClientList.Items with record elements. These elements have string fields. When I remove an element, I need to move the following ones in that empty space left. I don't like to copy field by field... And I thought I'd use the Move function to do it faster, but I'm not sure if this is a proper way to do it. If the record contained only unmanaged types, I'm sure it's OK, I uesed many times. But with those strings, I don't know... Should I call a Finalize first ? Or do it differently ? My test code seems it works as it is, directly moving those strings, but I'd like to make sure it's not just a coincidence. unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, SynCommons, System.SyncObjs, Vcl.StdCtrls; type TSrvClientInfo = record ClientIP: String; ClientGUID: Cardinal; AESKey: THa...

Flutter Geolocator 5.0.1 not working properly

Image
I'm having a problem with the flutter geolocator: ^5.0.1 dependencies. Bt it doesn't show the location also not showing any error. I have given permission in the manifest file also. I'm using flutter stable version 1.22.6 and for this project compile SDK version is 29. Manifest file: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />` Flutter Code for getting location: String specificAddress; try { Position position = await Geolocator() .getCurrentPosition( desiredAccuracy: LocationAccuracy.best); List<Placemark> placeMarks = await Geolocator() .placemarkFromCoordinates( position.latitude, position.longitude); Placemark mPlaceMark = pla...

trying to create a Discord webhook, with the avatar and username assigned inside the code

I am trying to create a Discord webhook, with the avatar and username assigned inside the code. This is the code I have so far. I have no idea what comes before or after this. { "username": "Webhook", "avatar_url": "https://i.imgur.com/4M34hi2.png", "content": "Text message. Up to 2000 characters.", } from Recent Questions - Stack Overflow https://ift.tt/3sxBY1a https://ift.tt/eA8V8J

How to center quantity and make buttons even - collection feature - shopify

Can anybody help me with the CSS that I need to center the quantity in my collection feature in Shopify? Also the shop buttons are kinda uneven. Does anybody know how to bring them in the same line? Here's an image: enter image description here from Recent Questions - Stack Overflow https://ift.tt/3bGHtn7 https://ift.tt/eA8V8J

Calculate average across all the branches for that day

Image
I am currently struggling on how to calculate average across all the branches. Like below you can see, call queue name is the unique name that has a call count for each day, multiple times a day. I want to calculate the average call count across all the call queue names for each day to compare individual call name across the average of all the call queue names. I am struggling for quite sometime and I was able to use averagex, Per_day_count = AVERAGEX(VALUES(fAgentTimelineAnalytics[Call Queue Name]), CALCULATE(COUNT(fAgentTimelineAnalytics[Call Count]))) Can someone please point me in the right direction. from Recent Questions - Stack Overflow https://ift.tt/2MuPT8O https://ift.tt/3dNQqxG

How can I modify my db for a Logistic regression in R?

I have the following fields in my database: record: row number Father: (1 to 7 values) Mother: (1 to 7 values) Age: 13, 14, 15 and 16 yo. Gender: Male/Female Suicide: (1/0 values) I'd like to create a ggplot from this logistic regression model where my response variable is Suicide vs Parent's education (Father & Mother) The plot has a straight line and not a curve as I expect, I'm using this code: ggplot( baseRL, aes(x=Father, y=Suicide)) + geom_point() + geom_smooth(data = baseRL, aes(x = Father, y = Suicide), method = "glm", method.args = list(family = "binomial"), se = FALSE) Is there another way to plot my objective? Thanks! from Recent Questions - Stack Overflow https://ift.tt/3qQDcE9 https://ift.tt/eA8V8J

Passing data to the keras model.fit() function more effficiently

I am training an LSTM wich on a time series. The input sequence has length 480, and I create my trainingsdata from a bigger timeseries array, where all the values are in the right order. I take blocks of length 480, starting at every possible position in the array and fill the container that will be passed to the model.fit() function with these blocks. But this is of course very inefficient as I need huge amounts of memory to train my model as the first sample contains values [0, 1, 2, ... , 479] and the second one values [1, 2, 3, ... , 480] and so on... When training im not able to fit all this (redundant) data into my RAM at once. Is there any way to solve this by using e.g. some kind of array that references the corresponding parts in the bigger timeseries array? Thanks for any help! from Recent Questions - Stack Overflow https://ift.tt/3r03u78 https://ift.tt/eA8V8J

Health probe says the endpoints (Azure Container Instances) are degraded

I have set up a health probe to ping Azure Containers from my load balancer so that requests are forwarded to only healthy nodes. However, I am getting "Degraded" status despite the containers being up and running. I am aware this has got to do with the reponse the health probe gets from the IP Address but I cannot figure out what changes do I need to make to my container settings to ensure that it works as expected from Recent Questions - Stack Overflow https://ift.tt/3kr48YU https://ift.tt/eA8V8J

Decimal tryparse doesn't parse decimal value

decimal.TryParse(".0005e+92", System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out decimal x) This returns false. What should I change? from Recent Questions - Stack Overflow https://ift.tt/37MxtHU https://ift.tt/eA8V8J

Create proportion of responses across columns

Hello lovely folks of stack overflow: i am a beginner in R and at the moment i'm trying to create a proportion for each participant in my study of how many close friends they have who are different from them over their total number of friends. My data from qualtrics is arranged so that participants were able to categorize up to 20 friends as "same" or "different", these responses are arranged in columns from Q34_1_44 to Q34_20_63. Of course not every participant had/rated the whole available 20 close friends, so many columns are almost all empty. Regardless i am trying to create another column that contains a numerical value that is equal to number of different friends/total (so blanks don't matter). i have tried the following (but got stuck as i realized this wasn't an appropriate function (or at least as far as i know): dataset.clean2 <- mutate(dataset.clean1, diff.friend=ifelse(Q34_1_44=="Different race",)) if anyone knows an easy...

New column in pandas df based on array

Say I have a df like the one below. num value 0 1 229 1 2 203 2 3 244 3 4 243 4 5 230 And an array: array([ 2, 4]) . I would like to create a new column for binary variable, such that it is 1 when num is equal to the value in the array and 0 otherwise. num value binary 0 1 229 0 1 2 203 1 2 3 244 0 3 4 243 1 4 5 230 0 Wanted to use: df["binary"] = np.where(df["num"] == dtemp.num.unique(), 1, 0) , where dtemp.num.unique() is the aforementioned array. But since the lengths of df and array are different - I get the "Lengths must match to compare" error. from Recent Questions - Stack Overflow https://ift.tt/3syheX3 https://ift.tt/eA8V8J

Ion.RangeSlider. Problem with parsing a value

Image
I have JS-Range Slider. I need to get min and max values from input, but I get an error in console when I I move the slider: The specified value "1000;2327" cannot be parsed, or is out of range." and etc <input type="number" class="js-range-slider" name="my_range" value="" data-min="100" data-max="4000" data-from="1000" data-to="2000" data-grid="true" /> Why is it happening? $(".js-range-slider").ionRangeSlider({ type: "double", prefix: '$', min: 100, max: 4000, from: 1000, to: 2000, values: [75, 300000] }); $(".filter-btn_send").click(function () { var min = $(".js-range-slider").slider("option", "min"); var max = $(".js-range-slider").slider("option", "max"); console.log("min: " + min + " max: " + max); }); ...

How to suppress KeyError in Python when dataframe is empty when mapping multiple Foursquare results and an API result is blank

I'm retrieving Foursquare venue data and plotting it on a Folium map. I'm plotting several API call results on the same map. When the API returns an empty JSON result because there are no queried venues within the search, it throws a KeyError because the code is referencing columns in the dataframe that doesn't exist, because the API result is blank. I want to continue to display the map with other results, and have the code ignore or suppress instances where the API result is blank. I've tried try/except/if to test if the dataframe is blank, though cannot figure out how to "ignore the blanks and skip to the next API result". Any advice would be appreciated. ## Foursquare Query 11 - name origin location address = 'Convent Station, NJ' ## Try "Madison, NJ" for working location example geolocator = Nominatim(user_agent="foursquare_agent") location = geolocator.geocode(address) latitude = location.latitude longitude = location.lon...