04 March, 2024
VS Code Extension for API Insights
Programing Coderfunda March 04, 2024 No comments
Recently, at Treblle, we released a Visual Studio Code extension to work with our free developer tool, API Insights. After releasing this new tool, we wanted to look for ways developers building OpenAPI Specifications could benefit without stopping what they were doing.
So, for those who need to be made aware, API Insights is a free developer tool we created at Treblle that lets you get insights into your API design. It will score your OpenAPI Specification against:
* Performance
* Quality
* Security
The way this works is that we analyze your specification to understand what this API does. We then compare your API to a set of industry standards for APIs and see how close you are to having an "industry standard API".
However, we go a step further than just analyzing your specification; we send a request to the first endpoint that could be successful and measure load time and response size. We can analyze something similar to understand your API better.
The VS Code extension will allow you to analyze your specifications without leaving your editor. Even better, though, is that it will then watch this file for changes and prompt you to re-run the analysis if a change is detected.
We wrote about this new free tool in a little more detail on our blog and would love to hear your thoughts about the extension - also, what developer tool you would find helpful! You never know; we may build it.
The post VS Code Extension for API Insights appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
Phone Number Formatting, Validation, and Model Casts in Laravel
Programing Coderfunda March 04, 2024 No comments
The Laravel-Phone package makes working with phone numbers in PHP and Laravel a breeze, offering validation rules, attribute casting, utility helpers, and more.
Have you ever built validation around phone numbers that supports multiple countries? This package has helpful validation rules built in, which makes it easy to validate numbers for any country. You can specify acceptible country code formats, but at the same time accept valid "international" numbers:
// Validate either USA or Belguim
Validator::make($request->all(), [
'phone_number' => 'phone:US,BE',
]);
// Validate US specifically, but also accept other countries
Validator::make($request->all(), [
'phone_number' => 'phone:US,INTERNATIONAL',
]);
// Use the Phone rule
Validator::make($request->all(), [
'phone_number' => (new Phone)->country(['US', 'BE']),
]);
// Match country code against another data field
Validator::make($request->all(), [
'phone_number' => (new Phone)->countryField('custom_country_field'),
'custom_country_field' => 'required_with:phone_number',
]);
This package uses the PHP port of Google's phone number handling library under the hood, which has robust parsing, formatting, and validation capabilities for working with phone numbers in PHP:
// Formatting examples
$phone = new PhoneNumber('012/34.56.78', 'BE');
$phone->format($format); // Custom formatting
$phone->formatE164(); // +3212345678
$phone->formatInternational(); // +32 12 34 56 78
$phone->formatRFC3966(); // +32-12-34-56-78
$phone->formatNational(); // 012 34 56 78
You can learn more about this package, get full installation instructions, and view the source code on GitHub. I recommend getting started with the readme for full documentation about this package.
The post Phone Number Formatting, Validation, and Model Casts in Laravel appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
03 March, 2024
Error: formControlName must be used with a parent formGroup directive. You'll want to add a formGroup directive - Angular reactive forms
Programing Coderfunda March 03, 2024 No comments
First Name*
Then in my component I have:
@Component({
selector: 'guest-input',
templateUrl: './guest-input.component.html',
})
export class GuestInputComponent implements OnInit {
@Input()
guest: Guest;
guestForm: FormGroup;
constructor(private _fb: FormBuilder) { }
ngOnInit() {
this.guestForm = this._fb.group({
firstname: ['test', [Validators.required, Validators.minLength(3)]]
});
}
}
This all looks fine to me but for some reason I am getting:
Error: Uncaught (in promise): Error: formControlName must be used with a parent formGroup directive. You'll want to add a formGroup
directive and pass it an existing FormGroup instance (you can create one in your class).
I thought I had declared this in my .
Weekly /r/Laravel Help Thread
Programing Coderfunda March 03, 2024 No comments
* What steps have you taken so far?
* What have you tried from the documentation?
* Did you provide any error messages you are getting?
* Are you able to provide instructions to replicate the issue?
* Did you provide a code example?
* Please don't post a screenshot of your code. Use the code block in the Reddit text editor and ensure it's formatted correctly.
For more immediate support, you can ask in the official Laravel Discord.
Thanks and welcome to the /r/Laravel community! submitted by /u/AutoModerator
[link] [comments]
How to add variation stock status to Woocommerce product variation dropdown
Programing Coderfunda March 03, 2024 No comments
// Updated Woocommerce Product Variation Select
if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
/**
* Output a list of variation attributes for use in the cart forms.
*
* @param array $args
* @since 2.4.0
*/
/*
function wc_dropdown_variation_attribute_options( $args = array() ) {
$args = wp_parse_args( apply_filters( 'woocommerce_dropdown_variation_attribute_options_args', $args ), array(
'options' => false,
'attribute' => false,
'product' => false,
'selected' => false,
'name' => '',
'id' => '',
'class' => '',
'show_option_none' => __( 'Choose an option', 'woocommerce' ),
) );
$options = $args['options'];
$product = $args['product'];
$attribute = $args['attribute'];
$name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute );
$id = $args['id'] ? $args['id'] : sanitize_title( $attribute );
$class = $args['class'];
$show_option_none = $args['show_option_none'] ? true : false;
$show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options.
if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {
$attributes = $product->get_variation_attributes();
$options = $attributes[ $attribute ];
}
$html = '';
$html .= '' . esc_html( $show_option_none_text ) . '';
if ( ! empty( $options ) ) {
if ( $product && taxonomy_exists( $attribute ) ) {
// Get terms if this is a taxonomy - ordered. We need the names too.
$terms = wc_get_product_terms( $product->get_id(), $attribute, array( 'fields' => 'all' ) );
foreach ( $terms as $term ) {
if ( in_array( $term->slug, $options ) ) {
$html .= 'slug ) . '" ' . selected( sanitize_title( $args['selected'] ), $term->slug, false ) . '>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $term->name ) ) . ' ';
}
}
} else {
foreach ( $options as $option ) {
// This handles lt 2.4.0 bw compatibility where text attributes were not sanitized.
$selected = sanitize_title( $args['selected'] ) === $args['selected'] ? selected( $args['selected'], sanitize_title( $option ), false ) : selected( $args['selected'], $option, false );
$html .= '' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ) . ' Output Stock Details Here ';
}
}
}
$html .= '';
echo apply_filters( 'woocommerce_dropdown_variation_attribute_options_html', $html, $args );
}
}
I can pull out the stock level for the overall product, but now for each variation.
Any help would be greatly appreciated.
How to get rid of the padding of SF Symbol in SwiftUI
Programing Coderfunda March 03, 2024 No comments
VStack{
Image(systemName: "drop")
.resizable()
.font(.largeTitle.weight(.ultraLight))
.scaledToFit()
}
Screenshot shows a small gap on the right side:
After using additional padding, the image still looks off. That gap becomes less but it's still noticable.
My expectation was that applying .scaledToFit would actually scale the image to fit the screen, and then I could use the padding.
Though even with padding the issue persists:
I tried to use .aspectRatio(contentMode: .fit), and also different aspect ratios hoping that it could fix it.
Also the same issue persists even using the "square" SF Symbol (that likely excludes aspect ratio issue cuz square is 1:1) Though I fixed issue with square using .imageScale(.large)
Square without .imageScale(.large):
Square with .imageScale(.large):
Watch Face isn't recognised as a standalone app by Google Play store
Programing Coderfunda March 03, 2024 No comments
I have set my watch face to be a standalone app (following the instructions from the
https://developer.android.com/training/wearables/apps/standalone-apps) by setting the com.google.android.wearable.standalone meta data in the manifest.xml:
However, for some reason Google Play still thinks that the Wear OS bundle is a non-standalone app (see the "Requires mobile app" message in the screenshot below).
Has anyone experienced a similar issue? Do you guys have any ideas what could be wrong?
02 March, 2024
What's the go to method on doing Auto Scaling with Laravel?
Programing Coderfunda March 02, 2024 No comments
Is there a better way in doing this? I'm mostly looking into making it easier to deploy code updates.
In your work, how do you do auto scaling with Laravel? submitted by /u/mod_suck
[link] [comments]
Why is there a gap to other elements when I add an image to the navigation bar in html?
Programing Coderfunda March 02, 2024 No comments
Here is the HTML file:
DataPredict
Home
Contact
Why DataPredict
And here is the CSS file:
body {
margin: 0px 0px 0px 0px;
}
.top-navigation-bar {
background-color: #5B9BD5;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
width: inherit;
height: 50px;
}
.top-navigation-bar img{
margin: 0px;
padding: 0;
border-width: 0;
width: auto;
height: 100%;
display: inline;
}
.top-navigation-bar button{
border-width: 0px;
margin: 0px;
padding: 0;
background-color: inherit;
padding-block: 0;
width: 10%;
height: 100%;
border-style: none;
display: inline;
}
.top-navigation-bar button text{
padding: 0;
height: 100%;
width: 95%;
background-color: inherit;
display: inline;
}
.top-navigation-bar button selected{
padding: 0;
height: 90%;
width: 5%;
background-color: inherit;
display: inline;
}
.top-navigation-bar button:hover selected{
padding: 0px 0px 0px 0px;
height: 90%;
width: 5%;
background-color: black;
display: inline;
}
Ah also, I was trying to make a black bar appear when the mouse hovers over it. So don't change that. But also I could not get that to work either, since it isn't appearing when I hover it. What exactly I'm missing here?
Drop down menu with protected sheet
Programing Coderfunda March 02, 2024 No comments
I have a little file Excel.
This file has protected sheets with drop down menu and these are the steps:
1)double click to show Userform1;
2)click on CommandButton of the Userform to write on the protected sheet:
Private Sub CommandButton1_Click()
ActiveSheet.Unprotect Password:="password"
Range("a1") = "prova"
ActiveSheet.Protect Password:="password", DrawingObjects:=True
Unload Me
End Sub
The problem is that when I fix manually protected sheets, double click on cells with drop down menu does work, but after I execute the "Private Sub CommandButton1_Click()" procedure, drop down menu doesn't work any more.
Is it possible to force drop down menu to work also after I execute the procedure triggered by CommandButton1?
I need Userform1 to show after double-click event, also for the cells formatted with the drop down menu.
Thank you in advance
I tried changing parameters of the Protect Method, but with the same result.
Switching between two frames on seperate files in tkinter
Programing Coderfunda March 02, 2024 No comments
Main_Menu.py
import tkinter as tk
from tkinter import PhotoImage
from second_page import SecondPage
from first_page import FirstPage
class Hauptfenster:
def init(self, root):
self.root = root self.root.title("Hauptfenster")
# Bild laden
self.background_image = PhotoImage(file="Background_Main.png")
# Größe des Bildes abrufen
self.width = self.background_image.width()
self.height = self.background_image.height()
# Haupt frame erstellen
self.main_frame = tk.Frame(self.root, width=self.width, height=self.height)
self.main_frame.pack_propagate(False) # Verhindert, dass der Rahmen seine Größe an die Widgets anpasst
self.main_frame.pack() # Packe den Haupt frame, um ihn sichtbar zu machen
# Hintergrundbild hinzufügen
self.background_label = tk.Label(self.main_frame, image=self.background_image)
self.background_label.place(x=0, y=0, relwidth=1, relheight=1) # Füllt das Bild den Rahmen aus
# Rahmen für den ersten Knopf erstellen
self.create_character_frame = tk.Frame(self.main_frame, bg="white", bd=0, relief="flat")
self.create_character_frame.place(relx=0.4, rely=0.7, anchor="center")
# Rahmen für den zweiten Knopf erstellen
self.Archiv_frame = tk.Frame(self.main_frame, bg="white", bd=0, relief="flat")
self.Archiv_frame.place(relx=0.6, rely=0.7, anchor="center")
# Rahmen für den schließen Button
self.close_frame = tk.Frame(self.main_frame, bg="white", bd=0, relief="flat")
self.close_frame.place(relx=0.5, rely=0.9, anchor="center")
# Rahmen für das Logo
self.logo_frame = tk.Frame(self.main_frame, bg="white", bd=0, relief="flat")
self.logo_frame.place(relx=0.5, rely=0.2, anchor="center")
# Text für den ersten Knopf hinzufügen
self.create_character_image = PhotoImage(file="character_text.png")
self.create_character_button = tk.Button(self.create_character_frame, image=self.create_character_image,
relief="flat", command=self.zeige_erste_seite)
self.create_character_button.pack(pady=10)
# Bild für den ersten Knopf hinzufügen
self.first_image = PhotoImage(file="Bild_eins.png")
self.first_image_label = tk.Label(self.main_frame, image=self.first_image, bd=0, highlightthickness=0)
self.first_image_label.place(relx=0.4, rely=0.511, anchor="center")
# Text für den zweiten Knopf hinzufügen
self.Archiv_image = PhotoImage(file="Archiv_Text.png") # Beispielbild, ersetze es mit deinem Bild
self.Archiv_button = tk.Button(self.Archiv_frame, image=self.Archiv_image, relief="flat",
command=self.zeige_zweite_seite)
self.Archiv_button.pack(pady=10)
# Bild für den zweiten Knopf hinzufügen
self.Sheet_image = PhotoImage(file="Bild_zwei.png")
self.Sheet_image_label = tk.Label(self.main_frame, image=self.Sheet_image, bd=0, highlightthickness=0)
self.Sheet_image_label.place(relx=0.6, rely=0.511, anchor="center")
# Button zum Schließen des Programms hinzufügen
self.close_image = PhotoImage(file="Escape.png")
self.close_button = tk.Button(self.close_frame, image=self.close_image, command=root.destroy, relief="flat")
self.close_button.pack(pady=10)
# Logo einfügen
self.logo_image = PhotoImage(file="logo.png")
self.logo_image_label = tk.Label(self.main_frame, image=self.logo_image, bd=0, highlightthickness=0)
self.logo_image_label.place(relx=0.5, rely=0.2, anchor="center")
def zeige_erste_seite(self):
# Alles im Haupt frame löschen
for widget in self.main_frame.winfo_children():
widget.destroy()
# Erstelle ein Objekt der Klasse für die erste Seite
FirstPage(self.main_frame)
def zeige_zweite_seite(self):
# Alles im Haupt frame löschen
for widget in self.main_frame.winfo_children():
widget.destroy()
# Erstelle ein Objekt der Klasse für die zweite Seite
SecondPage(self.main_frame)
def main():
root = tk.Tk()
app = Hauptfenster(root)
root.mainloop()
if name == "main": main()
first_page.py
import tkinter as tk
from Main_Menu import Hauptfenster
class FirstPage(tk.Frame):
def init(self, parent):
self.parent = parent
self.frame = tk.Frame(self.parent)
self.frame.pack(expand=True, fill='both')
# Neuen Inhalt für die zweite Seite hinzufügen
label = tk.Label(self.frame, text="Das ist die erste Seite")
label.pack()
# Button zum Hauptmenü hinzufügen
self.back_to_main_button = tk.Button(self.frame, text="Zurück zum Hauptmenü", command=self.back_to_main)
self.back_to_main_button.pack()
def back_to_main(self):
# Alles im Frame löschen
for widget in self.frame.winfo_children():
widget.destroy()
# Erstelle ein Objekt der Klasse für das Hauptmenü
Hauptfenster(self.parent)
I wanted to switch between those two while they are on separate files.
Write code to match a specific Big-O-Notation
Programing Coderfunda March 02, 2024 No comments
O(4n · (-2 + 3n) · (n - log(n)) / n) = ?
Simplifying it often gave me either O(n^2) or O(n^3) which would be easy enough to implement but i feel like is not the goal of the challenge.
I've tried directly changing each part into algorithm logic like this:
#include
#include
void Algorithm(int n) {
for (int i = 1; i
01 March, 2024
is not recognized as an internal or external command
Programing Coderfunda March 01, 2024 No comments
operable program or batch file error then i start to search about it i changed my system environment and everything but then i realize that it is not about node js when i try to code there git pull i get the same error again.How can i fix it ??
I'm a frontend web developer and i can not install anything because of that error in docker i can run my laravel project but i cant install locally react,vue,angular vite or anything else please help me to solve it
I want to show a video or Lottie animation for my React Weather App
Programing Coderfunda March 01, 2024 No comments
Thank you
I tried to create another component VideoPlayer.jsx and then put the lottie on it and then add variable and used useEffect:
const VideoPlayer = ({ onVideoEnd }) => {
const [videoLoaded, setVideoLoaded] = useState(false);
useEffect(() => {
const handleVideoLoad = () => {
setVideoLoaded(true);
};
const handleVideoEnded = () => {
if (onVideoEnd) {
onVideoEnd();
}
};
const videoElement = document.getElementById('myVideo');
videoElement.addEventListener('loadeddata', handleVideoLoad);
videoElement.addEventListener('ended', handleVideoEnded);
return () => {
videoElement.removeEventListener('loadeddata', handleVideoLoad);
videoElement.removeEventListener('ended', handleVideoEnded);
};
}, [onVideoEnd]);
give it absolute position and z-index of 1000.
In the return i added
{!videoLoaded &&
Loading video...}
Speed up your Laravel application up to 1000x (with FastCGI cache)
Programing Coderfunda March 01, 2024 No comments
Laravel Gems - About Command
Programing Coderfunda March 01, 2024 No comments
ElementNotInteractableException: element not interactable (When uploading the file by using the CloudFIleOperationUtil )
Programing Coderfunda March 01, 2024 No comments
But I'm getting the element not interactable error.
String uploadFile = "//div[@id='dZUpload']";
String absolutePath = System.getProperty("user.dir") + "\\src\\main\\resources\\uploadFiles\\" + file;
CloudFileOperationUtil.uploadFileToCloud(uploadFile,absolutePath,getDriver());
The same code is working fine when the element is present in the Input tag. But not working when the element is present in the div tag.
Normally the element is clickable only. But when I passing as a parameter the element inside the upload File To Cloud method, I get an error.
So, Please tell me, how to Interact with the element that is present inside the div tag.
I hope, you guys all understand my doubt. If you want some more details to understand my about doubt please ask me.
29 February, 2024
Render mode does not work properly on blazor web assembly .NET 8
Programing Coderfunda February 29, 2024 No comments
@page "/SignIn"
@inject INotificationService _localStorage
@inject NavigationManager _navigationManager
@inject IAuthenticationService _authService
@rendermode @(new InteractiveWebAssemblyRenderMode(prerender: false))
...
@code {
public bool PageLoading { get; set; }
private Models.Notification? Notification { get; set; } = null;
public SignInRequestDto SignInRequest { get; set; } = new();
public bool IsAuthFailed { get; set; }
public string ReturnURL { get; set; }
public string Error { get; set; }
protected override async Task OnInitializedAsync()
{
PageLoading = true;
StateHasChanged();
System.Threading.Thread.Sleep(3000);
await GetNotification();
PageLoading = false;
}
...
So when I am on the Home page and I click "Se connecter" (that means sign in), the page does not goes to the signIn page, but instead stall on the Home page executing the OnInitializeAsync of the SignIn and then when it is finish, it shows finally the SingIn page.
I was expected that prerender: false will fix this but it does nothing.
This is the MainLayout that will redirect to the /SignIn page.
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@inject NavigationManager Navigation
Hello, @context.User.Identity?.Name!
Se déconnecter
Se connecter
@code{
public void BeginLogOut()
{
Navigation.NavigateToLogout(Routes.Disconnect);
}
}
This is the demo:
https://drive.google.com/file/d/15fd0P8a4cuyH1F6rg8B6CN7MBfeSVk16/view?usp=sharing
/>
I expect that I will see the Loading component and the right page (/signin) instead of waiting on page Home before OnInitializeAsync is finished.
Error in module system when registering controlsFX validator for combo box in JavaFX project
Programing Coderfunda February 29, 2024 No comments
This is my code which is causing the error.
ValidationSupport validationSupport = new ValidationSupport();
validationSupport.registerValidator(prefixCombo, Validator.createEmptyValidator("Combobox selection required!"));
This is the error I got when running the project.
Exception in thread "JavaFX Application Thread" java.lang.reflect.InaccessibleObjectException: Unable to make protected javafx.collections.ObservableList javafx.scene.Parent.getChildren() accessible: module javafx.graphics does not "opens javafx.scene" to module org.controlsfx.controls
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
This is my current module-info.java file
module system {
requires javafx.controls;
requires javafx.fxml;
requires jakarta.persistence;
requires org.hibernate.orm.core;
requires MaterialFX;
requires org.slf4j;
requires de.jensd.fx.glyphs.fontawesome;
requires static lombok;
requires org.controlsfx.controls;
requires javafx.graphics;
opens com.example.system to javafx.fxml, org.controlsfx.controls;
exports com.example.system;
exports com.example.system.controller;
opens com.example.system.controller to javafx.fxml, javafx.graphics;
opens com.example.system.entity to org.hibernate.orm.core;
opens com.example.system.tm to javafx.base;
}
I tried adding opens javafx.scene to org.controlsfx.controls; to module-infor.java.
Then, resulted in another error Package not found: javafx.scene
Thank you all in advance!!
Azure Functions Credential uses wrong tenant
Programing Coderfunda February 29, 2024 No comments
No matter what I try, I get this error or similar - always the same tenant which I have no idea where it came from.
Various ways of getting credential:
credential = AzureCliCredential(tenant_id=os.environ["AZURE_TENANT_ID"])
credential = DefaultAzureCredential()
credential = EnvironmentCredential()
I have also tried to set local.settings.json (which sets environment variables)
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AZURE_TENANT_ID": "ad8d36e3-7a5d-4687-bef3-e758fc4f7649",
"AZURE_CLIENT_ID":"xxxxxxxxxxxxxxxx",
"AZURE_CLIENT_SECRET":"xxxxxxxxxxxxxx",
"AZURE_AUTHORITY_HOST":"login.microsoftonline.com"
}
}
The current credential is not configured to acquire tokens for tenant 49793faf-eb3f-4d99-a0cf-aef7cce79dc1. To enable acquiring tokens for this tenant add it to the additionally_allowed_tenants when creating the credential, or add "" to additionally_allowed_tenants to allow acquiring tokens for any tenant.*
It consistently uses the wrong tenant which sometimes appears as "American Airlines" in other error messages.
I have cleared out all the various Azure logins, so the DefaultAzureCredential fails not finding any login configurations.
I have tried:
az login --tenant-id xxx
azd auth login
etc...
This worked recently, and then I had to reboot.
Where is the login logic pulling tenant 49793faf-eb3f-4d99-a0cf-aef7cce79dc1. from ?
How do I get rid of it ?
How to best way to construct a static class member in c++?
Programing Coderfunda February 29, 2024 No comments
Another class Bar which define a static member of class Foo: the Foo member is being initialized (but not constructed).
What's the best way to construct the static member, in other words where or how should I make sure the constructor is called on the static member?
Should I turn to singleton?
// In demo.h
class Foo {
Foo() {
// doing important stuff in there
}
};
class Bar {
static Foo foo;
};
// In demo.cpp
Foo Bar :: foo = Foo();
void main() {
Bar bar;
// bar.foo is not constructed yet. How to do that?
}
Drizzle ORM select return string that isn't a column
Programing Coderfunda February 29, 2024 No comments
SELECT *
FROM (
SELECT 'car' AS type, model FROM car
UNION
SELECT 'truck' AS type, model FROM trucks
) vehicles;
I want to replicate the 'car' as type part in Drizzle so I can distinguish the data being returned without adding a column "type" to both tables and having repetitive data.
Is there a way to do this currently?
08 February, 2024
What's New Video: InsertOrIgnoreUsing, Adding Multiple Global Scopes & Unlink Storage
Programing Coderfunda February 08, 2024 No comments
Ask AI Questions About Your Codebase from the CLI With Laragenie
Programing Coderfunda February 08, 2024 No comments
Laragenie is an AI chatbot with an Artisan console integration for your Laravel applications. It can understand your source code by indexing directory/file paths. You can then ask questions about your code such as "Describe all the model associations for the App\Models\Post model".
Here's an example of how you can configure the indexes in your configuration file. It works by indexing your configured files with an AI model using OpenAI to generate responses and Pinecone to index data:
// config/laragenie.php
return [
// ...
'indexes' => [
'directories' => ['App/Models', 'App/Http/Controllers'],
'files' => ['tests/Feature/MyTest.php'],
'removal' => [
'strict' => true,
],
],
];
Once you’ve installed this package, you can index your files, clear the index, and ask questions by running the laragenie command:
Ask questions about your code from the command line.
Note that the files you index and ask questions about needn’t be only PHP files! You can also index and ask questions about your JavaScript, GitHub workflows, etc. The neat thing about this CLI is that it’s not generic answers; it’s specifically helpful to answer questions about your unique codebases.
Using AI models is a valuable way to speed up tedious tasks. It can be helpful in onboarding developers new to a project and getting general knowledge about an unfamiliar codebase more rapidly.
This package is available on Github at joshembling/laragenie and installable via composer:
composer require --dev joshembling/laragenie
The post Ask AI Questions About Your Codebase from the CLI With Laragenie appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
Exception "No successful match so far" after Matcher.find() == true
Programing Coderfunda February 08, 2024 No comments
if(m.find()){
...
m.start()
...
}
I wonder how it is possible for the m.start() in the above code to throw the following exception:
Exception: No successful match so far
Class: java.lang.IllegalStateException
Stack trace: java.lang.IllegalStateException: No successful match so far
at java.util.regex.Matcher.ensureMatch(Matcher.java:1116)
at java.util.regex.Matcher.start(Matcher.java:1158)
at java.util.regex.Matcher.start(Matcher.java:1130)
Could anyone shed some light on this?
07 February, 2024
Updating associated items in Sequelize
Programing Coderfunda February 07, 2024 No comments
Basically I have a table "invoices". Those invoices have a table "invoiceItems" associated to them as one invoice to many invoiceItems.
Now I have a route where users can update invoices. The part I cant figure out is how to handle when they update, add, or delete invoiceItems. The front end would be able to send me a JSON object containing all of the data including the IDs for the invoice and the invoiceItems (except the new ones of course). The goal is to update the existing invoice and associated invoiceItems with the new object sent from the front end. I can use the object to create a new invoice no problem, but updating has proven very complicated for me.
My create statement works and looks like this, I would love something similar for update, but I am starting to understand that might not be possible
db.invoice.create(
req.newInvoice, {
include:[
db.invoiceItem
]
}
)
I have tried using transactions as well as mixin methods like set/add/remove etc. With limited success and anything that comes close has so many nested loops comparing the versions it makes my head spin. Is there an easier way to achieve this that I have over looked?
Here's my pared down models for you to see in case it helps:
invoices
module.exports = (sequelize, Sequelize, DataType) => {
const Invoice = sequelize.define('invoice', {
id: {
type: DataType.UUID,
primaryKey: true,
defaultValue: Sequelize.literal( 'uuid_generate_v4()' )
},
userId: {
type: DataType.UUID,
},
createdAt: {
type: DataType.DATE
},
UpdatedAt: {
type: DataType.DATE
}
},{
underscored: true
});
Invoice.associate = models => {
Invoice.hasMany(models.invoiceItem), {
foreignKey: "invoiceId",
onDelete: 'cascade'
}
Invoice.belongsTo(models.user, {
foreignKey: "userId"
})
};
return Invoice
};
invoiceItems
module.exports = (sequelize, Sequelize, DataType) => {
const InvoiceItem = sequelize.define('invoiceItem', {
id: {
type: DataType.UUID,
primaryKey: true,
defaultValue: Sequelize.literal( 'uuid_generate_v4()' )
},
invoiceId: {
type: DataType.UUID,
},
userId: {
type: DataType.UUID,
createdAt: {
type: DataType.DATE
},
updatedAt: {
type: DataType.DATE
}
},{
underscored: true
});
InvoiceItem.associate = models => {
InvoiceItem.belongsTo(models.invoice, {
foreignKey: "invoiceId"
})
InvoiceItem.belongsTo(models.user), {
foreignKey: "userId"
}};
return InvoiceItem
};
Thanks in advance for any help/ideas!
Is there a way to write a JavaScript program that enables you to Search Words in Multiple PDF Files?
Programing Coderfunda February 07, 2024 No comments
Basically it's just like the Adobe Acrobat's Advance Search option. I just need to create a similar program but much simpler. It's a project for school. Please help.
JavaScript is my preferred language but if you have any ideas from a different programming language, I'm open to it.
If you can send me links of blogposts or YouTube videos it will be much appreciated.
Thank you so much!
I have already tried this:
https://apryse.com/blog/indexed-search/search-multiple-documents-using-javascript but I can't seem to make it work. An error occurs in installing the package. And this is the only thing out there that's very close to what I'm trying to achieve.
Command CodeSign failed with a nonzero exit code in flutter debug
Programing Coderfunda February 07, 2024 No comments
What do you actually do with Laravel?
Programing Coderfunda February 07, 2024 No comments
I work for a company that have both shared and dedicated servers for their clients, and we mostly create standard website or intranet sites for comparitively low traffic audiences. So the projects usually follow a classic style (db-> front end or external api -> front end) with no need for these extras. The most I've done is a TALL stack plus Filament. And these projects are pretty solid - they're fast, efficient (more efficient recently thanks to better solutions such as Livewire and ES module-bsased javascript). But I feel like I'm out of date because I generally don't understand a lot of these other things, and I don't know when I'd ever need to use them over what I currently work with.
So my question is, what types of projects are you all working on? How advanced are these projects? Do you eveer do "classic" projects anymore?
Am I in the minority, building classic projects?
How can I improve my projects if what I'm doing already works well? I feel like I'm getting left behind a bit.
Edit: Thanks for the replies. Interesting to see all the different points of view. I'm glad I'm not the only one. submitted by /u/No-Echo-8927
[link] [comments]