天道酬勤,学无止境

问答

tuple concurrently updated when creating functions in postgresql / PL/pgSQL

When initializing my process, it runs the PL/pgSQL statement below creating two functions. However, every time I create multiple processes simultaneously as part of an end-to-end test, parallel execution of this statement leads to a tuple concurrently updated error that I can't seem to get around. Any help would be much appreciated. CREATE OR REPLACE FUNCTION count_rows(schema text, tablename text) returns integer AS $body$ DECLARE result integer; query varchar; BEGIN query := 'SELECT count(1) FROM "' || schema || '"."' || tablename || '"'; execute query into result; return result; END; $body$

2022-05-29 17:00:13   postgresql

conversion from ‘void’ to non-scalar type ‘std::pair<std::basic_string<char, std::char_traits<char>

I have a stack of pairs in a spreadsheet obj: std::stack< std::pair<std::string, std::string> > undoStack; And I am trying to pop the stack and assign it to another pair: std::pair<std::string, std::string> change = spreadsheets.at(i).undoStack.pop(); And I am getting this error: error: conversion from ‘void’ to non-scalar type ‘std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >’ requested Whats going wrong here?

2022-05-26 00:55:19   c++

Typescript conditional return type with default argument value

I'm trying to make a function return a conditional type based on the argument value but with a default value for the argument : function myFunc<T extends boolean>(myBoolean: T = true): T extends true ? string : number { return myBoolean ? 'string' : 1 } this throws an error Type 'true' is not assignable to type 'T'. 'true' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'boolean'. I don't understand this error, since T is a boolean how come I can't assign true to it ? I tried another approach with function overloads : function

2022-05-25 10:40:05   typescript

git worktree with relative path?

I have a master and a setup branch in my repo. I'm keeping the setup branch checked out as a worktree inside the main repo folder via git worktree add ./local/setup echo '/local' > .gitignore So the main repo folder is on master, and the local/setup folder is on setup. Everything is fine and dandy, I can work on my setup files without having to switch branches, I can commit from within local/setup etc. But if I try to move the entire repo, or access it from a different Linux boot (/home/myrepo becomes /mnt/ubu/home/myrepo), things break. The problem seems to be that git's worktree

2022-05-25 03:21:03   git   git-worktree

Where to store user uploads in spring mvc application?

I am wondering where should i save files uploaded by user in my application. Right now i am saving them right into webapps/images/uploads(webapps folder is mapped as resource folder via mvc-resource) folder and they are instantly available to display after upload. But i am not sure if this is the right thing to do? how will redeployment of application affect the files already stored there? won't it complicate back ups of application? so basically where should i store them on server? and is this affected somehow by using local(windows) or remote(linux) server Thanks

2022-05-24 20:10:17   java   spring   file-upload   spring-mvc

how to define an array of textboxes in c#?

Hi when I create textboxes on Windows Application Form I cannot name it as box[0], box[1] and so on. The purpose why I want to do like this is because I want to use them in a loop.

2022-05-23 04:25:05   c#   arrays   loops   textbox   naming

Google.Apis sharing access and refresh tokens

Until now I had one client (web application) that was doing the OAUTH2 authorization flow, and then would send to the server (ASP.NET Web API) both the Access Token and the Refresh Token. Then on the server, those tokens would be used to do several operations against the Google API. Everything perfect until now we had the need of adding mobile clients doing the same OAUTH2 authorization flow. That required me to add those Android and iOS applications under the Googles Console. All 3 (Web, Android, and iOS) belong to the same project. The problem comes now, since on the server I have to use the

2022-05-23 03:15:03   c#   oauth-2.0   google-api

Class "App\Http\Controllers\Auth\User" not found

How do I resolve this Laravel error? Class "App\Http\Controllers\Auth\User" not found I am creating a register for a blog and I am using the following: User::create([ 'name' => $request->name, 'username' => $request->username, 'email' => $request->email, 'password' => Hash::make($request->password), ]) I have included namespace App\Http\Controllers\Auth; and use Illuminate\Support\Facades\Auth;

2022-05-22 12:29:03   laravel

Broadcast receiver not unregistering

I want to give the user the ability to unregister/register the broadcast receiver with the click of the button. When the button is pressed for the first time, the broadcast receiver is registered and a toast comes up when the device is connected. My problem is when I press the button again, the broadcast reciever is not unregistering like I specified. Can somebody please check if there is something wrong with mylogic, or explain to me if there is another approach to detecting when usb is unplugged/plugged in? Thank You. btn.setOnClickListener(new View.OnClickListener() { BroadcastReceiver

2022-05-15 02:45:05   android   usb   broadcastreceiver

Anaconda Navigator cannot create new environment

I need to use Python at work and just installed Anaconda Navigator today. I am able to open the Navigator GUI without any problems. I am able to open the Create new environment prompt. I fill out the details and hit ok. Navigator creates a New tab for the environment I requested under the base(root) tab. At the bottom it says: "Creating environment" and there is a blue progress bar and a cancel button. It does this for a while then the new tab disappears and it no longer says creating environment at the bottom and the progress bar is gone. In the new environment prompt, it tells me where it

2022-05-03 11:55:53   python   anaconda