Categories
Mastering Development

python pulp: How do I create LpMaximize and LpMinimize problem?

How do I go about creating an optimization that LpMaximize profits and LpMinimize the variance? I tried making var negative than using LpMaximize. The code below just the max of var and not the min of var and the max of profit. prob += lpSum([profits[i]*x[i] for i in N] and [var[v]*x[v] for v in N]) […]

Categories
Development

Missing required potential argument in function call Python

I’m just starting to learn Python, and was writing a calculator program with two different files to get the concept of calling classes and functions down. The file with the mathmatical operations in a class looks as such: class standardOpperations: def __init__(self, primaryNumber, secondaryNumber): primaryNumber.self = primaryNumber secondaryNumber.self = secondaryNumber def addition(self, primaryNumber, secondaryNumber): print(primaryNumber, […]

Categories
Development

C++ code to sort data in CSV file from string

I have written a function which parse data from file and is kept inside a String variable called content. For example : String Content = “ABC Corp : Processed server: dfgh123 passed = 1250; remaining = 0; DTY Corp : Processed server: dty123 passed = 120; remaining = 1; QRS Corp : Processed server: qrs123 […]

Categories
Development

search and return array with subarray in laravel

Hello community in Laravel I am doing a search, an array listing returns me, it’s perfect. I want to return a subarray with a list, how is it done with select? using db :: table in laravel DB::table(“campania_post AS pt”) ->join(“campania AS c”,”c.id”,”=”,”pt.campania_id”) ->where(“c.manager_id”, “=”, $user->id) ->leftJoin(“files AS f”,”f.id”,”=”,”c.avatar”) ->where(“pt.status”, “=”, 0) ->select(“c.id”, “c.nombre”, “c.avatar”, […]

Categories
Development

laravel, search for repeated and non-repeated records in table mysql

I have the following code: $campania_empresa_fotos = DB::table(“campania_post AS pt”) ->where(“c.manager_id”, “=”, $user->id) ->join(“campania AS c”,”c.id”,”=”,”pt.campania_id”) ->leftJoin(“files AS f”,”f.id”,”=”,”c.avatar”) ->select(“c.id”, “c.nombre”, “c.avatar”, “f.name”, “c.created_at”) ->groupby(“c.id”) ->get(); What I want to look for is repeated and non-repeated records. When the result returns in the blade call, if ITEM ONE => 3 records ITEM DOS => 1 […]

Categories
Development

Laravel query builder. Column if not null = 1 else = 0 in select method

I using Laravel and its \Illuminate\Database\Eloquent\Builder. I would like to select all columns from “table_1” a have custom column “is_table_2_present” which value will be 1 or 0 depending if(table_1_id != null). So I would like to do something like that. $queryBuilder->leftJoin(“table_2″….) $queryBuilder->select([ “table_1.*”, “is_table_2_present” = (table_2_id != null) ? 1 : 0, ]); I was […]

Categories
Development

Can’t return the same output after modifying Comparestring.py

Here is the previous version of Comparestring.py which returns the best matched product url from database.json and product_list.yaml Comparestring.py from difflib import get_close_matches import json, yaml import pprint class Comparestring(): def __init__(self): self.Purl = ” with open(r’C:\Users\Latitude\Desktop\Shadman\Scrapy_Projects\database.json’, encoding=’utf-8′) as File: data = json.load(File) # File = open(“database.json”, “r”) # data = json.load(File) with open(r’C:\Users\Latitude\Desktop\Shadman\Scrapy_Projects\Product_List.yaml’) as […]

Categories
Development

How do I get fetch and store the ID of the row I’m clicking the button on?

To briefly explain my title: I’ve a table where I’m printing all the users and their information. I’ve a Create Schedule button on each row. When I click the Create Schedule button, I go to a page where I’ll fill out a 7-day weekly schedule of THAT user and then save it. When I save […]

Categories
Development React

Failed to Fetch using Knex JS in in React App

I have a component with a checkbox that I’m keeping track of through a localhost db using postgres. When i check the checkboxes, a row is inserted into the table netowrkusers with the login user id in the id column, and the id of the user that was checked in the connections column. It removes […]

Categories
Database Development jQuery MySQL

I want to search for and save form values in the database

I am a javascript, database beginner. The database contains the following data ID Title Comment 1 Book1 test 2 Book2 test I am trying to save the form values in the database. At that time, by pressing the search button, I want to check if the form value (name: title) already exists in the database. […]