Categories
Mastering Development

How to chunk long numbers into 2 numbers

I have long numbers like 123456789123456789 I want to make it chunk like [ 12, 34,56,78,91,23,45,67,89 ] I did try with split but it’s not what I want

Categories
Mastering Development

Fast way to remove array of specific row values from 2D numpy array

I have a 2D array like this: a = np.array([[25, 83, 18, 71], [75, 7, 0, 85], [25, 83, 18, 71], [25, 83, 18, 71], [75, 48, 8, 43], [ 7, 47, 96, 94], [ 7, 47, 96, 94], [56, 75, 50, 0], [19, 49, 92, 57], [52, 93, 58, 9]]) and I want to […]

Categories
Mastering Development

Object.keys(myObject) returns an arbitrary list of numbers, not expected value

This is a bit of a head-scratcher – and has been a source of pain for the past 3 hours. Here’s my code. const payloadBody = JSON.parse(gatewayEvent.body); console.log(payloadBody); console.log(gatewayEvent.body); console.log(payloadBody.paymentMethodId); console.log(payloadBody[‘paymentMethodId’]); console.log(Object.keys(payloadBody)); If I look at the CloudWatch logs for this (I am executing in Lambda), the line console.log(payloadBody) logs: { "customerId": "cus_REDACTED", "paymentMethodId": "pm_REDACTED", […]

Categories
Mastering Development

Creating a List of Lists/Objects in java

I just recently started learning Java and wanted to try creating a list of lists. In all the examples I’ve come across on the internet, inorder to add lists of integers as different elements to another list,different lists were created. When tried using a single list but with changing it’s values each time before adding […]

Categories
Mastering Development

Closures in Swift: what are they? how do they work?

I’m working through a book on Swift basics and the section on closures made little sense to me. This is the example that they provided: To sort an array so that small numbers go before large numbers, you can provide a closure that describes how to do the sort, like this: var numbers = [2,1,56,32,120,13] […]

Categories
User Help

How to use variables in awk if condition in shell script?

When I tried to cut columns with key words from a csv file, I applied a variable from the for loop of a shell script in the awk if condition. But the if cannot recognize my string. So there’s no output. Here is my script. #! /bin/bash while read line do head -1 test.csv | […]

Categories
Mastering Development

–°ustomize R plotly plots colors in subplots

I have a dataframe, which you can get with this code: x = data.frame(metrics=c("type1", "type1", "type1","type1", "type1", "type1", "orders", "orders", "orders","orders", "orders", "orders", "mean","mean","mean","mean","mean","mean"), hr=c(6,7,8,6,7,8,6,7,8,6,7,8,6,7,8,6,7,8), actual=c(14,20,34,22,24,27,56,12,34,11,15,45,56,78,89,111,123,156), time=c("today", "yesterday", "today", "yesterday", "today", "yesterday")) I wrote a code to make som plots with that using plotly: plot <- function(df) { subplotList <- list() for(metric in unique(df$metrics)){ subplotList[[metric]] […]

Categories
Mastering Development

Value to Assign to Missing Values in uint Numpy Array

A numpy array z is constructed from 2 Python lists x and y where values of y can be 0 and values of x are not continuously incrementing (i.e. values can be skipped). Since y values can also be 0, it will be confusing to assign missing values in z to be 0 as well. […]

Categories
Mastering Development

mysql select random 10 posts with 10 pages from database and after refreshing it , Numbers of the current page become different

I just want to know whether I can make it or not. Thank you for helping me in advance. I have 100 posts. There are 10 pages. I want to display 10 random posts with each pages. If I refresh the page, numbers should be changed in the page . If I go to the […]

Categories
Mastering Development

I want to update all sub-sub tag of XML with different values how can i do that using BeautifulSoup

lets say this is my XML <sky class="new"> <list name="school"> <p>63</p> <p>62</p> <p>61</p> </list> </sky> And this is my values in list. value = [51,56,87] Now I what I need is: <sky class="new"> <list name="school"> <p>51</p> <p>56</p> <p>87</p> </list> </sky> So far want I did is: for i in soup.find_all(‘sky’, {‘class’:’new’}): k = i.find(‘list’,{‘name’:’school’}) After […]