How to comment on .tsx file? Posted: 12 Jun 2021 10:11 AM PDT I want to comment TSX code that I showed below. How can I do that? <Form.Group controlId="type"> <Form.Label>Type</Form.Label> |
How to prevent overflow when when using animations Posted: 12 Jun 2021 10:11 AM PDT I have a container div with overflow: auto (this can't be removed) and within it there's another div that toggles between showing and hiding using an animation when a button is clicked. The problem is that when this div moves down it causes an overflow. Keep in mind that this div must be within the container. Example of the problem https://jsfiddle.net/wg3jzkd6/1/ The expected result: - Div moves down without causing overflow
|
Conditional counts in pandas group by Posted: 12 Jun 2021 10:11 AM PDT I have the following dataframe I want to reformat it in the following way: - Group by name/account/monthly periods
- Average (mean) balance to two decimal places
- Average (mean) for transactions to no decimal places
- Count of days where balance < 0
- Count of days where Balance > Max credit
So the I apply the following function to make a Series of all the aggregations, and use the Series index as labels for the new columns: def f(x): d = {} d['Avg_Transactions'] = x['Transaction'].mean().round() d['Avg_Balance'] = x['Balance'].mean().round(2) d['Zero_Balance_days'] = (x['Balance'] < 0).count() d['Over_Credit_days'] = (x['Balance'] > x['Max Credit']).count() return pd.Series(d, index=['Avg_Transactions', 'Avg_Balance', 'Zero_Balance_days', 'Over_Credit_days']) month = df.groupby(['Account','Name', 'Month']).apply(f) Which gives the following output: But I am getting the conditional counts wrong and instead counting all days. What would be the proper way to write these? |
Swift iOS 14 Firebase Warning - This Old-Style Function Definition Is Not Preceded By a Prototype Posted: 12 Jun 2021 10:11 AM PDT I have an app with Firebase integration to connect analytics using cocoapods. It was working well without any yellow warnings for iOS 13, but when I installed the new cocoa pods for target iOS 14 and build the app I get 6 yellow warning messages "XXXPods/GoogleUtilities/GoogleUtilities/Logger/GULLogger.m:130:20: This old-style function definition is not preceded by a prototype" When I was looking for answers online, there are only few and pointing to Flutter. I don't have Flutter for this app and I don't think I will be needing one. Does anyone else have the same issue? How can this be silenced for iOS 14 please? I can downgrade the pods to iOS 13 but the whole point was to update the version. Thank you for any help/direction |
Python adding outlook color categories to specific emails with a loop Posted: 12 Jun 2021 10:11 AM PDT I am trying to add color categories to existing emails in a given outlook folder based on criterias such as email object and/or sender email address. I found a way to do it with VBA but I would like to use python not sure if the code can easily be "translated" from VBA to python? import win32com.client as client import win32com import pandas as pd outlook = client.Dispatch("Outlook.Application").GetNamespace('MAPI') main_account = outlook.Folders.Item(1) second_account = outlook.Folders.Items(3) df = pd.read_excel (r'C:\Python\test.xls') df_outlook_folder = df['Outlook_folder'].tolist() df_mail_object = df['Mail_object'].tolist() out_iter_folder = main_account.Folders['Inbox'].Folders['TEST'] fixed_item_count = out_iter_folder.Items.Count item_count = out_iter_folder.Items.Count if yout_iter_folder.Items.Count > 0: for i in reversed(range(0,item_count)): message = out_iter_folder.Items[i] for y,z in zip(df_mail_object,df_outlook_folder): try: if y in message.Subject: message.Move(second_account.Folders['Inbox'].Folders['TESTED'].Folders[z] except: pass item_count = out_iter_folder.Items.Count print('Nb mails sorted:',fixed_item_count - item_count) the code above enables me to move emails based on the mail object but I am not able so far to add a feature to also change the outlook color categories I spent time on the following doc without success so far https://docs.microsoft.com/en-us/office/vba/api/outlook.categories Many thanks ! |
find cumulative number of shops of past 12 month in mongodb Posted: 12 Jun 2021 10:11 AM PDT I want to find the cumulative number of shops of past 12 month. Query must return result something like [{ date: 'Aug-2020', numShops: 100, // Total number of shops until aug-2020 }, { date: 'Sep-2020' numShops: 230, // Total number of shops until sep-2020 }, .... ] |
Change Products by Form in Django Posted: 12 Jun 2021 10:10 AM PDT I have two models about my products class Product(models.Model): product_model = models.CharField(max_length=255, default='', verbose_name="نام محصول") product_url = models.SlugField(max_length=200, default='', verbose_name="اسلاگ محصول" ) description = tinymce_models.HTMLField(verbose_name="توضیحات") size = models.ManyToManyField(Size , verbose_name="سایز", related_name="rel_size") ... class Size(models.Model): size = models.CharField(max_length=20) size_url = models.SlugField(max_length=200, default='', verbose_name="اسلاگ سایز") class Stock(models.Model): amount = models.PositiveIntegerField(verbose_name="موجودی انبار") product = models.ForeignKey(Product, on_delete=models.CASCADE, verbose_name="محصول") size = models.ForeignKey(Size, on_delete=models.CASCADE, verbose_name="سایز") product_price = models.FloatField(null=True, verbose_name="قیمت محصول") we have L M Xl XXL sizes and in views.py i have: def product_detail(request, product_url): if request.user.is_authenticated and request.user.is_staff or request.user.is_superuser: product = get_object_or_404(Product, product_url=product_url) stock = get_list_or_404(Stock, product=product) if request.method == "POST": amount = request.POST['amount'] price = request.POST['price'] stock.amount = amount stock.product_price = price stock.save() ctx = {'product':product, 'stock':stock} return render(request, 'staff/product_detail.html',ctx) else: return redirect('/staff') and my html : <div class="container-fluid"> {{product.product_model}} <br> <br> {% for sto in stock %} <form method="POST" class="register-form" id="register-form"> {% csrf_token %} <p>{{sto.size}}</p> <input type="text" value="{{ sto.amount | default_if_none:"" }}" name="amount" id="lo" placeholder="موجودی"/> <input type="text" value="{{ sto.product_price | default_if_none:"" }}" name="price" id="lo" placeholder="قیمت (تومان)"/> <br> <input type="submit" name="signup" id="signup" class="form-submit" value="ذخیره"/> </form> {% endfor %} <br> </div> My problem is that each size has own amount and price from a product, like each product has 1 or more size it can be one or more, how can I edit models by "for" in my html ? or any best other way? |
How can I design the code in VBA in order to refer to a previously already newly created workbook in Excel? Posted: 12 Jun 2021 10:10 AM PDT How can I refer in VBA to a previously newly created workbook within the same macro? For example, I copy something from A2 in the active workbook, then I create a new workbook, paste there in cell B3, return to the first workbook, copy cell A3, return again to the newly created workbook and paste in in cell B4. So, what I need is the code for this part of the sentence: "return again to the newly created workbook" My code till now is this: `Selection.Copy` `Workbooks.Add` `Range("B3").Paste` `Windows("First_WorkBook.xlsm").Activate` `Range("A3").Select` `Selection.Copy` The last two lines are missing: returning to the new workbook and pasting there. Can you please help me with this issue? |
How to make an outlier detection function from scratch? Posted: 12 Jun 2021 10:10 AM PDT I ve got some data on Premier League players and I want to check for outliers. Boxplots show several outliers in some variables. However, I have created a function to detect them into a list, but returns an empty outlier list: numeric_cols = [x for x in df if df[x].dtype != "object"] def outlierdetector(x): for i in x: mn = df[i].min() mx = df[i].max() iqr = stats.iqr(df[i]) outlier = [o for o in df[i] if o < mn or o > mx] print("COLUMN:", i,"\nMIN:", mn, " MAX:",mx," IQR:",iqr, "\nOutliers:", outlier, "\n\n") outlierdetector(numeric_cols) What is wrong with the function so that it does not return outlier values? Thank you |
Restore deleted script blocks Posted: 12 Jun 2021 10:10 AM PDT please help, I accidentally removed a huge portion of my codes in Google Script and accidentally saved it. Is there any way I can "Undo" and I get my previous version back? |
React and Springboot : axios requests not shown in browser devtools Posted: 12 Jun 2021 10:10 AM PDT I'm trying to follow a tutorial on React(frontend) and Springboot(backend) and I face a little problem when making an http POST request with Axios on Mozilla and Chrome. I try to post some data to a REST api that I set up and save it in an H2 in-memory database. If I use an HTTP client like Postman, it works fine but when I use a web browser as a client, here are some issues : - On Chrome, when I submit the form, I don't see any trace of the triggered request in the Network tab of the console while the data is saved in the database. I also have this browser error message when I run my React client :
- On Firefox, the request doesn't hit my rest controller endpoint and no data is persisted. But I get this error message
I configured my CORS, checked proxy config in package.json but I don't get what the issue is. my http post method called from my form component when submitted import axios from 'axios'; const API_URL = 'http://localhost:8080/api/v1'; export const signup = (user) => { const headers = {"Accept": "application/json", 'Content-Type': 'application/json'}; return axios.post(API_URL + '/auth/signup', user, {headers}) .then(res => console.log(res)); }; my package.json { "name": "project-frontend", "version": "0.1.0", "private": true, "proxy": "http://localhost:8080", "dependencies": { "@testing-library/jest-dom": "^5.11.9", "@testing-library/react": "^11.2.4", "@testing-library/user-event": "^12.6.3", "axios": "^0.21.1", "http-proxy-middleware": "^2.0.0", "react": "^17.0.1", "react-dom": "^17.0.1", "react-scripts": "4.0.1", "web-vitals": "^0.2.4" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] } } My rest controller package com.project.project.auth; import com.project.project.shared.HttpResponse; import com.project.project.user.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.logging.Logger; @CrossOrigin(origins = "http://localhost:3000") @RestController @RequestMapping("/api/v1/auth") public class AuthController { @Autowired private AuthService authService; public Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); @PostMapping("/signup") public HttpResponse signup(@RequestBody User user) { logger.info("AUTH_CONTROLLER : I'am in signup method"); authService.save(user); HttpResponse response = new HttpResponse("User saved succesfully !"); return response; } } |
Is there any solution for the following error ? Its actually while running the web app in shiny. Although i installed all the necessary packages Posted: 12 Jun 2021 10:10 AM PDT runApp() Warning: package 'shinyWidgets' was built under R version 3.6.3 Error: package or namespace load failed for 'shinyWidgets' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called 'bslib' |
How to run non-web docker container on AWS ECS Posted: 12 Jun 2021 10:10 AM PDT What I have are Python Scripts that listen to SQS and Process messages received from those.These are dockerized and uploaded to ECR. What the requirement is to run this docker on ECS using EC2 and Scale up/in based on the number of messages from sqs. The issue is I am not able to run the tasks defined, I think the reason for it is the health check is not set, so I set it to CMD_SHELL, ps aux | grep "Python" || exit 1 , but of no use can anyone help me with it. Also is it possible to run Non-Web application on ECS. If anyone has any documents please point me put to it. I am posting my container definition here i-00bd43d507b521acc { "ipcMode": null, "executionRoleArn": "arn", "containerDefinitions": [ { "dnsSearchDomains": null, "environmentFiles": null, "logConfiguration": { "logDriver": "awslogs", "secretOptions": null, "options": { "awslogs-group": "python-extract", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "ecs" } }, "entryPoint": [ "/bin/sh", "-c", "/tmp/bin/main" ], "portMappings": [ { "hostPort": 0, "protocol": "tcp", "containerPort": 80 } ], "command": null, "linuxParameters": null, "cpu": 256, "environment": [ ], "resourceRequirements": null, "ulimits": null, "dnsServers": null, "mountPoints": [], "workingDirectory": null, "secrets": null, "dockerSecurityOptions": null, "memory": null, "memoryReservation": 512, "volumesFrom": [], "stopTimeout": null, "image": "<docker-registery:latest>", "startTimeout": null, "firelensConfiguration": null, "dependsOn": null, "disableNetworking": null, "interactive": null, "healthCheck": { "retries": 3, "command": [ "ps aux | grep "python" || exit 1" ], "timeout": 5, "interval": 30, "startPeriod": 5 }, "essential": true, "links": null, "hostname": null, "extraHosts": null, "pseudoTerminal": null, "user": null, "readonlyRootFilesystem": null, "dockerLabels": null, "systemControls": null, "privileged": null, "name": "python-extract" } ], "placementConstraints": [], "memory": "1024", "taskRoleArn": "arn:aws:iam::<is>:role/ecsTaskRole", "compatibilities": [ "EC2", "FARGATE" ], "taskDefinitionArn": "<ecsTaskRole>", "family": "map-extractor", "requiresAttributes": [ { "targetId": null, "targetType": null, "value": null, "name": "com.amazonaws.ecs.capability.logging-driver.awslogs" }, { "targetId": null, "targetType": null, "value": null, "name": "ecs.capability.execution-role-awslogs" }, { "targetId": null, "targetType": null, "value": null, "name": "com.amazonaws.ecs.capability.ecr-auth" }, { "targetId": null, "targetType": null, "value": null, "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19" }, { "targetId": null, "targetType": null, "value": null, "name": "com.amazonaws.ecs.capability.docker-remote-api.1.21" }, { "targetId": null, "targetType": null, "value": null, "name": "com.amazonaws.ecs.capability.task-iam-role" }, { "targetId": null, "targetType": null, "value": null, "name": "ecs.capability.container-health-check" }, { "targetId": null, "targetType": null, "value": null, "name": "ecs.capability.execution-role-ecr-pull" }, { "targetId": null, "targetType": null, "value": null, "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18" }, { "targetId": null, "targetType": null, "value": null, "name": "ecs.capability.task-eni" }, { "targetId": null, "targetType": null, "value": null, "name": "com.amazonaws.ecs.capability.docker-remote-api.1.29" } ], "pidMode": null, "requiresCompatibilities": [ "EC2" ], "networkMode": "awsvpc", "cpu": "256", "revision": 6, "status": "ACTIVE", "inferenceAccelerators": null, "proxyConfiguration": null, "volumes": [] } Any suggestion on whether it's possible to run non-server containers on ECS would be of great help or any one has done it please let me know what should be the healtchecks |
Moshi parses List custom object to List that holds LinkedHashTreeMap Posted: 12 Jun 2021 10:09 AM PDT I have a list of custom objects that I want to parse and save in shared prefs. internal fun putObjects(key: String, item: List<Any>) { val listJson = toJson(item) edit { it.putString(key, listJson) } } internal fun <T> getObjects(key: String): List<Any> { val json = prefs.getString(key, "") ?: "" val objectList: List<Any>? = fromJson(json) return objectList ?: listOf() } Moshi builder is created like this: return Moshi.Builder() ... .addLast(KotlinJsonAdapterFactory()) .build() Expected result is ArrayList<XObject> , but instead Moshi returns ArrayList<LinkedHashTreeMap<String, String>> . |
Discord.py Sqlite Posted: 12 Jun 2021 10:11 AM PDT How can I save the count of guilds in sqlite? @commands.Cog.listener() async def on_guild_join(self,ctx, guild): self.client.warnings[guild.id] = {} db = sqlite3.connect("C:\\RDS\\Software\\Mythern\\Database\\database.sqlite") cursor = db.cursor() cursor.execute(''' CREATE TABLE IF NOT EXISTS guilds( guild_count TEXT ) ''') |
Using a Lambda function with a CloudFront distribution located in a different AWS account Posted: 12 Jun 2021 10:09 AM PDT I am wondering if a lambda function located in AWS account A can be used with a CloudFront distribution located in AWS account B. When I try, i get the following error. This leads me to think that it is probably not possible. But maybe it is a permission problem. com.amazonaws.services.cloudfront.model.InvalidLambdaFunctionAssociationException: The CloudFront distribution under account 999999888888 cannot be associated with a Lambda function under a different account: 999999666666. Function: arn:aws:lambda:us-east-1:999999666666:function:cf_test_lambda:2 (Service: AmazonCloudFront; Status Code: 400; Error Code: InvalidLambdaFunctionAssociation; |
Loop three lines and print horizontally from csv file in bash Posted: 12 Jun 2021 10:09 AM PDT I have been trying to print two lines from the csv file to print horizontally and loop the next two lines and try to do the same. The code which I have tried is while IFS=, read -r name code; do echo "$name" "$code" | head -2 | tr ' ' done < csvfile.csv The csv file contains Albany, N.Y Albuquerque, N.M. Anchorage, Alaska Asheville, N.C. Atlanta, Ga. Atlantic City, N.J. All I want is the output like Albany, N.Y. Albuquerque, N.M. Anchorage. Alaska. Asheville, N.C. Atlanta, Ga. and so on Can anyone help me with this. I have tried different ways as suggested online but still no luck and am a newbie in bash scripting. Any help would really be appreciated. Thank you |
how to check if a email is already in my database in python kivy app Posted: 12 Jun 2021 10:10 AM PDT main.py def email_validate(self, email): return_value2 = Database.validate() print(email) df1 = pd.DataFrame(return_value2) print(df1) if email != "": for items in df1 == email: content_box = BoxLayout(orientation="vertical", padding=40) content_box.add_widget(Label(text="this email is taken")) return_button = Button(text="Return", size_hint=(0.8, 0.4), pos_hint={'center_x': .5, 'center_y': .5}) content_box.add_widget(return_button) popup_window = Popup(content=content_box, title="Error!", size_hint=(None, None), size=(200, 200)) return_button.on_release = popup_window.dismiss popup_window.open() |
Open SQLite connection in UWP right after moving StorageFile Posted: 12 Jun 2021 10:10 AM PDT Prologue: I am writing SQLite GUI client for UWP. I use Microsoft.Data.Sqlite library for SQLite API with C#. Also I use a redirection table to be able to open database within my sandbox app which is published in Microsoft Store. Redirection table replaces CreateFileW to CreateFileFromAppW calls and similar. Problem: User has File -> Save as feature. When user creates a new database file is created inside app local directory. Next when user saves his/her database as I need to move this file. I use StorageFile API cause I cannot use any other file API within a sandbox app. So I call: var savePicker = new Windows.Storage.Pickers.FileSavePicker(); savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary; savePicker.FileTypeChoices.Add("SQLite3 Database", new List<string>() { ".sqlite", ".db" }); savePicker.SuggestedFileName = "Database"; var file = await savePicker.PickSaveFileAsync(); if(null != file) { Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file); sqliteConnection.Close(); // it is important cause if I skip this moving a file will fail var localFolder = ApplicationData.Current.LocalFolder; var currentStorageFile = await localFolder.GetFileAsync(App.UnsavedDatabaseFileName); // here I obtain StorageFile for opened database await currentStorageFile.MoveAndReplaceAsync(file); // here I move a file sqliteConnection = new SqliteConnection("Data Source=" + file.Path); sqliteConnection.Open(); // this line fails with error 14: cannot open database file } I also tried to skip closing and reopening a connection -> then moving a file fails. If I call FileOpenPicker between await currentStorageFile.MoveAndReplaceAsync(file); and sqliteConnection = new SqliteConnection("Data Source=" + file.Path); then everything will work fine but showing file open picker right after file save picker is a very bad user experience. I know that sandboxed app gives file access permission only after user selected a file manually. But it looks like that FileSavePicker does not give me a permission just like FileOpenPicker does. I could not find any info about it. Epilogue: This is the app https://sqliteman.dev. Please feel free to criticize cause it is what makes my app better. |
How to efficiently create multidimensional arrays? Posted: 12 Jun 2021 10:09 AM PDT assuming I have any function such as f(x, y, z) = xyz what's the fastest way of calculating every value for f given three linear input arrays x, y, and z? Of course I can do something along the lines of, import numpy as np x = np.linspace(-1., 1., 11) y = np.linspace(-1., 1., 11) z = np.linspace(-1., 1., 11) for xi, xx in enumerate(x): for yi, yy in enumerate(y): for zi, zz in enumerate(z): f(xi, yi, zz) = xx*yy*zz but this is probably not the best way to do it, especially if the input arrays become larger. Is there a better way of doing it, such as with a list comprehension (but multidimensional) or any other way? Help is appreciated. |
How to change background video on scroll in React? Posted: 12 Jun 2021 10:10 AM PDT I am trying to change background video on scroll, using react-intersection-observer. When inView changes to true, useEffect must change state to sample2, and send new video to startscreen, where it's using as background video with position fixed. State is changing, but video is still the same. //Startscreen const Startscreen = ({ sample }) => { return ( <VideoBg className="videoTag" autoPlay loop muted> <source src={sample} type="video/mp4" /> </VideoBg> </Container> ); }; //App.js import sample1 from "./videos/0.mov"; import sample2 from "./videos/2.mov"; function App() { const [state, setState] = useState(sample1); const { ref, inView, entry } = useInView({ threshold: 0.5, }); useEffect(() => { if (inView === true) { setState(sample2); } else { setState(sample1); } console.log(state); }, [inView]); return ( <div className="App"> <Startscreen sample={state} /> <div ref={ref}> <AboutMe> </div> </div> )}; |
Select columns of multiple items in SQL on Laravel Posted: 12 Jun 2021 10:09 AM PDT I have something like that : - product 1 with rating rating2 rating3 etc... in my database
- product 3 with rating rationg2 ratioN3 etc... in my database
My wish is to select all notations (given by members) to make the average rating. I looked in the collections helpers but I don't found what I am looking for. My goal is to make something generic, like an helper per example, but Im open to all method you can suggest to help me to do this. One more difficulty is that Im showing all the products on the same page.... Bests |
Difference between localhost 3000 and 5000? Posted: 12 Jun 2021 10:10 AM PDT While using NodeJS, the URL was localhost:3000 and while using flask, it was localhost:5000. Why are they different if both running on same browsers. What is the key difference? Are there any others in different web technologies? Can we run NodeJS on 5000 and flask on 3000? |
Button in UICollectionView's Cell not working Posted: 12 Jun 2021 10:11 AM PDT I added a button to my collection view, but I cannot press it. I coded it so it would print something to the console as a test, but it still didn't work. The UIButton is connected to the respective class as well. This is the code: @IBAction func plusTapped(_ sender: UIButton) { print("presses!") } EDIT This is what it looks like in the View Hierarchy Debugger . It seems that the UIButtonLabel is on top of the UIButton. However, on the storyboard, I cannot find that UIButtonLabel. How do I remove the label? Edit 2 So I dragged the button down so it could be at the top like suggested, but I still can't press on it. Edit 3 The content inspector: The size inspector: Edit 4 This is what the View Hierarchy Debugger 's inspector shows. The code: extension ViewController: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: 180, height: 260) } } Edit 5 Edit 6 |
How to create a for loop to obtain correlations from a data frame in R? Posted: 12 Jun 2021 10:10 AM PDT I have the following data frame: Gene <- c("1","2","3","4","5","6") A1.1 <- c(1,1,2,4,3,5) B1.1 <- c(1,2,3,4,5,6) C1.1 <- c(2,2,3,5,5,5) A1.2 <- c(1,2,3,5,5,5) B1.2 <- c(3,2,5,6,6,6) C1.2 <- c(1,1,2,2,4,6) df <- data.frame(Gene, A1.1, B1.1, C1.1, A1.2, B1.2, C1.2) Gene A1.1 B1.1 C1.1 A1.2 B1.2 C1.2 1 1 1 1 2 1 3 1 2 2 1 2 2 2 2 1 3 3 2 3 3 3 5 2 4 4 4 4 5 5 6 2 5 5 3 5 5 5 6 4 6 6 5 6 5 5 6 6 So I need to obtain correlation values between columns of the same letter. So obtain the correlation values for A1.1 and A1.2, B1.1 and B1.2, and C1.1 and C1.2 for a total of 3 correlation values. I can do this by using the cor() function for each (eg. cor(df$A1.1, df$A1.2) ), but is there a for loop I could create that could obtain the correlations for all these at once? |
How to delete "X" lines, when found "Y" line Posted: 12 Jun 2021 10:10 AM PDT I have a .txt with contacts like this: (line 1) Andrew (line 2) andrew@email.com (line 3) 314657463 (line 4) Ariana (line 5) ariana@email.com (line 6) 1026479657 (line 7) . (line n) ...
(each value is in a diferent line) I am trying to make a code (Python) to delete 1 full contact (name, email and phone number) given the NAME. The thing is, I haven't been able to delete the email and the phone number. Try is what I tried: def delete_someone(): Y=input("Enter the full name:") archivo=open("agenda.txt", "r") count_lineas= archivo.readlines() archivo.close() archivo1= open("agenda.txt", "w") for line in count_lineas: if line.strip("\n")!= Y: archivo1.write(line) archivo1.close() |
aws quicksight create-analysis cli command Posted: 12 Jun 2021 10:11 AM PDT We have two different accounts: - one for developing
- another clien prod account
We have cloudformation templates to deploy resources, during developing new features firstly we test on dev and then deploy to prod. But with quicksight it not so easy, there are no cloudformation templates for quicksight. We need to reacreate all reports in prod account, manually it is very hard. I found QuickSight API and create-analysis command but I don't understand how I can create analysis via this command. Maybe someone have examples or know how to create analysis with cli? |
(2027, 'Malformed packet') packet issue with SQLAlchemy Posted: 12 Jun 2021 10:11 AM PDT Environment - Amazon RDS Aurora - 2.03.1
- MySQL Innodb - 5.7.12
- SQLAlchemy - 1.2.18
- Python - 3.6.7
I have this table class Users(Base): __tablename__ = "users" id = Column(Integer, primary_key=True) user_id = Column(String(64)) email = Column(String(64)) first_name = Column(String(100)) last_name = Column(String(100)) mobile = Column(String(100)) last_org_session = Column(ForeignKey("organizations.id")) I am using the session.query version of querying. updated_by_user_query = select([Users.id, Users.first_name, Users.last_name]).where( Users.id == obj["updated_by"] ) updated_by_user = session.execute(updated_by_user_query).first() This issue is that when tested locally it works. But when tested on a staging environment, it raises a malformed packet error issue. I have confirmed that localhost and staging are using the same environment and database. Any ideas what I should do? |
Appium/Protractor - Cordova app - When I try to run simple test I get following error - Failed to get sockets matching: @webview_devtools_remote_ Posted: 12 Jun 2021 10:11 AM PDT I'm trying to run a simple test on my hybrid app with Appium + Protractor and I am unable to since I am getting following error: Failed to get sockets matching: @webview_devtools_remote_.*15239 I am using Ubuntu, and on it I have set up Appium and Protractor, tried literally every solution I have found on the internet, could not resolve the issue. Only thing that would "remove" the error is adding following code into capabilities: chromeOptions: { androidPackage: "com.android.chrome" }, But then I only get in the app, and Appium server just gets stuck at: [debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8001/wd/hub/session] with body: {"desiredCapabilities":{"chromeOption {"androidPackage":"com.android.chrome","androidUseRunningApp":true,"androidDeviceSerial":"1cdc4ed10c027ece"}}} It won't start the spec file at all. var SpecReporter = require('jasmine-spec-reporter').SpecReporter; exports.config = { seleniumAddress: 'http://localhost:4723/wd/hub', allScriptsTimeout: 50976, specs: [ 'test.js' ], capabilities: { platformName: 'Android', platformVersion: '8.0.0', deviceName: 'Galaxy S9', app: 'path_to_app', autoWebview: true, browserName: '', appPackage: 'app_package_name', newCommandTimeout: '140', chromeOptions: { androidPackage: "com.android.chrome" } }, onPrepare: function () { jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'})); }, framework: 'jasmine', jasmineNodeOpts: { print: function () {}, //remove protractor dot reporter defaultTimeoutInterval: 100000 } } |
Restoring mongodb database with different name Posted: 12 Jun 2021 10:10 AM PDT I've been doing periodic (every 24 hour) backups of my mongodb instance. This works great, and I can restore them on my staging server with no problem: time mongorestore --ssl --gzip --authenticationDatabase=admin \ --host=fra-mongo-staging-1.example.com --port=27017 \ --username=restore --password=secret --archive="$snapshot_name" But the dbname in production is example_prod, whereas on the staging server I'd like to restore to example_staging. So I type this: time mongorestore --ssl --gzip --db "$dbname" --authenticationDatabase=admin \ --host=fra-mongo-staging-1.example.com --port=27017 \ --username=restore --password=secret --archive="$snapshot_name" The only difference is the --db "$dbname" (where $dbname is example_staging). This doesn't work: I see the lines about preparing, then it says done, but nothing is restored. 2019-02-07T11:16:36.743+0000 the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead 2019-02-07T11:16:36.772+0000 archive prelude example_prod.surveys 2019-02-07T11:16:36.773+0000 archive prelude example_prod.settings 2019-02-07T11:16:36.773+0000 archive prelude example_prod.spines 2019-02-07T11:16:36.773+0000 archive prelude example_prod.reduced_authors 2019-02-07T11:16:36.773+0000 archive prelude example_prod.delayed_backend_mongoid_jobs 2019-02-07T11:16:36.773+0000 archive prelude example_prod.email_events 2019-02-07T11:16:36.773+0000 archive prelude example_prod.authors 2019-02-07T11:16:36.774+0000 archive prelude example_prod.crowberry 2019-02-07T11:16:36.774+0000 archive prelude example_prod.bitly 2019-02-07T11:16:36.774+0000 archive prelude example_prod.mytestcollection 2019-02-07T11:16:36.774+0000 archive prelude example_prod.reviews 2019-02-07T11:16:36.774+0000 archive prelude example_prod.books 2019-02-07T11:16:36.774+0000 archive prelude example_prod.candy_events 2019-02-07T11:16:36.774+0000 archive prelude example_prod.features 2019-02-07T11:16:36.774+0000 archive prelude example_prod.elderberry 2019-02-07T11:16:36.776+0000 preparing collections to restore from 2019-02-07T11:17:02.403+0000 done I've also tried using --tsFrom=example_prod --tsTo=example_staging , no joy. Any suggestions on the right way to do this? |
No comments:
Post a Comment