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

29 January, 2024

Return cells that contain numbers with recurring digits

 Programing Coderfunda     January 29, 2024     No comments   

I have a large dump of data containing in which column A has TOTAL AMOUNTS. In column B, I'd like Excel to simply say "yes" or "no" if the cell contains a number that has any digit recurring 4 times or more consecutively.
For example: if a cell contains the number 38,353.03 this would bring "no"
For example: if a cell contains the number 3,404,444 this would bring "yes"


I tried a formula using LOOKUP(SUMPRODUCT(LARGE(FREQUENCY(--MID(
but that was a disaster


so I'm at a loss
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Imcremental data import in Power BI Desktop table

 Programing Coderfunda     January 29, 2024     No comments   

In my Power BI desktop model, I have a fact table with 10 million rows.
Every day, I need to add (import) 600,000 new rows to this fact table inside Power BI desktop from SQL server data warehouse.
My concern is how can I incrementally import these new data and add it to the already existing one in my Power BI Desktop model.
Simply refresh data will read every day all the 10 million rows which will be time consuming.


I tried to modify the M code of the fact table to get new rows after a specific date but this solution completely erase the already 10 million rows of the fact table in Power BI Desktop.


Below my M code
let
Source = Sql.Database("10.Xx.Xx.Xx", "MY_DB"),
dbo_fact_table = Source{[Schema="dbo",Item="fact_table"]}[Data],
filteredRows = Table.SelectRows(dbo_fact_table, each [date] >= StartDate)

in
filteredRows
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How do I fix the health check issue when deploying rails application on Digital Ocean

 Programing Coderfunda     January 29, 2024     No comments   

This is my first try at deploying a Rails application on digital ocean but each time I try to deploy the application I get a health check error.


The build stage is successful:





But it fails when it gets to the deployment stage and there are no details on this error in the logs.





I tried checking the error logs but instead the server appears to be running.





What i have tried so far:




*

Switched between the scheduled HTTP or TCP under health check in digital ocean.



*

Confirmed if the droplet is live:









Used the rails build pack to create a new application in the droplet:


::: Current build pack::::
Custom Build Command v0.1.2
Procfilev 0.0.4
Ruby: v1.244.3
::::::::::::::::::::::::::::::::


Setup the correct environment variables for the app on the digital ocean console.
RAILS_MASTER_KEY=..correct key ommited deliberately..
RACK_ENV=development
RAILS_ENV=development
RAILS_LOG_TO_STDOUT=enabled
RAILS_SERVE_STATIC_FILES=enabled
SECRET_KEY_BASE=key correct ommited deliberately..



In addition,I am currently on the basic plan which should allow me to deploy a rails application and i also tried setting the app level environment variables but they are were overriden by the env i initially setup when creating a new app.





My setup:




*

Ruby and Rails versions:


ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin20]
Rails 7.1.3


*

platform configs in gemfile:


gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
group :development, :test do
gem 'debug', platforms: %i[mri mingw x64_mingw]
end (edited)






The App Platform Error Code Reference stipulates that this issue is caused by *



the container not responding to health checks. If a health check is
failing, that means that external traffic is not reaching my service
at the expected HTTP route



*.How do ensure external traffic is reaching my service to resolve this if this is the solution?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Error : Error getting access token for service account: Remote host terminated the handshake, iss

 Programing Coderfunda     January 29, 2024     No comments   

I'm using below Java snippet to get the Authentication token for Firebase Messaging. But its throwing error during refreshIfExpired method call.


Java code:
private static String getAccessToken() throws IOException {
String[] SCOPES = {"
https://www.googleapis.com/auth/firebase.messaging"}; />
GoogleCredentials googleCredentials = GoogleCredentials.fromStream(new FileInputStream("./src/service-account.json")).createScoped(Arrays.asList(SCOPES));
//googleCredentials.refresh();
try {
googleCredentials.getAuthenticationType();
googleCredentials.refreshIfExpired();
} catch (IOException e) {
e.printStackTrace();
}

return googleCredentials.getAccessToken().getTokenValue();
}




Cause: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake.

Detailed Error: Error getting access token for service account: Remote host terminated the handshake, iss: firebase-adminsdk-jnf15@



Are these errors related to jars or certificates? As per Firebase documentation, they did not mentioned anything related to Certificates.your text


Java Snippet code from documentation link :
https://firebase.google.com/docs/cloud-messaging/migrate-v1#use-credentials-to-mint-access-tokens />

The getAccessToken() method was shared in Google Firebase API documentation and same was used by uploaded certain jars which are required.


This service supposed to return the Access Token which will be used in subsequent service as Bearer token to send the Notifications to devices in REST API call. But this service is not working as expected and returning error.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

08 January, 2024

Synchronised Environment Variables

 Programing Coderfunda     January 08, 2024     No comments   

I currently have about 4 server instances og a Laravel app all running on separate digital ocean droplets.

I've been thinking of a way to cndtaliswd my environment variables and keep it synchronised across all the servers because I've been doing a lot of updates recently and it's very likely to miss one or two servers.

Is this a problem anyone has faced before and how did you go around it? submitted by /u/_1017e_
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel Pulse cards to show response times, scheduled jobs, broken links

 Programing Coderfunda     January 08, 2024     No comments   

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

The current state of Laravel Herd

 Programing Coderfunda     January 08, 2024     No comments   

Is Laravel Herd going open source or are there plans to monetize it?

i've been looking for something like WAMP on MacOS and it seems Herd is the closest one.

However the fact that it's:

* Not open source ( Developer tools are mostly open source, devs like to know that the software running on their machines is validated by the community. Also it can easily be forked when the need arises )
* No clear monetization strategy ( I assume it not being open source means there are plans to monetize it in the future but this has not been communicated)
* Hasn't been updated in 3 months
* No clear roadmap




For the reasons above, I'm skeptical about the longevity of the project. submitted by /u/MobyFreak
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

07 January, 2024

How to comprehensively evaluate the performance of an arm CPU?

 Programing Coderfunda     January 07, 2024     No comments   

I would like to conduct a comprehensive performance evaluation of the newly launched Nvidia Grace Superchip, including the following three aspects:



* Capabilities at the microarchitecture level, such as integer computing capability, floating-point computing capability, etc.

* Higher level capabilities, such as memory access latency, memory bandwidth limits, frequency fluctuations, etc.

* Actual operation situation, typical benchmark operation of computationally intensive or memory intensive workload






I wonder if there are sound and authoritative test suites, workloads, or methodologies for these three aspects?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Force number to text in R

 Programing Coderfunda     January 07, 2024     No comments   

For a system I am using, it requires the input format to be text even though the value is integer. In SQL, this is forced by using the following method:
variable_x = '"' + 5 + '"'



How do I do this in R? I tried as.character. But when I write out the data, the quote is missing.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Weekly /r/Laravel Help Thread

 Programing Coderfunda     January 07, 2024     No comments   

Ask your Laravel help questions here. To improve your chances of getting an answer from the community, here are some tips:

* 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]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

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
Newer Posts Older Posts Home

Meta

Popular Posts

  • Credit card validation in laravel
      Validation rules for credit card using laravel-validation-rules/credit-card package in laravel Install package laravel-validation-rules/cr...
  • 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...
  • iOS 17 Force Screen Rotation not working on iPAD only
    I have followed all the links on Google and StackOverFlow, unfortunately, I could not find any reliable solution Specifically for iPad devic...
  • C++ in Hindi Introduction
    C ++ का परिचय C ++ एक ऑब्जेक्ट ओरिएंटेड प्रोग्रामिंग लैंग्वेज है। C ++ को Bjarne Stroustrup द्वारा विकसित किया गया था। C ++ में आने से पह...
  • Python AttributeError: 'str' has no attribute glob
    I am trying to look for a folder in a directory but I am getting the error.AttributeError: 'str' has no attribute glob Here's ...

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

  • July (2)
  • 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