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

03 January, 2024

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

Calling different functions of a DLL from different threads simultaneously segfaults or gives a status_stack_buffer_overrun

 Programing Coderfunda     January 01, 2024     No comments   

I'm writing a library regarding Bridge (the card game), which performs deals generation, performance analysis and other stuff. I'm using Rust and, for some functionalities, I'm leaning on the DLL of a C++ library, called Double Dummy Solver (henceforth DDS - Site, GitHub). I used bindgen to create the bindings for the DLL (I don't know if this is the correct approach: I am not a programmer by trade and I kinda had an hard time wrapping my head around how DLL and FFI works and how to use them in Rust. I'll happily accept advices regarding this.) and everything seemed to work perfectly.


After implementing a parallel function to analyse multiple deals simultaneously (AnalyseAllPlaysBin, link to the docs) and writing a little test for it, cargo test started failing with:


exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN
or with:
exit code: 0xc0000005, STATUS_ACCESS_VIOLATION
note: test exited abnormally; to see the full output pass --nocapture to the harness.
Segmentation fault



I was a bit surprised and I dug a bit to understand the problem. I found out that the reason for the failure was cargo running the tests in parallel, and I think simultaneous calls mess up with the DLL, making it segfault.


Using cargo t -- --test-threads=1 solves the problem, but since I'm writing a library I hope to use for an application in the future, I would like to understand the problem and solve it in some way. I'm not planning to make multiple simultaneous calls to the DLL but the problem still bothers me.

I cannot provide an MWE but I'll give some code for reference:

use dds::{
deal, // The `deal` type the C++ library uses
solvedPlays, // Type of the C++ library
solvedPlay, // Same as above
playTraceBin, // Same as above
playTracesBin, // Same as above
PlayTraceBin, // Cards played for the deal to analyze
PlayTracesBin, // Collection of PlayTraceBin for different deals
SolvedPlays, // My wrapper around the C++ type
SolvedPlay, // Same
RankSeq, // Sequence of the rank (2,3,Q,K,A ecc.) of cards played
RawDDSRef, // Trait (fn get_raw(&self)) for getting a ref to the underlying struct of the Rust wrapper types
RawDDSRefMut, // Same as above, but mut (fn get_raw_mut(&mut self))
AsRawDDS, // Same as above, but not a ref (fn as_raw(self))
SuitSeq, // Sequence of suits of cards played
Target,Mode,Solutions // Parameters used by the DLL
MAXNOOFBOARDS,
};

const TRIES: usize = 200;
const CHUNK_SIZE: i32 = 10;

pub fn initialize_test() -> DealMock {
DealMock {
hands: [
[8712, 256114688, 2199023255552, 2344123606046343168],
[22528, 10485760, 79182017069056, 744219838422974464],
[484, 1612185600, 1924145348608, 4611686018427387904],
[1040, 268435456, 57415122812928, 1522216674051227648],
],
}
}

pub trait PlayAnalyzer {
/// Analyzes a single hand
/// # Errors
/// Will return an Error when DDS fails in some way.
fn analyze_play(
deal: &D,
contract: &C,
play: PlayTraceBin,
) -> Result;
/// Analyzes a bunch of hands in paraller.
/// # Errors
/// Will return an Error when DDS fails in some way or the deals and contracts vecs have
/// different length or their length doe
fn analyze_all_plays(
deals: Vec,
contracts: Vec,
plays: &mut PlayTracesBin,
) -> Result;
}

impl PlayAnalyzer for DDSPlayAnalyzer {
#[inline]
fn analyze_all_plays(
deals: Vec,
contracts: Vec,
plays: &mut PlayTracesBin,
) -> Result {
let deals_len = i32::try_from(deals.len().clamp(0, MAXNOOFBOARDS)).unwrap();
let contracts_len = i32::try_from(contracts.len().clamp(0, MAXNOOFBOARDS)).unwrap();

if deals_len != contracts_len || deals_len == 0 || contracts_len == 0 {
return Err(RETURN_UNKNOWN_FAULT.into()); // The error tells that
// either something went terribly wrong or we used wrongly sized inputs.
}

let mut c_deals: Vec = contracts
.into_iter()
.zip(deals)
.map(|(contract, deal)| construct_dds_deal(contract, deal))
.collect();
c_deals.resize(
MAXNOOFBOARDS,
deal {
trump: -1,
first: -1,
currentTrickSuit: [-1i32; 3],
currentTrickRank: [-1i32; 3],
remainCards: [[0u32; 4]; 4],
},
);
let mut boards = boards {
noOfBoards: deals_len,
// We know vec has the right length
deals: match c_deals.try_into().unwrap(),
target: [Target::MaxTricks.into(); MAXNOOFBOARDS],
solutions: [Solutions::Best.into(); MAXNOOFBOARDS],
mode: [Mode::Auto.into(); MAXNOOFBOARDS],
};
let mut solved_plays = SolvedPlays {
solved_plays: solvedPlays {
noOfBoards: deals_len,
solved: [solvedPlay::new(); MAXNOOFBOARDS],
},
};

let bop: *mut boards = &mut boards;
let solved: *mut solvedPlays = solved_plays.get_raw_mut();
let play_trace: *mut playTracesBin = (*plays).get_raw_mut();

// SAFETY: calling C
let result = unsafe { AnalyseAllPlaysBin(bop, play_trace, solved, CHUNK_SIZE) };
match result {
// RETURN_NO_FAULT == 1i32
1i32 => Ok(solved_plays),
n => Err(n.into()),
}
}

#[inline]
fn analyze_play(
deal: &D,
contract: &C,
play: PlayTraceBin,
) -> Result {
let c_deal = construct_dds_deal(contract, deal);
let mut solved_play = SolvedPlay::new();
let solved: *mut solvedPlay = &mut solved_play.solved_play;
let play_trace = play.as_raw();
// SAFETY: calling an external C function
let result = unsafe { AnalysePlayBin(c_deal, play_trace, solved, 0) };
match result {
1i32 => Ok(solved_play),
n => Err(n.into()),
}
}
}

/// Constructs a DDS deal from a DDS contract and a DDS deal representation
fn construct_dds_deal(contract: &C, deal: &D) -> deal {
let (trump, first) = contract.as_dds_contract();
deal {
trump,
first,
currentTrickSuit: [0i32; 3],
currentTrickRank: [0i32; 3],
remainCards: deal.as_dds_deal().as_slice(),
}
}

#[test]
fn analyse_play_test() {
let deal = initialize_test();
let contract = ContractMock {};
let suitseq = SuitSeq::try_from([0i32, 0i32, 0i32, 0i32]).unwrap();
let rankseq = RankSeq::try_from([4i32, 3i32, 12i32, 2i32]).unwrap();
let play = PlayTraceBin::new(suitseq, rankseq);
let solvedplay = DDSPlayAnalyzer::analyze_play(&deal, &contract, play).unwrap();
assert_eq!([2, 2, 2, 2, 2], solvedplay.solved_play.tricks[..5]);
}

#[test]
fn analyse_all_play_test() {
let mut deals_owner = Vec::with_capacity(TRIES);
deals_owner.resize_with(TRIES, initialize_test);
let deals = deals_owner.iter().collect();
let suitseq = SuitSeq::try_from([0, 0, 0, 0]).unwrap();
let rankseq = RankSeq::try_from([4, 3, 12, 2]).unwrap();
let mut suitseqs = Vec::with_capacity(TRIES);
let mut rankseqs = Vec::with_capacity(TRIES);
suitseqs.resize_with(TRIES, || suitseq.clone());
rankseqs.resize_with(TRIES, || rankseq.clone());
let contracts_owner = Vec::from([ContractMock {}; TRIES]);
let contracts = contracts_owner.iter().collect();
let mut plays = PlayTracesBin::from_sequences(suitseqs, rankseqs).unwrap();
let solved_plays = DDSPlayAnalyzer::analyze_all_plays(deals, contracts, &mut plays).unwrap();
let real_plays = solved_plays.get_raw();
assert_eq!(TRIES, real_plays.noOfBoards.try_into().unwrap());
for plays in real_plays.solved {
assert_eq!([2, 2, 2, 2, 2], plays.tricks[..5]);
}
}




I could wrap the DDSAnalyzer in an Arc and then lock it for the duration of the external function call. I think this should work (didn't have time to try it) but I don't know if it is the correct approach.


I would like to ask two things:



* Why I get those errors in a multithreaded situation?

* Would using a Arc work? Is it the correct solution or should I do something different?






Thanks to everyone!
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Weekly /r/Laravel Help Thread

 Programing Coderfunda     January 01, 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

31 December, 2023

change inija2 template file with jquery or javascript

 Programing Coderfunda     December 31, 2023     No comments   

I have no idea how, but would like to know if it is possible to change the file in the jinja2 include statement.


such as:
{% include file.name %} to {% include file1.name %}


Since the file.name is in include parentheses, I could not use {{ file.name }} to achieve this.


Thought maybe I could use something like jquery,
$(".btnt").click(function(){
$("section:fourth").replaceWith("{% include 'file1.name' %}");}



maybe initiate with button click, would this have to be on same page. I tend to use flask python for most projects.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How do I scroll an element to a specific height of a page in JavaScript?

 Programing Coderfunda     December 31, 2023     No comments   

I'm making a website with react typescript and tailwind and in it, there is a vertical list of the days of the month. The idea is that when you click on a day, it scrolls to the visible part of the div, that is 24rem under the top.


I have this function to scroll the selected day to the top of the page, but I actually need it to scroll 24rem below the top
useEffect(() => {
// Scroll to the selected day when the component mounts or when the selected date changes
if (scrollRef.current) {
const selectedDayElement = scrollRef.current.querySelector(".selected-day");
if (selectedDayElement) {
selectedDayElement.scrollIntoView({
behavior: "smooth",
block: "start",
});

scrollRef.current.scrollTop;
}
}
}, [value]);



I tried 'block: "center"' and 'nearest' but I need a more specific position. Chat GPT suggested some things using an offset property but none of them seemed to have any effects.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Why is the tag deprecated in HTML?

 Programing Coderfunda     December 31, 2023     No comments   

I am just curious as to why the tag in HTML was deprecated.



The was a simple way of quickly center-aligning blocks of text and images by encapsulating the container in a tag, and I really cannot find any simpler way on how to do it now.



Anyone know of any simple way on how to center "stuff" (not the margin-left:auto; margin-right:auto; and width thing), something that replaces ? And also, why was it deprecated?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Firebase passwordless sign-in to be only allowed for predefined Firestore users

 Programing Coderfunda     December 31, 2023     No comments   

What I am trying to achieve with my Firebase project is the following:




*

User account is created in the Authentication menu of the Firebase
console by a system admin



*

On our Website, the user enters the email which was previously
provided to us (so, we created it in the cloud console)



*

Entered email is checked whether it is one of the
predefined emails/accounts that we already have under the Users menu
of the authentication tab.






If the email is one of the predefined ones, then we allow the validation to continue. Otherwise, we don't send validation email (So, we don't spam people whose email got eventually abused) and we don't create a new account in the system and we just return 403 error somehow.


On the website, the way we access Firestore is through the firebase-admin package:
//admin.js

const admin = require('firebase-admin');

admin.initializeApp();

const db = admin.firestore();

module.exports = { admin, db };



So, how can I achieve this behaviour and accomplish it in the most clean and robust way? I've bee using this repo as a starting point but it has no such restriction on predefined users and whatever email is entered in the form - email is sent to it.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Unleash the Power of Random Scheduling in Laravel with Chaotic Schedule 🎲📅

 Programing Coderfunda     December 31, 2023     No comments   

Hey Laravel enthusiasts! 🚀

I'm excited to introduce Chaotic Schedule, an open-source Laravel package that brings a twist to scheduling your commands. Imagine scheduling tasks not just at fixed intervals, but at random times and days! This package is perfect for those looking to add a human touch or unpredictability to their tasks.


https://github.com/skywarth/chaotic-schedule


https://packagist.org/packages/skywarth/chaotic-schedule

What's Chaotic Schedule? Chaotic Schedule allows you to randomize command schedule intervals using pseudo-random number generators (pRNGs). This means your Laravel commands can run at random times within boundaries set by you. It's like rolling dice for your task scheduler!

Why Use Chaotic Schedule?

* Human-like Interaction: Perfect for tasks like sending notifications, reminders, or gifts, making them seem less robotic and more human.
* Anomaly Detection: Ideal for detecting data anomalies by running commands at unpredictable times.
* Performance and Reliability: Despite the randomness, it's built with performance in mind and is thoroughly tested for reliability.
* Production Ready: In order to harness the chaos and assert that it runs as expected in various conditions; more than 1200+ assertions and 72 test cases are prepared for unit & feature tests. Code coverage rate cruises around 96% whilst reliability rating is fixed to 'A'.




Some Cool Features:


* Random Time Macros like atRandom
, dailyAtRandom
, hourlyAtRandom * Random Date Macros for more varied scheduling
* Customizable with unique identifiers and closures for more control




How to Get Started? Simply install via composer: composer require skywarth/chaotic-schedule

And you're all set to add randomness to your schedules!

Seeking Your Support! If you find this package useful, please consider starring it on GitHub. Your support would mean a lot and help in the continuous development of this project.

For more details, check out the documentation on GitHub

I'm eager to see how you integrate Chaotic Schedule into your projects and would love to hear your feedback or suggestions.

Let's make our Laravel apps unpredictably efficient! 🌟 submitted by /u/campercroco
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

30 December, 2023

Updating a cell in Google Sheets based on whether the value appears on two different tabs in the same workbook

 Programing Coderfunda     December 30, 2023     No comments   

I am trying to make a cell in my "Inventory" sheet update to "Yes" if that item appears on either of two other sheets in the workbook. If the item from column B does not appear in either sheet, the cell should read "No".


If I use the following formula to check my "2023 Completed" sheet, I do get a proper yes/no result.


=IF(ISERROR(VLOOKUP($B$2:$B$200, '2023 Completed'!$D$2:$D$100, 1, FALSE)), "No", "Yes")


I am trying to check both the '2023 Completed' and '2024 Completed' sheets though. I have tried many variations of formulas and just get a parsing error no matter what I try. The most recent formula I have is:


=IF(OR(ISERROR(VLOOKUP($B$2:$B$200, '2023 Completed'!$D$2:$D$100, 1, FALSE)), "No", "Yes"), (ISERROR(VLOOKUP($B$2:$B$200, '2024 Completed'!$C$2:$C$100, 1, FALSE)), "No", "Yes"))


The shift from column D to column C is correct, I removed a column between the two years' sheets. I'm not sure what I'm doing wrong here - any help would be appreciated.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

I can't access a webpage through python requests module but I can access the website from my PC browser

 Programing Coderfunda     December 30, 2023     No comments   

I am trying to access this website
https://99acres.com with python requests module but it just keeps processing and does not stop while the same website works fine on browser.
After 10 min it gives an error
ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))


Following is my code:
import requests
url = '
https://99acres.com'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0'
}
r = requests.get(url,headers = headers)



I have tried the following:



* giving user-agent in headers.


* copying the request from the browser inspect as Curl and then converted it to python from online website.
Unfortunately nothing seems to work.





Is it possible to connect with this website from python request module?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Java Swing Graphics are drawned inconsistently when system scale is 125% in a scrollpane

 Programing Coderfunda     December 30, 2023     No comments   

at 100% screen scaling the drawn shape is always "pixel perfect".





at 125% screen scaling the same shape in this case it's sometimes drawn as if it has an extra row of pixels on the top (1) instead of the way it should be drawned (2). These shapes are drawned in a list in a scrollpane and while scrolling up and down, they flicker, changing from one version to the other and it's very apparent and distracting.





This I've observed being dependant on the component position, and perhaps I suppose it draws the shape inbetween 2 pixels and so it "randomly" chooses either the pixel above for one component or the one below for another one...
package debug;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;

public class TestBugScaling implements Runnable {

private final int size = 38;

public static void main(String[] args) {
SwingUtilities.invokeLater(new TestBugScaling());
}

@Override
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setPreferredSize(new Dimension(400, 400));

Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.setPreferredSize(new Dimension(400, 400));

JScrollPane scrollPane = new JScrollPane();
scrollPane.setPreferredSize(new Dimension(size + 10, 400));
scrollPane.getVerticalScrollBar().setUnitIncrement(size + 5);
scrollPane.getVerticalScrollBar().setBlockIncrement((size + 5) * 2);

JPanel container = new JPanel();
container.setBorder(new EmptyBorder(5, 5, 5, 5));
container.setLayout(new GridLayout(20, 0, 0, 5));
container.setPreferredSize(new Dimension(size + 10, (size + 5) * 20));

container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());
container.add(new CirclePanel());

scrollPane.setViewportView(container);

contentPane.add(scrollPane, BorderLayout.NORTH);

frame.pack();
frame.setVisible(true);
}

public class CirclePanel extends JPanel {

public CirclePanel() {
super();
setPreferredSize(new Dimension(size, size));
setMinimumSize(new Dimension(size, size));
setMaximumSize(new Dimension(size, size));
}

@Override
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g.create();
g2.fillOval(0, 0, getHeight(), getHeight());
g2.dispose();
}

}

}



With this code, if you have 100% screen scale, you will see a smooth scrolling of the circles.
Instead, with a 125% screen scale, if you look closely you will see the circles bobbing up and down 1 pixel out of place while scrolling...


Is there a way to prevent / fix this? what is causing it?


I don't mind the shape not being completely perfect, but I do mind that it flickers and that it's not consistent all the time...
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Update from 9 to 10

 Programing Coderfunda     December 30, 2023     No comments   

Should I update from laravel 9 to 10? It's a small project. submitted by /u/icex34
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Cashier package and Blade files

 Programing Coderfunda     December 30, 2023     No comments   

I'm a little confused about this Cashier package.

I installed it using the Laravel website (with composer), but noticed there's no template files. composer require laravel/cashier php artisan vendor:publish --tag="cashier-migrations"

Then i stumbled across this github repo:
https://github.com/laravel/cashier-stripe

The repo has a some template files so now I'm not sure what to use. Anybody knows more about this?Can I just copy the few blade files from the repo? Ot is this a whole other package?

Thanks!

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

29 December, 2023

Unable to install pyocd in latest version of Anaconda

 Programing Coderfunda     December 29, 2023     No comments   

I'm trying to set up our usual Anaconda development environment on a new Windows 10 PC. I downloaded the latest version of Anaconda last week (version 2023.09, I believe), and I'm having trouble installing pyocd. pyocd installed easily on all the other PCs several months ago.


I ran conda using Anaconda Powershell Prompt in administrator mode. Here's what conda returns:
(base) PS C:\WINDOWS\system32> conda install -c conda-forge pyocd
>> Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Solving environment: \

Found conflicts! Looking for incompatible packages.

This can take several minutes. Press CTRL-C to abort. failed /

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions



The error messages are pretty unhelpful - I'd try installing downrev packages, but I don't know which ones to downgrade. Any ideas what's going on?


UPDATE
I updated conda, and now it actually gives me actionable error messages:
(base) PS C:\WINDOWS\system32> conda install -c conda-forge pyocd
>> Channels:
- conda-forge
- defaults
- anaconda Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: | warning libmamba Added empty dependency for problem type SOLVER_RULE_UPDATE failed

LibMambaUnsatisfiableError: Encountered problems while solving:
- package pyocd-0.34.0-pyhd8ed1ab_0 requires cmsis-pack-manager >=0.4.0,=0.4.0,=3.10,=3.7,=3.8,=3.9,
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Restriction of explicit object parameter in lambda with capture

 Programing Coderfunda     December 29, 2023     No comments   

In C++23, lambda-expression supports an explicit object parameter (a.k.a. "Deducing this"). I found strange restriction for lambda with capturing at [expr.prim.lambda]/p5.



Given a lambda with a lambda-capture, the type of the explicit object parameter, if any, of the lambda's function call operator (possibly instantiated from a function call operator template) shall be either:



* the closure type,

* a class type derived from the closure type, or

* a reference to a possibly cv-qualified such type.






[Example 2:
struct C {
template
C(T);
};

void func(int i) {
int x = [=](this auto&&) { return i; }(); // OK
int y = [=](this C) { return i; }(); // error
int z = [](this C) { return 42; }(); // OK
}



-- end example]



Question: Why is there such restriction for lambda with capture only? Are there any implementation issues?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Bash script to find and return files in directory

 Programing Coderfunda     December 29, 2023     No comments   

I am a non-programmer experimenting more than anything by writing a commandline based system to write a blog.


I have the following as part of a longer script:

# Find & list out files
filefind (){
files=( */*.md )
PS3="$MSG" ;
select file in "${files[@]}"; do
if [[ $REPLY == "0" ]]; then echo 'Bye!' >&2 ; exit
elif [[ -z $file ]]; then echo 'Invalid choice, try again' >&2
else break
fi
done ;}



I would like to echo " No Files found. Enter 0 to exit" if the folder is empty. I realise I would need another elif line to do this.


When I run this, as is, I always get a return of:
{ ~/Code/newblog } $ ./blog pp
1) /.md
Choose file to Publish, or 0 to exit:



Ideally I'd like only the message with exit option, but would also like to understand why the /.md is returned. Apologies if this is answered elsewhere, hard to know what to look for if you don't know what to look for..! Happy to be pointed in the right direction.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Error in GiftedChat, Warning : Maximum update depth exceeded. in react-native-gifted-chat

 Programing Coderfunda     December 29, 2023     No comments   

i want to use react-native-gifted-chat
and then when I try to call it, it keeps getting this error
Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
in GiftedChat (created by Chat)
in Chat (created by SceneView)
in StaticContainer
in EnsureSingleNavigator (created by SceneView)
in SceneView (created by CardContainer)
in RCTView (created by View)
in View (created by CardContainer)
in RCTView (created by View)
in View (created by CardContainer)
in RCTView (created by View)
in View
in CardSheet (created by Card)
in RCTView (created by View)
...



And my code
import React from "react";
import { GiftedChat } from 'react-native-gifted-chat';

export default function Chat(){
return(



)
}



How can I solve this issue?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Deploy angular app to static web app on azure

 Programing Coderfunda     December 29, 2023     No comments   

i have a angular application that i want to be deployed on azure static web apps via git hub actions.
On my local machine:
angular cli 17
node 20
npm 10



This is the yaml file.

name: Azure Static Web Apps CI/CD

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/setup-node@v4
with:
node-version: '18'
- uses: actions/checkout@v4
with:
sub-modules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_VICTORIOUS_DESERT_030B8CE03 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit:
https://aka.ms/swaworkflowconfig /> app_location: "/" # App source code path
api_location: "api" # Api source code path - optional
output_location: "dist/sun-club" # Built app content directory - optional
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_VICTORIOUS_DESERT_030B8CE03 }}
action: "close"




I am stuck with this error.



Node.js version v16.20.2 detected.
The Angular CLI requires a minimum Node.js version of v18.13.



I have tried to update the node version with a command from the yaml file but it seems that node 16 is default.


I tried to update the node version using nvm but no success.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

09 December, 2023

Is nova profitable?

 Programing Coderfunda     December 09, 2023     No comments   

I have been studying tools like Nova, tinkerwell and their licencing. I am myself working on a tool targeted for Laravel and Symfony app, and exploring the licencing model.

I am thinking of licencing the tool as these apps do. But I am not quite sure, if thats the right way to go.

Anyone experienced in different business models for these kind of tool? Why is nova not opensource? Are there any opensource tools in laravel ecosystem that have sustained a business?

I would love to hear the business aspect of the tools by the creators of nova and tinkerwell, or point me to the direction where I can get more info. submitted by /u/broncha
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

An introduction to Eloquent’s internals

 Programing Coderfunda     December 09, 2023     No comments   

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

Hard to find a job

 Programing Coderfunda     December 09, 2023     No comments   

Is it just me or the PHP / Laravel job market is down at the moment? I love Laravel but I feel "forced" to migrate to a different ecosystem / tech stack where I can find a decent job.

Looking forward to your thoughts. submitted by /u/Rude-Professor1538
[link] [comments]
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...
  • 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...
  • 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