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
Raspberry Pi User Help

how to use MCP23S17 pin expander via SPI

I’m working on a custom sensor that is wired to a couple of MCP23S17 gpio expanders, which are in term connected to a Raspberry Pi 4 via the SPI pins i.e. SPI_MOSI, SPI_MISO, SPI_SCLK and CE0 pin. I’m trying to read/write to these expanded pins via some python code, preferably using ‘wiringpi’ but I can’t […]

Categories
Mastering Development

Pyspark/NiFi : Converting Multiline rows file to single line row file

I have a csv file which has records are in multiline like this 1,2,3,4,5,6,7 1,2,3,4 ,5,6, 7 1,2 3,4 ,5,6, 7 I want to change the file like below – 1,2,3,4,5,6,7 1,2,3,4,5,6,7 1,2,3,4,5,6,7 I know pyspark can read such file with multiline :True option but I want to convert this file to single line rows […]

Categories
Mastering Development

FullCalendar – I can’t retrieve the events on the calendar

I have json format events available on a "/ index" url. I would like to be able to retrieve them in order to display them on the calendar. I followed the official tutorial to the letter but unfortunately I still can’t do it, here are my files: calendar.js $(function () { ‘use strict’ // Initialize […]

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
Cryptocurrency Ethereum Mastering Development

ethers.js wrong signature

From the same private key in ethers.js and secp256k1 I get the same eth address. But if I sign a message I get a different (wrong) signature in ethers.js. What is wrong with my code? import { createKeyPair, sign } from ‘@erebos/secp256k1’ import { pubKeyToAddress } from ‘@erebos/keccak256’ import { ethers, Wallet } from ‘ethers’; […]

Categories
User Help

Linux mint freezes when running SDL2 prgram

In the past couple SDL2 programs I’ve been developing the strangest error seems to pop up; whenever I run the program– after an arbitrary amount of time has passed– Linux mint freezes. I can’t move my mouse or do anything with the computer. My only option at that point is to push the power button […]

Categories
Mastering Development

poly crop image python: How to change mask color

I’m croping an image with a polygon array, but I need to change the swoed mask color to PINK for another program recognize it as a mask. How to do that? import numpy as np import cv2 import time img = cv2.imread("teste3.jpg") start=time.time() height = img.shape[0] width = img.shape[1] mask = np.zeros((height, width), dtype=np.uint8) points […]

Categories
Mastering Development

python plotly: unfixed number of traces

My code reads data from .xlsx file and it plots the Bubble diagram by using plotly. Bubble Diagram The task is easy when I do know how many traces need to be plot. However, I was thrown into bewilderment when the number of traces is unfixed since the number of rows is variable. raw data […]

Categories
Linux Mastering Development

Bash: convert 100,000+ characters to decimal format?

I’m looking for a quick and not-so CPU intensive solution to convert 100,000+ lines of text into decimal format. # random ascii string=’QPWOEIRUTYALSKDJFHGZMXNCBV,./;[]75498053$#!@*&^%(*’ convert () { for ((b=0; b<${#string}; b++ )) do # convert to dec, append colon character, add to array arr+=$(printf ‘%d,’ "’${string:$b:1}"); done; # show array contents printf ‘%s’ "${arr[@]::-1}" } time […]