Categories
Mastering Development

cx_Oracle SessionPool root of all Flask problems

I created a web service in Flask over uwsgi. I thought I would follow good practice and create a SessionPool with 20 connections to be safe. Each call to a web service endpoint, I acquire a connection from the pool, and at the end I release it. When using Locust to swarm test the API, […]

Categories
Mastering Development

Removing red within an image from cImage

def removeRed(imageFile): myimagewindow = ImageWin("Image Processing", 1000, 300) oldimage = FileImage(imageFile) oldimage.draw(myimagewindow) width = oldimage.getWidth() height = oldimage.getHeight() newim = EmptyImage(width, height) pixel = Pixel(0, 0, 0) redPixel = Pixel(255, 0, 0) for row in range(height): for col in range(width): if pixel == redPixel: originalPixel = oldimage.getPixel(col, row) newPixel = Pixel(originalPixel, originalPixel, originalPixel) newim.setPixel(col, row, […]

Categories
Mastering Development

Align Tkinter radio buttons

My Tkinter radio buttons are misaligned. I have tried this Python tkinter align radio buttons west, this Python tkinter align radio buttons west and none of them worked, what I see is this when I use grid to manage the widgets (has to be grid as it is part of a larger UI). I have […]

Categories
Mastering Development

Why is my component reloading several times in React

Here is the code that is the cause. I have seen a kind of similar issue but in the thread but it stated that the code was calling a lot of asynchronous functions, but in this case i’m only calling one. import React, { Fragment, useState, useEffect } from ‘react’; import { Modal, Button, Row, […]

Categories
Database Development

SQL Show databases doesn’t show all databases, while being logged in as root

If I run the following code using PHP: <?php $mysqli = new mysqli(‘localhost’, ‘root’, ‘password’); if ($mysqli->connect_errno) { trigger_error(‘query failed: ‘ . $mysqli->connect_error, E_USER_ERROR); } $result = $mysqli->query(‘SHOW databases’) or trigger_error(‘connect failed: ‘ . join(‘,’, $mysqli->error_list), E_USER_ERROR); foreach ($result as $row) { echo join(‘, ‘, $row), "<br />\r\n"; } I get a list of databases. […]

Categories
Mastering Development

Getting Information/Data/Values from a row in React-Table

I literally have stayed up all night trying to figure out how to grab a value from my row. const columns = useMemo( () => [ { // first group – TV Show Header: "Shop Chop Chop List", // First group columns columns: [ { Header: "User", accessor: "email", }, { Header: "Store", accessor: "store", […]

Categories
Mastering Development

getting error when using jlink to create runtime image with time4j datepicker

i am using time4j library for Persian date picker . when i run with gradle i see the app running but when i use jlink to create java fx runtime image i get this error: Caused by: java.util.ServiceConfigurationError: net.time4j.engine.ChronoExtension: module alif.pooya.merged.module does not declare `uses` at java.base/java.util.ServiceLoader.fail(Unknown Source) at java.base/java.util.ServiceLoader.checkCaller(Unknown Source) at java.base/java.util.ServiceLoader.<init>(Unknown Source) at […]

Categories
Mastering Development

Error while importing data with foreign keys in django import-export

I have implemented importing data using django import-export library. When i try to import data with names of object that do not exists it throws error matching query does not exist. It ends with generating template with error stack trace like this: Line number: 1 – CustomUser matching query does not exist. sample@sample.com, data1, firstname, […]

Categories
Mastering Development

Python Recursive Sudoku Solver Doesn’t Return the Solution

I tried to optimize this code and my final code was as shown below import numpy as np sudoku = np.array([[0, 9, 0, 0, 5, 0, 6, 0, 8], [0, 0, 0, 7, 1, 0, 3, 5, 0], [2, 1, 0, 0, 0, 0, 7, 0, 4], [0, 0, 1, 5, 0, 0, 0, 0, […]

Categories
Mastering Development

Checkboxes – Getting starting value from state

I have the following form, and the part that works is it sets the state for each option to "true" of "false" as I check and uncheck the boxes as expected. My problem is that when I first run the app, if I have some states set to true, I want those checkboxes to start […]