CoderFunda
  • Home
  • About us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • About us
  • Home
  • Php
  • HTML
  • CSS
  • JavaScript
    • JavaScript
    • Jquery
    • JqueryUI
    • Stock
  • SQL
  • Vue.Js
  • Python
  • Wordpress
  • C++
    • C++
    • C
  • Laravel
    • Laravel
      • Overview
      • Namespaces
      • Middleware
      • Routing
      • Configuration
      • Application Structure
      • Installation
    • Overview
  • DBMS
    • DBMS
      • PL/SQL
      • SQLite
      • MongoDB
      • Cassandra
      • MySQL
      • Oracle
      • CouchDB
      • Neo4j
      • DB2
      • Quiz
    • Overview
  • Entertainment
    • TV Series Update
    • Movie Review
    • Movie Review
  • More
    • Vue. Js
    • Php Question
    • Php Interview Question
    • Laravel Interview Question
    • SQL Interview Question
    • IAS Interview Question
    • PCS Interview Question
    • Technology
    • Other

07 January, 2024

Flutter-When i am changing value in respiratoryRate case and there i applied a setState after that i want to rebuild 'issue' case

 Programing Coderfunda     January 07, 2024     No comments   

var _respiratoryRate=0;

switch (cardioVascularWidget.key) {
case 'respiratoryRate':
VitalComponent? respiratoryRate = widget
.cardiovascularFormModel?.cardiovascularAssessment?.respiratoryRate;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomInputTextFormField(
titleText: respiratoryRate?.title ?? "",
hintText: respiratoryRate?.hintText ?? "",
trailingInputUnitText: respiratoryRate?.suffixValue ?? "",
isTitleRequired: true,
isTitleMandatory: true,
onEnteredValue: (value) {
setState(() {
_respiratoryRate = value;
});
},
),
],
);
case 'issue':
Issue? issue =
widget.cardiovascularFormModel?.cardiovascularAssessment?.issue;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TitleMandatoryWidget(isMandatory: false, title: '${issue?.title}'),
Text('$_respiratoryRate'),
],
);
}



In the switch case, you can see there I have a case 'respiratoryRate' in which have CustomInputTextFormField it return value inside onValueChange then i apply a

setState(() { _respiratoryRate = value ; });
and other switch case is 'issue' is there, i want to rebuild issues case
Anyone please help me
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Filtering Pivot Field using VBScript

 Programing Coderfunda     January 07, 2024     No comments   

I'm trying filter the field "Ödeme_Tarihi" by yesterday's date. Standart Autofilter didn't work.


enter image description here


I tried below code but it gives that error;
enter image description here


Code;
Dim oExcel
Dim myPivotField
Dim PvtItm

Function CnvTr(str)
str = Replace(str, "İ", ChrW(304))
str = Replace(str, "ı", ChrW(305))
str = Replace(str, "Ç", ChrW(199))
str = Replace(str, "ç", ChrW(231))
str = Replace(str, "Ğ", ChrW(286))
str = Replace(str, "ğ", ChrW(287))
str = Replace(str, "Ö", ChrW(214))
str = Replace(str, "ö", ChrW(246))
str = Replace(str, "Ş", ChrW(350))
str = Replace(str, "ş", ChrW(351))
str = Replace(str, "Ü", ChrW(220))
str = Replace(str, "ü", ChrW(252))
CnvTr = str
End Function

Set oExcel = CreateObject("Excel.Application")

oExcel.Visible = True
oExcel.DisplayAlerts = False
oExcel.AskToUpdateLinks = False
oExcel.AlertBeforeOverwriting = False

Set oWorkbook = oExcel.Workbooks.Open("C:\\RobustaDocs\\OdemeListesi.xlsx")
Set myPivotField = oWorkbook.WorkSheets(2).PivotTables("PivotTable1").PivotFields(CnvTr("\[Workbook\].\[Ödeme_Tarihi\]"))

oWorkbook.RefreshAll
myPivotField.ClearAllFilters
myPivotField.VisibleItemsList = Array(CnvTr("\[Workbook\].\[Ödeme_Tarihi\].&\[5.01.2024\]"))

Set myPivotField = Nothing
Set PvtItm = Nothing
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

06 January, 2024

Access denied error using move-item to recursively move folders containing files with specific text

 Programing Coderfunda     January 06, 2024     No comments   

I'm scratching my head on this one and haven't found anything that gets it working.


I have a folder tree with a root1\yyyy\mm\dd\hh\uniqueid structure and need to move the uniqueid sub folders into a root2\yyyy\mm\dd\hh tree based on content within a specific json file in each uniqueid folder


After several searches I've arrived at the code below which is correctly identifying the folders I need to move, and creating the root2\yyyy\mm\dd\hh folders to hold the moved uniqueid folders, but it gives an access denied error trying to execute the move cmdlet
$root1 = My-Current-Root-Folder
$root2 = My-New-Root-Folder
(Get-ChildItem -Literalpath $root1 -Recurse -Filter *.json) | Select-String -Pattern content-I-am-looking-for | ForEach-Object {
$folderToMove = (Split-Path -Parent $_.Path)
$destinationFolder = $folderToMove.Substring(0, $folderToMove.Length - 33).Replace($root1 , $root2)
write-host $folderToMove #This correctly displays the source folders I need to move
write-host $destinationFolder #This correctly displays the root2 folder structure to hold the moved folders
If(!(Test-Path $destinationFolder)){
New-Item -Path $destinationFolder -ItemType "directory" #This correctly created the root2 folders for the move
}

move-item -path $folderToMove -destination $destinationFolder -Force
}



The error is like this:
move-item : Access to the path '$root1\2023\10\19\01\uniqueid' is denied.


But if I execute a move-item command explicitly specifying one of the uniqueid folders and the associated root2\yyyy\mm\dd\hh destination, the folder is moved without any issue.


All advice greatly appreciated


Tried wrapping the source and destination in double quotes in case that was needed and also specifying [string] on the source and destinations, but that just gives a different error (cannot find a drive F)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Triangular linear system with triangular right hand side in python

 Programing Coderfunda     January 06, 2024     No comments   

I have to solve a linear system of equations with multiple right hand sides, A*X=B, where both, A and B are (upper) triangular, real, square matrices. The size is about 200 by 200. Is there a fast method for this in python/numpy?


I was considering looping over the columns,
n=A.shape[0]
X=zeros((n,n))
for i in range(n):
X[:i+1,i]=solve_triangular(A[:i+1,:i+1],B[:i+1,i])



But this does not use fast matrix-matrix operations.


I could also do all right hand sides simultaneously, X=solve_triangular(A,B), but this does not take into account the triangular structure in B.


Finally, I could invert A and multiply with B, X=inv(A)@B, but inverting matrices is usually discouraged from.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel Wallet

 Programing Coderfunda     January 06, 2024     No comments   

Hi!
I recently completed the documentation for my Laravel Wallet package and would like to receive feedback on the implementation, if you would be so kind :)

The main objective of this package is to provide a reliable and convenient mechanism for transactions and balances.

Github | Documention

​ submitted by /u/GiveMeYourSmile
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Z-Function. String algorithms. Optimize for large strings

 Programing Coderfunda     January 06, 2024     No comments   

The problem:



Given a string s. For each i from 1 to |s|, find the number of occurrences of its prefix of length i in the string.


Input:

The first line of input contains an integer q (1≤q≤10^5) — the number of datasets in the test.


Each dataset consists of a string s. The length of the string s is from 1 to 10^6 characters. The string consists exclusively of lowercase Latin alphabet letters.


The sum of the lengths of strings s across all q datasets in the test does not exceed 10^6.


Output:

For each dataset, output |s| integers c1, c2, ..., c|s|, where c[i] is the number of occurrences of the prefix of length i in the string s.


Example


Input:
5
abacaba
eeeee
abcdef
ababababa
kekkekkek



Output:
4 2 2 1 1 1 1
5 4 3 2 1
1 1 1 1 1 1
5 4 4 3 3 2 2 1 1
6 3 3 2 2 2 1 1 1



The task must be solved exclusively using the Z-function, and the total time for a string of length 10^6 characters should not exceed 2 seconds.



My solution looks like this:
#include
#include
#include

std::vector ZFunc(const std::string& s) {
const int sz = s.size();
std::vector z(sz, 0);

for (int i = 1, l = 0, r = 0; i != sz; ++i) {
if (r >= i)
z[i] = std::min(z[i - l], r - i + 1);

while (z[i] + i < sz && s[i + z[i]] == s[z[i]])
z[i]++;

if (z[i] > r - i + 1) {
l = i;
r = i + z[i] - 1;
}
}

return z;
}

int main() {
int n;
std::cin >> n;

std::vector res(n);

for (int k = 0; k != n; ++k) {
std::string s;
std::cin >> s;

res[k].resize(s.size(), 1);
std::vector z = ZFunc(s);

for (int i = 1; i != z.size(); ++i) {
while (z[i]--)
res[k][z[i]]++;
}
}

for (const auto& ivec : res) {
for (int i : ivec)
std::cout
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

I have a _ctx.product is undefined

 Programing Coderfunda     January 06, 2024     No comments   

I have a Nuxt3 application. And inside a file named ProductList.vue which contains a list of products which returns a name, description, image...
When I try to create a [productId].vue file I get an error _ctx.product is undefined I don't understand why. Thanks for your help


What I tried


ProductList.vue



Filtrer par catégorie




Voir tout

{{ category }}







*






{{ product.category }}





View details for {{ product.title }}






{{ product.title }}




{{ product.price }}










export default {
data() {
return {
selectedCategory: "", // Ajoutez cette propriété
products: [
{ id: 1, title: 'Candy Land', price: '120€ / jour - 180€ / 2 jours', description: 'loremipsum set', image: 'candy.jpg', category: 'Chateaux Gonflables' },
{ id: 2, title: 'Château Fort', price: '100€ / jour - 160€ / 2 jours', description: 'lorem ipsum set', image: 'chateau_fort.jpg', category: 'Chateaux Gonflables' },

],
...
},
...




[productId].vue



{{ product.title }}




{{ product.description }}



export default {
async asyncData({ params }) {
const productId = parseInt(params.productId);
const product = products.find((p) => p.id === productId);

return { product };
},
};
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

05 January, 2024

I'm getting an unexpected Tensorflow ResourceExhaustedError when I try to use model.predict() with a Keras Sequential model

 Programing Coderfunda     January 05, 2024     No comments   

I'm using Python 3.9, and I have Tensorflow 2.10 installed with CUDA Toolkit 11.2 and cuDNN 8.2, as this was the last configuration to be supported natively on Windows 10.


I'm training using an NVIDIA GeForce RTX 2070 SUPER with 8Gb of VRAM, and I have 64 Gb of RAM on my PC.


I've used Keras to create a Sequential model to predict POS-tags. I've used the same model format to train models for text in several different languages. The models all trained alright, and when I run model.evaluate(test_data) they all produce a score. Similarly, when I run model.predict(test_data) most models produce the expected results, but there is one model, for one language, which acts differently.


This one model was trained the same as all the other models, so there should be no difference I think. When I run model.predict(test_data) using this model, at first it seems to be working. It starts applying the model to the dataset:
6/152 [=>............................] - ETA: 19s



It even appears to successfully complete this step, though it never gets as far as producing any results:
152/152 [==============================] - 20s 126ms/step



Unfortunately at this point it hangs and produces the following traceback:
2024-01-05 23:08:38.977923: W tensorflow/core/common_runtime/bfc_allocator.cc:479] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.61GiB (rounded to 2804106240)requested by op ConcatV2
If the cause is memory fragmentation maybe the environment variable 'TF_GPU_ALLOCATOR=cuda_malloc_async' will improve the situation.
Current allocation summary follows.
...
...
...
2024-01-05 23:08:38.998922: I tensorflow/core/common_runtime/bfc_allocator.cc:1101] Sum Total of in-use chunks: 4.04GiB
2024-01-05 23:08:38.998977: I tensorflow/core/common_runtime/bfc_allocator.cc:1103] total_region_allocated_bytes_: 6263144448 memory_limit_: 6263144448 available bytes: 0 curr_region_allocation_bytes_: 8589934592
2024-01-05 23:08:38.999071: I tensorflow/core/common_runtime/bfc_allocator.cc:1109] Stats:
Limit: 6263144448
InUse: 4335309312
MaxInUse: 4520417536
NumAllocs: 1293
MaxAllocSize: 536870912
Reserved: 0
PeakReserved: 0
LargestFreeBlock: 0

2024-01-05 23:08:38.999241: W tensorflow/core/common_runtime/bfc_allocator.cc:491] ****************x*****************************************************______________________________
2024-01-05 23:08:38.999336: W tensorflow/core/framework/op_kernel.cc:1780] OP_REQUIRES failed at concat_op.cc:158 : RESOURCE_EXHAUSTED: OOM when allocating tensor with shape[38688,18120] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
Traceback (most recent call last):
File "C:\Users\admd9\PycharmProjects\codalab-sigtyp2024\generate_results.py", line 131, in
predictions = task_model.predict(test_gen)
File "C:\Users\admd9\anaconda3\envs\tf_codalab_sharedtask\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\admd9\anaconda3\envs\tf_codalab_sharedtask\lib\site-packages\tensorflow\python\framework\ops.py", line 7209, in raise_from_not_ok_status
raise core._status_to_exception(e) from None # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.ResourceExhaustedError: {{function_node __wrapped__ConcatV2_N_152_device_/job:localhost/replica:0/task:0/device:GPU:0}} OOM when allocating tensor with shape[38688,18120] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc [Op:ConcatV2] name: concat



I can't work out why it's only happening with this one model, or why there would be a problem with memory allocation when it works for all the other models. It doesn't seem like it's trying to use a lot of memory either. So why am I getting this error message? And, how can I fix it?


I've tried setting memory growth, but it didn't work:
physical_devices = tf.config.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(physical_devices[0], True)



I've also reduced batch sizes. This didn't help. I've even gone back and retrained the model in case there was something wrong with the model itself. Still have the same problem with the new model. As a last option, I tried splitting the test set into smaller divisions, running model.predict(test_data) on each of these divisions, then recombining the results of each division. It sometimes successfully predicts the first division, but always runs out of memory and gives me the same error by the second division.


Is there anything I can do?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Get parameters for currently running queries in PostgreSQL

 Programing Coderfunda     January 05, 2024     No comments   

We wrote a small tool which displays all currently running queries. We get the currently running queries from pg_stat_activity.



The problem is: We dont know the parameters which were given to the query. We can only see the placeholders $1, $2, etc.



Is there any way to get the parameters for a currently running query?



The only workaround could be to enable the query log and parse the parameters from the query log, but this would be a very dirty and slow solution.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Alpine adds a new build to work with Content Security Policies

 Programing Coderfunda     January 05, 2024     No comments   

---



Caleb Porzio announced that Alpine.js now has a CSP build that will with environments where CSP is required:



In order for Alpine to be able to execute plain strings from HTML attributes as JavaScript expressions, for example x-on:click="console.log()", it needs to rely on utilities that violate the "unsafe-eval" Content Security Policy that some applications may enforce for security purposes.


In order to accommodate environments where this CSP is necessary, Alpine offer's an alternate build that doesn't violate "unsafe-eval", but has a more restrictive syntax.



One thing to note with this new build is you must Alpine.data:



Since Alpine can no longer interpret strings as plain JavaScript, it has to parse and construct JavaScript functions from them manually.


Due to this limitation, you must use Alpine.data to register your x-data objects, and must reference properties and methods from it by key only.



This new build is available as a CDN or an npm install @alpinejs/csp


See the official documentation for complete details and for detailed instructions.


Note: When asked about Livewire support, Caleb says, "Not yet unfortunately because there is one or two places Livewire relies on eval (wire:click="something('one', 'two')") kinda thing"



The post Alpine adds a new build to work with Content Security Policies appeared first on Laravel News.


Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Integrating Cloudflare R2 with Laravel

 Programing Coderfunda     January 05, 2024     No comments   

Hey everyone!

We swapped out AWS S3 for Cloudflare R2 in our Laravel app – the bandwidth costs were getting steep.

We've put together a thorough blog post about it, so go ahead and check it out.

Hit me up if you've got any questions!


https://www.luckymedia.dev/blog/integrating-cloudflare-r2-storage-with-laravel submitted by /u/lmusliu
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Localhost for Mail server?

 Programing Coderfunda     January 05, 2024     No comments   

Curious to see what are the options to run email server locally. I believe I had one with Laragon setup on windows but I wonder if there is anything like that for Mac? Like it would setup SMTP or some similar service locally and all your email would show up there. Any free/open source service like that? submitted by /u/TastyInternet
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

04 January, 2024

Syntax error in the code creating a PostgreSQL procedure

 Programing Coderfunda     January 04, 2024     No comments   

CREATE OR REPLACE FUNCTION
Cree_RefFacture()
RETURNS trigger
AS
$BODY$
BEGIN
NEW."RefFacture" := nextval("dbo.Base_Factures_RefFacture_seq");
RETURN NEW;
END;
$BODY$
LANGUAGE plpgsql;



I get syntax error on this line :

Syntax error on or near “NEW”
LINE 7:NEW."RefFacture":=nextval"dbo.Base_Factures_RefFacture_seq");




Something wrong in your opinion?


I've tried various solutions, I keep getting the same error. Could you help me please
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

R: Pattern matching one column to a json string stored in another column

 Programing Coderfunda     January 04, 2024     No comments   

I have a dataframe of untidy data: TX_JAN_2019_DF


This dataframe contains a columns TX_JAN_2019_DF$AREA (type: numeric) and TX_JAN_2019_DF$DEVICE_HOME_AREA (type: character)


TX_JAN_2019_DF$AREA[1] produces:[1] 481210216382


TX_JAN_2019_DF$DEVICE_HOME_AREA[1] produces a sample of the string (for this benefit of this post, this output is greatly reduced):


"{\"481210216382\":307,\"481210216371\":50,\"481210216381\":43,\"481130137213\":35,\"481210216373\":27,\"481130137222\":21,\"481210216154\":21,\"481210216152\":17,\"481210216133\":15,\"481210216372\":4}"


As you can see the json string is a string of values type character. I need to pattern match the first column TX_JAN_2019_DF$DEVICE[1], to see if the second column element TX_JAN_2019_DF$DEVICE_HOME_AREA[1] and the json string stored in that element contains the pattern and if it does, what is the number after the colon (307 for example in the first element).


Then of course do this for all columns TX_JAN_2019_DF$DEVICE_HOME_AREA


I'm at a loss on how to do this as the json adds a complication to normal pattern matching. I've looked at the jsonlite library, but the examples are not much help.


Thank you in advance
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Use Model shouldBeStrict when starting a new Laravel app

 Programing Coderfunda     January 04, 2024     No comments   

---



So you have an idea for a brand new app. You install Laravel, you're ready to get started. What's the first thing you should do?


For me, I open up the app service provider and go down to the boot method and set the global Model::shouldBeStrict():
public function boot(): void
{
Model::shouldBeStrict();
}



With this turned on it does the following:
public static function shouldBeStrict(bool $shouldBeStrict = true)
{
static::preventLazyLoading($shouldBeStrict);
static::preventSilentlyDiscardingAttributes($shouldBeStrict);
static::preventAccessingMissingAttributes($shouldBeStrict);
}



This does three things:



* Prevents lazy loading

* It prevents silently discarding attributes.

* It prevents accessing missing attributes.






Preventing Lazy Loading




Here is an example of lazy loading.
$articles = \App\Models\Article::get();

foreach ($articles as $article) {
echo " * " . $article->user->name . "
\n";
}



If you run this, it will output what you expect. However, it’s lazy loading the user relationship, causing a new query for every loop.


With shouldBeStrict turned on instead of running the code you’ll get an error giving you instant feedback:
Attempted to lazy load [user] on model [App\Models\Article] but lazy loading is disabled.



Prevent Silently Discarding Attributes




Here is an example showing trying to update an attribute that is not fillable:
$user->fill(["remember_token" => "bar"]);



Now this will return an exception:
Add fillable property [remember_token] to allow mass assignment on [App\Models\User].



Prevent Accessing Missing Attributes.




Let’s pretend we are trying to display a property on the User that may not exist:
{{ $user->nonexistant }}



By default, Laravel will just not display anything because the property is not found, but with Strict mode turned on you get:
The attribute [nonexistant] either does not exist or was not retrieved for model [App\Models\User].



This really helps in cases where you might make a spelling mistake like:
{{ $user->emial }}



Now, you’ll get instant feedback you messed up.


Turning on Model::shouldBeStrict() is now the first thing I do on every app, and it helps prevent me from making basic mistakes that could be harmful to the app later on.



The post Use Model shouldBeStrict when starting a new Laravel app appeared first on Laravel News.


Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Advanced Laravel Repository

 Programing Coderfunda     January 04, 2024     No comments   

Hello friends,

I wanted to introduce you to a package I recently wrote.

​

This package is to facilitate and speed up the development of Laravel in the implementation of the repository pattern for models.

for more information, see documentation link. submitted by /u/thunder11like
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Generate PDFs in Laravel from Blade Views

 Programing Coderfunda     January 04, 2024     No comments   

---



The Laravel PDF package by Spatie provides a simple way to create PDFs in Laravel Apps. It uses Blade views to render HTML and create a PDF from that view using Browsershot. This opens up the ability to use modern CSS tools like Grid and Flexbox, modern CSS frameworks like Tailwind, and even JavaScript code for things like rendering charts.


Here's a basic example of creating a PDF and returning it from a controller, passing variables to the template that you can use to dynamically render the PDF data:
use Spatie\LaravelPdf\Facades\Pdf;

class DownloadInvoiceController
{
public function __invoke(Invoice $invoice)
{
return Pdf::view('pdfs.invoice', ['invoice' => $invoice])
->format('a4')
->name('your-invoice.pdf');
}
}



At launch, the Laravel PDF package supports the following features:



* Render PDFs from Blade templates or an HTML string

* Save a generated PDF to a Laravel disk

* Run JavaScript code when the PDF is created

* PDF testing fake with powerful assertions

* Generate PDFs on Lambda via Laravel Sidecar

* Advanced PDF control with tools like page breaks, Browsershot customization

* And more...






Creating PDFs in Laravel with Blade will make generating beautiful custom PDFs easier and more powerful than ever! To get started, check out the official Laravel PDF documentation. The source code is available on GitHub at spatie/laravel-pdf.



The post Generate PDFs in Laravel from Blade Views appeared first on Laravel News.


Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

03 January, 2024

DataSnap - how to change SELECT query to show different data?

 Programing Coderfunda     January 03, 2024     No comments   

In DataSnap, I have a server and client. In the client, I use this code to show data in a TDBGrid:
ClientDataSet1.CommandText := 'SELECT * from table_name WHERE autoid = 10';
ClientDataSet1.Open;
ClientDataSet1.Refresh;



But when I want to change this, the TDBGrid is not showing different data, it still shows data from my first code:
ClientDataSet1.CommandText := 'SELECT * FROM table_name WHERE autoid = 1';
ClientDataSet1.Open;
ClientDataSet1.Refresh;



How can I fix it?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Is there any way to observe all data attributes in a custom component?

 Programing Coderfunda     January 03, 2024     No comments   

I'm trying to use vanilla javascript to build a custom component which observes changes in all data attributes, e.g.:
class MyComponent extends HTMLElement {

static get observedAttributes () {
return ["data-one","data-two","data-three",so forth...]
}

}



This component could in theory be assigned an arbitrary number of data attributes, so there's no way to predict exactly how many there would be, yet I need the component to do stuff every time a new data attribute is assigned to it, is there any way to do it? having to put into the array returned by "observedAttributes" the specific name of every attribute seems really restrictive


As a bonus, is there any way to observe attributes that don't have a specific name but follow a certain pattern? (e.g. they match against a regex string or something like that)


And as an extra bonus, is there any way to observe all attributes? (I know they made this not be the default behavior due to performance factors, but still it would be good to be able to enable it if needed)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to remove specific characters from select column in Snowflake

 Programing Coderfunda     January 03, 2024     No comments   

I have loaded data into table using copy into from stage file(CSV).
+--------------------------------------------------------------------+--------+
| STRING | RESULT |
+--------------------------------------------------------------------+--------+
| hhhhrerererereNRD\r\n\r\nthe 193how (test) testtest peo\r\n\r\n | 30.00 |
+--------------------------------------------------------------------+--------+



my select query expected output is like below:
+---------------------------------------------------------+--------+
| STRING | RESULT |
+---------------------------------------------------------+--------+
| hhhhrerererereNRDthe 193how (test) testtest peo | 30.00 |
+---------------------------------------------------------+--------+



I have tried following option like :
SELECT
regexp_replace(STRING,'\r\n\r\n','')
FROM test;



It is not producing expected output.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel SQS DLQ

 Programing Coderfunda     January 03, 2024     No comments   

Hey laravel folks,

​

We are currently in the process of migrating to AWS and we are thinking about using SQS for the queue driver. We created DLQ for the queues we created but it seems it's not needed since laravel internally stores the failed jobs in the `failed_jobs` table in database? Is my assumption correct and should we just not create DLQ on sqs for the queues?

​

Thank you! submitted by /u/g00g00li
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to fill out existing PDF?

 Programing Coderfunda     January 03, 2024     No comments   

Hey all. Looking for some help.

I’m building an application that needs to dynamically generate 1099 tax forms for contractors. I’d love to be able to just lay text on top of the existing PDF form from the IRS, even if it’s just by using x and y coordinates to target the specific fields, since the file is not directly editable.

Is there an easy way of doing this? I’m very familiar with the Laravel-dompdf package (
https://github.com/barryvdh/laravel-dompdf), but I don’t believe this is possible.

Should I just build my own version of the IRS form and generate the entire thing from scratch? I’m just not sure if that’s frowned upon by the IRS and/or compliant.

Any direction would be appreciated. Thanks! submitted by /u/brycematheson
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

02 January, 2024

How to fetch data server-side in the latest Next.js? Tried getStaticProps but it's not running and getting undefined

 Programing Coderfunda     January 02, 2024     No comments   

I am working on a Django Rest Framework with Next.js, and I am getting stuck with fetching data from the API. I have data in this url
http://127.0.0.1:8000/api/campaigns and when I visit the url I see the data.


The problem is when I fetch and console the data with Next.js, I get undefined. Also when I try mapping the data, I get the error:



Unhandled Runtime Error


Error: Cannot read properties of undefined (reading 'map')



Here is my Index.js file where the data fetching is done:
import React from 'react'

export default function Index ({data}) {
console.log(data)
return (




Available Campaigns


{data.map((element) =>







)}


);
}

export async function getStaticProps() {
const response = await fetch("
http://127.0.0.1:8000/api/campaigns");
const data = await response.json();
return {
props: {
data: data
},
}
}



Here is a screenshot of the data I am getting when I visit the URL:





Here is the file structure for the Next.js app inside the front end:





Also, note that I am using the latest version of Next.js. Any help will be highly appreciated. Thanks.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Prevent default (ionChange) ion-checkbox

 Programing Coderfunda     January 02, 2024     No comments   

What i´m trying to do is to prevent default event on (ionChange).



I want to be able to set the checkbox checked= true or checked= false



If a condition is true or false.


{{classroom.name}}





---


updateClassroom(item, cbox: Checkbox){
//cbox.preventDefault(); ------> Not Work

if(something){
cbox.checked = true
}else{
cbox.checked = false
}
}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Easily create PDFs in Laravel apps

 Programing Coderfunda     January 02, 2024     No comments   

submitted by /u/freekmurze
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Any good AI tools that stay up-to-date with the latest versions of Laravel or Livewire or related resources

 Programing Coderfunda     January 02, 2024     No comments   

I've been trying to solve a particular problem for a while now with filament. Sometimes AI tools help get me where i need to be, but when they are outdated in their reference material, it can create more confusion if there is considerable code change

I've tried a few including the one on laracast, chat gpt, and codieum but they seem to be only updated to livewire v2-- and therefore filament v2 submitted by /u/jcc5018
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Add Primevue Theme To Laravel InertiaJs

 Programing Coderfunda     January 02, 2024     No comments   

Link to the tutorial


https://dev.to/xtreme2020/add-primevue-theme-to-laravel-inertiajs-1n7b

Link to the repo


https://github.com/xtreme2020/laraprimevue submitted by /u/xtreme_coder
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

01 January, 2024

issue inserting data to joining table of many to many in ef core and dotnet 8

 Programing Coderfunda     January 01, 2024     No comments   

I have my models configured as below:
public class Order
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string UserId { get; set; } = null!;
public DkUser User { get; set; } = null!;
public int ShippingStatusId { get; set; }
public ShippingStatus ShippingStatus { get; set; } = null!;
public DateTime CreatedDate { get; set; }
public DateTime UpdatedDate { get; set; }
public string? CreatedBy { get; set; }
public string? UpdatedBy { get; set; }
public ICollection Products { get; set; } = new List();
public ICollection OrderDetails {get; set;} = [];

}

public class Product
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Brand { get; set; } = string.Empty;
public string Model { get; set; } = string.Empty;
public float Price { get; set; }
public int View { get; set; }
public int CategoryId { get; set; }
public Category? Category { get; set; }
public int DiscountId { get; set; }
public Discount Discount { get; set; } = null!;
public DateTime CreatedDate { get; set; }
public DateTime UpdatedDate { get; set; }
public string? CreatedBy { get; set; }
public string? UpdatedBy { get; set; }
public ICollection Orders { get; set; } = new List();
public ICollection OrderDetails { get; set; } = [];
public ICollection ProductPictures { get; set; } = new List();
}

public class OrderDetail
{
public int ProductId { get; set; }
public Product Product { get; set; } = new();
public int OrderId { get; set; }
public Order Order { get; set; } = new();
public int Amount { get; set; }
}

class DkdbContext(DbContextOptions options) : IdentityDbContext(options)
{
public DbSet Computers { get; set; }
public DbSet Products { get; set; }
public DbSet Categories { get; set; }
public DbSet Orders { get; set; }
public DbSet Discounts { get; set; }
public DbSet ShippingStatuses { get; set; }
public DbSet ProductPictures { get; set; }
public DbSet DkUsers { get; set; }
public DbSet OrderDetails { get; set; }

protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);

builder.Entity()
.HasKey(c => c.Id);
builder.Entity()
.Property(c => c.Id)
.HasColumnType("uuid");

builder.Entity()
.HasMany(e => e.Products)
.WithOne(e => e.Category)
.HasForeignKey(e => e.CategoryId)
.IsRequired();

builder.Entity()
.HasOne(e => e.Discount)
.WithMany(e => e.Products)
.HasForeignKey(e => e.DiscountId)
.IsRequired();

builder.Entity()
.Property(e => e.CreatedDate)
.HasDefaultValueSql("current_timestamp");
builder.Entity()
.Property(e => e.UpdatedDate)
.HasDefaultValueSql("current_timestamp");
builder.Entity()
.Property(e => e.View)
.HasDefaultValue(1);

builder.Entity()
.Property(e => e.CreatedDate)
.HasDefaultValueSql("current_timestamp");
builder.Entity()
.Property(e => e.UpdatedDate)
.HasDefaultValueSql("current_timestamp");
builder.Entity()
.Property(e => e.ShippingStatusId)
.HasDefaultValue(1);

builder.Entity()
.HasOne(e => e.Product)
.WithMany(e => e.ProductPictures)
.HasForeignKey(e => e.ProductId)
.IsRequired();

// order detail config
builder.Entity()
.HasMany(e => e.Orders)
.WithMany(e => e.Products)
.UsingEntity();

builder.Entity()
.Property(e => e.Amount)
.HasDefaultValue(1);

// end order detail config

builder.Entity()
.HasMany(e => e.Orders)
.WithOne(e => e.ShippingStatus)
.HasForeignKey(e => e.ShippingStatusId);

builder.Entity()
.HasMany(e => e.Orders)
.WithOne(e => e.User)
.HasForeignKey(e => e.UserId);
}
}




i want to create a new order with 2 products and corresponding amount specified. here is how i implement it:
public class OrderEnpoint
{
public static void Map(WebApplication app)
{
app.MapPost("/order", async (DkdbContext db, OrderDto orderRequest, UserManager userManager) =>
{
if (orderRequest == null || string.IsNullOrEmpty(orderRequest.UserId))
return Results.BadRequest();

var user = await userManager.FindByIdAsync(orderRequest.UserId);

var newOrder = new Order
{
UserId = orderRequest.UserId,
CreatedBy = user?.UserName,
UpdatedBy = user?.UserName,
};

await db.Orders.AddAsync(newOrder);
await db.SaveChangesAsync();

var _OrderDetails = orderRequest.ProductOrderList
.Select(e => new OrderDetail
{
OrderId = newOrder.Id,
ProductId = e.ProductId,
Amount = e.Amount,
}).ToList();

await db.OrderDetails.AddRangeAsync(_OrderDetails);
await db.SaveChangesAsync();

return Results.Created();
});
}
}



here is my data transfer object class:
public class OrderDto
{
public string UserId { get; set; } = string.Empty;
public List ProductOrderList { get; set; } = [];
}

public class OrderRequest
{
[Required]
public int ProductId { get; set; }
[Required]
public int Amount { get; set; }
}



When i debug this code, I am able to see order record created in Orders table, but not in OrderDetails. am using postgres as database. here is what the error look like:
---> Npgsql.PostgresException (0x80004005): 23502: null value in column "UserId" of relation "Orders" violates not-null constraint

DETAIL: Failing row contains (15, null, 1, 2024-01-01 14:07:25.091254+00, 2024-01-01 14:07:25.091254+00, null, null).

Exception data:
Severity: ERROR
SqlState: 23502
MessageText: null value in column "UserId" of relation "Orders" violates not-null constraint
Detail: Failing row contains (15, null, 1, 2024-01-01 14:07:25.091254+00, 2024-01-01 14:07:25.091254+00, null, null).
SchemaName: public
TableName: Orders
ColumnName: UserId
File: execMain.c
Line: 2003
Routine: ExecConstraints



i expect to be able to create a new Order with associated OrderDetail with amount respectively. I am looking for solutions, am glad if someone can help. thank you.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Compression of randomly ordered non-repeating incremental integers

 Programing Coderfunda     January 01, 2024     No comments   

I have a set of 100 integers from 0-99 in random order. Each number in the range occurs exactly once. I am looking for the most effective lossless compression algorithm to compress this data while maintaining the ability to decompress it efficiently?


I know that compressing random numbers is theoretically not possible, but I'm wondering if it's possible for this case since each number only appears once and you basically just need to compress the order of the numbers somehow... Please don't be harsh, I'm not an expert in this field. Also, any tips for python implementations would be greatly appreciated! :)


Thanks in advance.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Does a timer-triggered Azure function execute if an instance of the function is already executing?

 Programing Coderfunda     January 01, 2024     No comments   

I have an Azure Function App with the [TimerTrigger(...)] attribute, which is scheduled to execute every morning.


Suppose you manually execute the function via the Function Menu Blade -> Code + Test -> Test/Run, as shown at the bottom of this message. What happens if this manual execution of the function is still running when the time specified in the TimerTrigger attribute arrives?



* Will the manual execution be interrupted by the timer-triggered execution?

* Will the manual execution prevent the timer from triggering a new execution of the function?

* Or will a new instance of the function be kicked off when the timer triggers it, running in parallel with the existing manual execution?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Posts Older Posts Home

Meta

Popular Posts

  • Write API Integrations in Laravel and PHP Projects with Saloon
    Write API Integrations in Laravel and PHP Projects with Saloon Saloon  is a Laravel/PHP package that allows you to write your API integratio...
  • Features CodeIgniter
    Features CodeIgniter There is a great demand for the CodeIgniter framework in PHP developers because of its features and multiple advan...
  • Laravel Breeze with PrimeVue v4
    This is an follow up to my previous post about a "starter kit" I created with Laravel and PrimeVue components. The project has b...
  • Fast Excel Package for Laravel
      Fast Excel is a Laravel package for importing and exporting spreadsheets. It provides an elegant wrapper around Spout —a PHP package to ...
  • Send message via CANBus
    After some years developing for mobile devices, I've started developing for embedded devices, and I'm finding a new problem now. Th...

Categories

  • Ajax (26)
  • Bootstrap (30)
  • DBMS (42)
  • HTML (12)
  • HTML5 (45)
  • JavaScript (10)
  • Jquery (34)
  • Jquery UI (2)
  • JqueryUI (32)
  • Laravel (1017)
  • Laravel Tutorials (23)
  • Laravel-Question (6)
  • Magento (9)
  • Magento 2 (95)
  • MariaDB (1)
  • MySql Tutorial (2)
  • PHP-Interview-Questions (3)
  • Php Question (13)
  • Python (36)
  • RDBMS (13)
  • SQL Tutorial (79)
  • Vue.js Tutorial (68)
  • Wordpress (150)
  • Wordpress Theme (3)
  • codeigniter (108)
  • oops (4)
  • php (853)

Social Media Links

  • Follow on Twitter
  • Like on Facebook
  • Subscribe on Youtube
  • Follow on Instagram

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

  • September (100)
  • August (50)
  • July (56)
  • June (46)
  • May (59)
  • April (50)
  • March (60)
  • February (42)
  • January (53)
  • December (58)
  • November (61)
  • October (39)
  • September (36)
  • August (36)
  • July (34)
  • June (34)
  • May (36)
  • April (29)
  • March (82)
  • February (1)
  • January (8)
  • December (14)
  • November (41)
  • October (13)
  • September (5)
  • August (48)
  • July (9)
  • June (6)
  • May (119)
  • April (259)
  • March (122)
  • February (368)
  • January (33)
  • October (2)
  • July (11)
  • June (29)
  • May (25)
  • April (168)
  • March (93)
  • February (60)
  • January (28)
  • December (195)
  • November (24)
  • October (40)
  • September (55)
  • August (6)
  • July (48)
  • May (2)
  • January (2)
  • July (6)
  • June (6)
  • February (17)
  • January (69)
  • December (122)
  • November (56)
  • October (92)
  • September (76)
  • August (6)

Loading...

Laravel News

Loading...

Copyright © CoderFunda | Powered by Blogger
Design by Coderfunda | Blogger Theme by Coderfunda | Distributed By Coderfunda