Random snippets of all sorts of code, mixed with a selection of help and advice.
Conformance to generic constraint seems impossible with subclass
27 July 2024 @ 9:20 am
I've cut my code down to the following simplest version to show the problem. I'm not sure why Swift is complaining.
Why does DatabaseGateway need to conform to protocol Something ???
struct Database {}
open class DatabaseGateway {
let database: Database
public init() {
database = Database()
}
}
struct FilterParameter<T> {}
protocol Something {
associatedtype T: RawRepresentable where T.RawValue == String
var filterParameter: FilterParameter<T> { get }
}
enum VoteTable {}
extension VoteTable {
enum Field: String {
case value = "value"
}
}
final class User: DatabaseGateway, Something {
let filterParameter = FilterParameter<VoteTable.Field>()
}
final class Poll: DatabaseGateway, Something {
let filterParameter = FilterParameter<VoteTable.Field>()
}
struct VoteRecordFilter {
let parameters: [Parameter]
init(paramet
Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24. React Native Async Storage
27 July 2024 @ 9:18 am
Error when building release or debug
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':@react-native-async-storage'.
> Could not resolve all artifacts for configuration ':@react-native-async-storage:classpath'.
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24.
Required by:
project :@react-native-async-storage
> Cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24:
- gradle70JavadocElements
- gradle70RuntimeElements
- gradle70SourcesElements
- gradle71JavadocElements
- gradle71RuntimeElements
- gradle71SourcesElements
- gradle74JavadocElements
- gradle74RuntimeElements
I tried updating the version async storage, but didn´t work
Advice tools to generate digital signature and esignature
27 July 2024 @ 9:16 am
I need to implement a system in Spring Boot and logical document to manage document which provide the feature to add either digital signature or Esignature to word document/PDF file while it is being uploaded on the system.
I have seen there are many tools that I can use to integrate as REST API to generate either e-signature or digital signature as follows:
Docusign - Robust , widely used and expensive compared to PandaDoc
and DocuSeal.It supports both e-signature and digital signature
Docuseal - Robust support e-signature but it does not look like it
support digital signature.
PandaDoc - Robust and ideal for businesses needing comprehensive
document management but support only e-signature not digital
signature.
Based on the above it looks like only docuSign support both digital signature and esignature.
I am new to the above tools and I might have missed something important or any other tool. Any advice on which one is ea
trpc giving error when trying to test with postman
27 July 2024 @ 9:16 am
Im using nextjs app router, trpc, prisma, zod
Trying to test my trpc endpoint
http://localhost:3000/api/trpc/user.login
using Body- AW-JSON
{
"username": "admin",
"password": "CodingDojo2022!"
}
but im getting this error
POST /api/trpc/user.login 400 in 15ms
❌ tRPC failed on user.login: [
{
"code": "invalid_type",
"expected": "object",
"received": "undefined",
"path": [],
"message": "Required"
}
]
{
"error": {
"json": {
"message": "[\n {\n \"code\": \"invalid_type\",\n \"expected\": \"object\",\n \"received\": \"undefined\",\n \"path\": [],\n \"message\": \"Required\"\n }\n]"
Applying default layout to Nuxt.js error page while preserving route transitions
27 July 2024 @ 9:14 am
I have set up a default layout that includes a header and footer. This layout works fine for all of my pages since they are inside the pages directory and because I have a <NuxtPage/> wrapped in <NuxtLayout/> in app.vue.
However, I've encountered an issue with the error page. It is located outside the pages directory and as a result, the default layout will never be applied.
I've considered adding a <NuxtLayout/> component in error.vue, but this approach causes conflicts with the <NuxtLayout/> in app.vue - it re-renders it and breaks the transition. I have both pageTransition and layoutTransition set up in nuxt.config.ts.
How can I make sure that the default layout is applied to the error page while maintaining a transition?
How to mock indexed display in Figma
27 July 2024 @ 9:11 am
I am new to the Figma app and need the hints how to approach the design in the best way. I would like to create the iPhone app mockup, styling it to look like 'indexed display'. Should I divided the frame for little squares and try to create the fonts based on it or there is easier way to do this ?
![enter image description here](https://i.sstatic.net/BHOwYKsz.png)
![enter image description here](https://i.sstatic.net/BHOwYKsz.png)
CSS to "scale" Image to Fit Browser Window height and width
27 July 2024 @ 9:10 am
I am generating a static site where the images and set within a responsive "picture frame" so the Mat is the same size on each side, regardless of the image's aspect ratio. This is working well; however...
I want to ensure that the whole "picture frame" is visible in the browser window. Currently, the frame is sized to the width, meaning tall images scroll off the bottom.
Can someone look at my code and suggest how I dynamically resize the "picture frame" so it is 100% visible in the browser window ?
There is a JSFiddle here - link
<div class="frame" style="padding-bottom: 115.09%">
<div class="mat" style="top: 2.1721%; bottom: 2.1721%; left: 2.50%; right: 2.50%;">
<div class="art" style="top: 11.354%; bottom: 11.354%; left: 13.158%; right: 13.158%;">
Selenium python program started crashing with WinError 193
27 July 2024 @ 9:09 am
I am running code with pytest and initializing a set of frontend tests with selenium. With no changes in code my selenium chrome tests started crashing with this error, firefox tests pass with no issue. Looks like something not related directly with code but rather my system? Below I'm pasting full log of the error I am receiving. I would appreciate all the help I can get.
__________________________________________________________________________________________ ERROR at setup of TestLoginPage.test_positive_login[chrome] ___________________________________________________________________________________________
request = <SubRequest 'driver' for <Function test_positive_login[chrome]>>
@pytest.fixture(params=["chrome", "firefox"])
def driver(request):
chrome_options = ChromeOptions()
chrome_options.add_argument("--headless=new")
firefox_options = FirefoxOptions()
firefox_options.add_a
Tenancy for Laravel repeating db search query for domain multiple times
27 July 2024 @ 8:56 am
I have a Laravel v10.x multitenancy application, I'm using stancl/tenancy: ^3.8 with multiple database and InitializeTenancyByDomain and PreventAccessFromCentralDomainsmiddlewares.
In partical terms it's working fine, but when analyzing the db queries being done in more detail,
controller construct method:
\DB::listen(function($query) {
\Log::info(
$query->sql,
$query->bindings,
$query->time
);
});
I'm seeing in my logs a lots of (30+ times, for some routes):
select * from `domains` where `domains`.`tenant_id` = ? and `domains`.`tenant_id` is not null limit 1
When In fact I'm calling this route/controller only twice, one non ajax, and other ajax. I can see this in the browser network tab.
So this query being done only twice is the expected.
My assumption at first was that the tenant() helper isn't cached in
consistency by isolation levels, while SELECT SUM(*) million records, UPDATE some records
27 July 2024 @ 8:49 am
I was testing READ UNCOMITTED and READ COMITTED. For this, using 2.5 million row records, I tried the followings.
First, at Session A:
BEGIN;
SELECT SUM(salary) FROM salaries;
then immediately (before finishing the SUM), at Session B:
BEGIN; UPDATE salaries SET salary = 10000 WHERE emp_no = 250000; COMMIT;
then the result is:
READ UNCOMMITTED at Session A gives the result as if it is after UPDATE. (understandable)
READ COMMITTED at Session A gives the result as if it is before UPDATE. (confusing for me)
I'm confused about the result of READ COMMITTED. When Session A is scanning the records, I think the UPDATE from Session B is already commited.
In other words, the difference between READ UNCOMMITTED and READ COMMITTED should be if