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 July, 2024

is there a way to print a bank check from a template where the user only puts the amount and the name?

 Programing Coderfunda     July 03, 2024     No comments   

I've been trying on excel to create a template for printing a bank check i've set the dimensions and everything but always has the print issues as it's not perfectly aligned so i've thought in some other way like coding an entire program in python (gui) that only needs the information (amount, location, date, name), it did create a pdf file but when i print it, it doesn't align well, like for example the amount isn't exactly put in the box of the check, same goes for the amount in letters.


Guys i really need help in this, i'm so lost in this i've tried everything


this is the code of the program i did,
import tkinter as tk
from fpdf import FPDF
import num2words

def generate_cheque():
amount = amount_entry.get().replace(" ", "")
amount_parts = amount.split(".")
amount_in_letters = num2words.num2words(int(amount_parts[0]), lang='fr').replace("virgule", "comma").replace("zero", "")
amount_in_letters += " dinars algeriens"
if int(amount_parts[1]) > 0:
amount_in_letters += " et " + num2words.num2words(int(amount_parts[1]), lang='fr').replace("virgule", "comma").replace("zero", "") + " centimes"
location = location_entry.get()
date = date_entry.get()
company_name = company_name_entry.get()

# Convert dimensions from inches to points
width_in_inches = 8.5
height_in_inches = 3.5
width_in_points = width_in_inches * 72
height_in_points = height_in_inches * 72

pdf = FPDF(unit="pt", format=(width_in_points, height_in_points))
pdf.add_page()
pdf.set_font("Arial", size=12)

# Add date
pdf.set_xy(480, 150)
pdf.cell(0, 10, txt=date, align="R")

# Add amount in numbers
pdf.set_xy(450, 50)
pdf.cell(0, 10, txt=amount, align="R")

# add location
pdf.set_xy(400,150)
pdf.cell(0,10, txt=location, align="L")

# Add amount in letters
pdf.set_xy(110,70)
pdf.multi_cell(0, 10, txt=amount_in_letters, align="L")

# Add company name
pdf.set_xy(50, 120)
pdf.cell(0, 10, txt=company_name, align="L")

# Save the PDF
pdf.output("cheque.pdf", "F")

result_label.config(text="Cheque generated successfully!")

root = tk.Tk()
root.title("Cheque Generator")

amount_label = tk.Label(root, text="Amount (000 000 000.00):")
amount_label.pack()
amount_entry = tk.Entry(root)
amount_entry.pack()

location_label = tk.Label(root, text="Location:")
location_label.pack()
location_entry = tk.Entry(root)
location_entry.pack()

date_label = tk.Label(root, text="Date (DD.MM.YYYY):")
date_label.pack()
date_entry = tk.Entry(root)
date_entry.pack()

company_name_label = tk.Label(root, text="Company Name:")
company_name_label.pack()
company_name_entry = tk.Entry(root)
company_name_entry.pack()

generate_button = tk.Button(root, text="Generate Cheque", command=generate_cheque)
generate_button.pack()

result_label = tk.Label(root, text="")
result_label.pack()

root.mainloop()



is there a way to like creates the perfectly aligned pdf check file?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Salt-Stack: Looking for a neet way to enforce a state only if a minon has seLinux installed

 Programing Coderfunda     July 03, 2024     No comments   

I have code that installs a custom seLinux module. In my fleet of minions there's Fedora based systems (with seLinux installed) and Debian based ones (without seLinux). On the latter the module/installing state should not be used and I am thus looking for a way of retrieving a neat answer to the question "is seLinux installed on this system?" (NOT "is seLinux enforcing on this system?") to use in a corresponding jinja2 if clause.


Attempts that have me despairing are:



* there appears to be no state in salt querying whether a given binary is on the $PATH - checking for sestatus is what I was after here.

* salt.states.selinux is not available on systems devoid of seLinux, so it's functionality does not help.

* I could not find any salt functionality to query for the local availability of something like salt.states.selinux (see above) either.






Any hint on how to go about this is appreciated.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel v11.14.0 Released: Improvements server log and support in Stringable class for Markdown extensions - msamgan.com

 Programing Coderfunda     July 03, 2024     No comments   

Discover Laravel v11.14.0 with enhanced server log improvements and expanded Markdown extension support in the Stringable class. Explore the latest updates for your Laravel projects.


https://msamgan.com/laravel-v11140-released-improvements-server-log-and-support-in-stringable-class-for-markdown-extensions submitted by /u/samgan-khan
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

allure reports not running, although allure is installed - allure command not found

 Programing Coderfunda     July 03, 2024     No comments   

I am using Nightwatch js, and have allure installed, and have been using reports successfully. However, something has changed, and now I get the following error:
$ allure generate ./allure-results --clean && allure open
bash: allure: command not found



I have allure-report folder and allure-results folder. Results folder holds up to date records, but nothing is being written to report folder.


Package.json looks correct - contains references to allure:
{
"name": "automation-poc",
"version": "2.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/nightwatch --retries 1",
"cleanConfigFiles": "del 'config/*.conf.js'",
"cleanReports": "del 'reports/*'"
},
"author": "Alex",
"license": "ISC",
"dependencies": {
"allure-commandline": "^2.29.0",
"chromedriver": "^94.0.0",
"csvtojson": "^2.0.10",
"del": "^4.1.1",
"del-cli": "^5.0.0",
"nightwatch": "^2.2.3",
"nightwatch-allure": "^1.2.0",
"selenium-server": "^3.141.59",
"uuid": "^10.0.0",
"yargs": "^15.3.1"
}
}



I've run various commands:
npm install allure-commandline
npm install nightwatch-allure
allure generate ./allure-results --clean && allure open
allure --version
npm install -g allure-commandline
npm install -g nightwatch-allure


I've made sure there's an entry in System Variables for the location of \node_modules\allure-commandline\bin


I've tried deleting the node_modules folder and running npm install again
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

02 July, 2024

How do iI fix the error with UIViewControllerRepresentable?

 Programing Coderfunda     July 02, 2024     No comments   

I got the error on my visionOS app saying that my view doesn't conform to UIViewControllerRepresentable. I tried this code in another visionOS project and it works. Is there anything I can dp?
import SwiftUI
import AVKit
import UIKit

struct PlayerView: UIViewControllerRepresentable {
typealias UIViewControllerType = AVPlayerViewController

var url: String = "
https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_adv_example_hevc/master.m3u8" />
func makeUIViewController(context: Context) -> AVPlayerViewController {
let controller = AVPlayerViewController()
// controller.navigationItem.hidesBackButton = true
// controller.showsPlaybackControls = false

controller.player = AVPlayer(url: URL(string: url)!)
controller.player?.playImmediately(atRate: 1.0)

return controller
}

func updateUIViewController(_ uiViewController: AVPlayerViewController, context: Context) {

}

class Coordinator: NSObject, AVPlayerViewControllerDelegate {
}

func makeCoordinator() -> Coordinator {
Coordinator()
}
}



a prompt answer.....
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Unable to calculate pod specific utilization of the resource through PromQL

 Programing Coderfunda     July 02, 2024     No comments   

I am calculating the namespace specific resource utilization which includes request and resource for cpu and memory and also doing the same for pod specific data.


When I am trying to aggregate the data based on pod to namespace level it is not matching the data directly driven by namespace filter.


I want the pod specific data which matches the namespace data when got aggregated.


For namespace specific data I am using below four queries. (Which is giving me correct answer)

{"cpu_usage": f"sum_over_time(namespace:container_cpu_usage:sum{{namespace='{namespace}'}}[1d])",
"cpu_request":f"sum_over_time(namespace_cpu:kube_pod_container_resource_requests:sum{{namespace='{namespace}'}}[1d])",
"memory_usage":f"sum_over_time(namespace:container_memory_usage_bytes:sum{{namespace='{namespace}'}}[1d])",
"memory_request":f"sum_over_time(namespace_memory:kube_pod_container_resource_requests:sum{{namespace='{namespace}'}}[1d])"}



For pod specific data I am using below four queries. (When I aggregate this queries using sum (query) by (namespace) the result is not matching the above queries' readings.)
{"cpu_usage": f"sum_over_time(pod:container_cpu_usage:sum{{namespace='{namespace}'}}[1d])",
"cpu_request": f"sum_over_time(kube_pod_container_resource_requests{{namespace='{namespace}', resource = 'cpu'}}[1d])",
"memory_usage":f"sum(sum_over_time(container_memory_usage_bytes{{namespace='{namespace}', container!='POD', container!=''}}[1d])) by (pod)",
"memory_request": f"sum_over_time(kube_pod_container_resource_requests{{namespace='{namespace}', resource = 'memory'}}[1d])"}



tl;dr


I want the same data as I am getting for the whole namespace but I want to segregate the usage and request for the specific pods.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Amazon athena, presto sql :INVALID_FUNCTION_ARGUMENT: Cannot unnest type: varchar

 Programing Coderfunda     July 02, 2024     No comments   

Have some transaction data and the data looks like:
record_id labels
001 ['first_record','transfer']
002 ['withdraw', 'holiday']
003 ['direct','change_password','transfer']
004 ['change_password']
......



Labels column is of string type.


Tried to unnest labels column
select record_id, new_labels from transactions, UNNEST(labels ) as t(new_labels ) order by record_id, new_labels



but got following error



INVALID_FUNCTION_ARGUMENT: Cannot unnest type: varchar



Then tried to cast string to array then to the unnest
select record_id, cast(json_parse(labels) as array(varchar)) as labels from transactions



but got following error:



INVALID_CAST_ARGUMENT: Cannot cast to array(varchar). ['withdraw', 'holiday']



Then simply tried
select cast(['first_record','transfer']) as array(varchar)



it returned



mismatched input '['. Expecting:
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Multiply Collections, Number Pairs & Markdown Extensions

 Programing Coderfunda     July 02, 2024     No comments   

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

Laravel sending contact form getting 550 error

 Programing Coderfunda     July 02, 2024     No comments   

I am trying to send mail with a contact form. I cannot figure why I am getting this error below. If I submit it with any address it comes back with this error. If I put any email address on my server it goes through and sends. So I do not know where to research and fix it.


"Expected response code "250" but got code "550", with message "550-Sorry! This server is unable to send email from this domain: 550 gmail.com. Please try sending from a domain on this server."
MAIL_DRIVER=smtp
MAIL_HOST=mail.domain.com
MAIL_PORT=465
MAIL_USERNAME=me@domain.com
MAIL_PASSWORD=......
MAIL_ENCRYPTION=ssl



Controller:
Namespace App\Http\Controllers;
use App\Notifications\ContactFormMessage;
use App\Http\Controllers\Controller;
use App\Http\Requests\ContactFormRequest;
use App\Recipient;
Class ContactController extends Controller
{
public function show()
{
return view('contact.index');
}
public function mailContactForm(ContactFormRequest $message, Recipient $recipient)
{
$recipient->notify(new ContactFormMessage($message));

return redirect()->back()->with('message', 'Thanks for your message! We will get back to you soon!');
}
}



Model recipient
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Model;
class Recipient extends Model
{
use Notifiable;
protected $recipient;
protected $email;
public function __construct() {
$this->recipient = config('recipient.name');
$this->email = config('recipient.email');
}
}



Checked email settings and password. ran composer dump-autoload
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

01 July, 2024

Packing, unpacking and storing parameter pack in a tuple in c++ 17

 Programing Coderfunda     July 01, 2024     No comments   

I have a function pointer and parameters, and I'd like to save these and potentially modify them and call the function with them.


I've seen parts of this answered however I'm unsure how a complete solution would look like, I apologize, but I don't really understand parameter packs, and how they relate to tuple.


Here's bits of my code that I'm trying to make work together:


I have this which is basically just calling the function, I think this can be used to save the call into the "callable" structure, to make an interface.


from this question:
C++ generic function call with varargs parameter
template
auto call(R(*function)(Args...), Args... args) -> typename std::enable_if::value, R>::type {
return function(args...);
}

template
void call(void (*function)(Args...), Args... args) {
function(args...);
}



And this structure which should store the parameters and the function pointer. (thanks to RaymondChen for pointing out how it should be correctly)
template
struct callable
{
R(*function)(Args...);
std::tuple params;

callable(Args... argv):
params(std::make_tuple(argv...))
{}
};



I'm still unsure how I would actually call back the function with the tuple, as far as I understand I should somehow turn the tuple back to Args... and then simply call it.


What I'm trying to achieve:




* Save a call to be used later on

* Create my own call and fill it with my own parameters, from a running app.

* Read out saved parameters to do some manner of debugging.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Replace a record with a value zero when a specific number is not find with shellscript

 Programing Coderfunda     July 01, 2024     No comments   

I have a file as shown below, I'm taking the last number on the column $2 and counting how many records are there finishing from 0 to 9, but sometimes there is no record with 0 to 9 so I need to replace it with result zero. I mean when I don't have any record on $2 finishing with for example with number 2, I will put as a result number 2 --> 0


Input file example:
2022-11-17 05:00:02.327, MSG:86442, AppID:22
2022-11-17 05:00:10.829, MSG:81874, AppID:9
2022-11-17 05:00:14.143, MSG:81778, AppID:10
2022-11-17 05:00:16.365, MSG:81782, AppID:22
2022-11-17 05:00:25.010, MSG:82959, AppID:22
2022-11-17 05:00:30.647, MSG:58653, AppID:22
2022-11-17 05:00:40.852, MSG:58198, AppID:11
2022-11-17 05:00:45.104, MSG:89039, AppID:22
2022-11-17 05:00:45.221, MSG:83564, AppID:21
2022-11-17 05:01:00.618, MSG:34115, AppID:20
2022-11-17 05:01:02.692, MSG:86963, AppID:21
2022-11-17 05:01:02.927, MSG:81387, AppID:10
2022-11-17 05:01:04.826, MSG:82119, AppID:11
2022-11-17 05:01:04.926, MSG:82111, AppID:11
2022-11-17 05:01:04.945, MSG:82116, AppID:13
2022-11-17 05:01:00.618, MSG:59110, AppID:20



Output:
# awk -F ',' '{print $2}' test.log|cut -c 10-10|sort|uniq -c
1 0
1 1
2 2
2 3
2 4
1 5
1 6
1 7
2 8
3 9



I try as shown below, but I need to put zero to field where I don't have any records found in $2 at the end with 0 to 9:
2022-11-17 05:00:02.327, MSG:86442, AppID:22
2022-11-17 05:00:14.143, MSG:81778, AppID:10
2022-11-17 05:00:16.365, MSG:81782, AppID:22
2022-11-17 05:00:25.010, MSG:82959, AppID:22
2022-11-17 05:00:40.852, MSG:58198, AppID:11
2022-11-17 05:00:45.104, MSG:89039, AppID:22
2022-11-17 05:01:00.618, MSG:34115, AppID:20
2022-11-17 05:01:02.927, MSG:81387, AppID:10
2022-11-17 05:01:04.826, MSG:82119, AppID:11
2022-11-17 05:01:04.926, MSG:82111, AppID:11
2022-11-17 05:01:04.945, MSG:82116, AppID:13
2022-11-17 05:01:00.618, MSG:59110, AppID:20


Output expectation :




awk -F ',' '{print $2}' test.log|cut -c 10-10|sort|uniq -c




nuberofrecords N° from0 to 9
# awk -F ',' '{print $2}' test.log|cut -c 10-10|sort|uniq -c
nuberofrecords N°from0 to 9
1 0
1 1
2 2
**0 3**
**0 4**
1 5
1 6
1 7
2 8
3 9
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

get-service needs local account - how to consolidate report

 Programing Coderfunda     July 01, 2024     No comments   

I have a list of computers and I can only use the local account (user1) for each computer to get a list of services. I'm looping through the computers and using get-service but as you can see I have to title each section with the computer name. I was wondering if I can consolidate this into one list with computer name attached to each service.
$computers =
@"
computer1
computer2
"@ -split [Environment]::NewLine

$computers | ForEach-Object {

$ServerUserId = "_$\user1"
$ServerPassword = ConvertTo-SecureString -String 'complexpassword' -AsPlainText -Force
$Credential = New-Object -TypeName PSCredential -ArgumentList $ServerUserId, $ServerPassword

Enter-PSSession -ComputerName $_ -Credential $Credential

"Computer name: $_"
get-service -ComputerName $computers -Name `
Service* `

Exit-PSSession
}



Output:
Computer name: Computer1
Service A
Service B

Computer name: Computer2
Service Y
Service Z



Would like it to look like:
Service A Computer1
Service B Computer1
Service Y Computer2
Service Z Computer2
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Adding Real Time Chat to Laravel Using Reverb & Vue

 Programing Coderfunda     July 01, 2024     No comments   

---



Laravel, the web artisan's favorite PHP framework, has just got a whole new powerful tool in its arsenal: Reverb. Among the official packages of Laravel, this WebSocket server application would seamlessly let you integrate real-time features in your Laravel-based applications, thereby taking interaction to a whole new level.


What is Laravel Reverb?




Reverb acts as a mediator between your Laravel-based application and its users. It establishes two-way, real-time communication based on WebSockets technology that allows web pages to receive updates on the server without a complete page refresh. This means that your users experience your application more dynamically and responsively.


Key Features of Laravel Reverb




Blazing Speed: Provides outstanding performance for real-time information with no lags.


Scalability: Grow with your applications to handle increased user traffic.


Seamless Integration: It works with broadcasting features added to Laravel and Laravel Echo to make development simple.


Push Updates: Push updates, messages, or events to clients to share your information instantly.


Built-in Security: Data encryption and authentication assurance for security communication


Adding Laravel Reverb to Your Chat Project




With Laravel Reverb, you can build dynamic chat applications. The messages are posted instantly, making users involved comprehensively. Here's a breakdown of the steps involved:


Step 1: Setting Up Your Laravel Project:






*


Ensure you have a Laravel application set up (version 11 or above is recommended).


*


If you're starting fresh, use composer create-project laravel/laravel your-chat-app-name.






Step 2: Install and Configure Reverb:




Install Laravel Reverb by running the following command:
php artisan install:broadcasting



Once you’ve installed Reverb, you can now modify its configuration from the config/reverb.php file. To establish a connection to Reverb, a set of Reverb “application” credentials must be exchanged between the client and server. These credentials are configured on the server and are used to verify the request from the client. You can define these credentials using the following environment variables:
BROADCAST_DRIVER=reverb
REVERB_APP_ID=my-app-id
REVERB_APP_KEY=my-app-key
REVERB_APP_SECRET=my-app-secret



It also automatically creates echo.js in the resources/js directory.
import Echo from 'laravel-echo';

import Pusher from 'pusher-js';
window.Pusher = Pusher;

window.Echo = new Echo({
broadcaster: 'reverb',
key: import.meta.env.VITE_REVERB_APP_KEY,
wsHost: import.meta.env.VITE_REVERB_HOST,
wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
});



Follow the Laravel documentation for configuration steps specific to your application server
https://laravel.com/docs/11.x/reverb />

Step 3: Running a Server




You can launch the Reverb server by using the reverb:start Artisan command:
php artisan reverb:start



By default, the Reverb server will be started at 0.0.0.0:8080, which makes it accessible from all network interfaces.


If you want to set a specific host or port, you can use the –host and –port options when starting the server.
php artisan reverb:start --host=127.0.0.1 --port=9000



You can also define REVERB_SERVER_HOST and REVERB_SERVER_PORT environment variables in your application’s .env configuration file.


Step 4: Setup Database




Open your .env file and adjust the settings to set up your database. Here’s an example using SQLite for simplicity:
DB_CONNECTION=sqlite
DB_DATABASE=/path/to/database.sqlite



You can create an SQLite database by simply running:
touch /path/to/database.sqlite



For this demo, we’ll create five predefined rooms. Let’s start by generating a model ChatMessage with migration for a chat_messages table.
php artisan make:model ChatMessage --migration



To make it simpler, only create name attributes for this model and migrate it.
Schema::create('chat_messages', function (Blueprint $table) {
$table->id();
$table->foreignId('receiver_id');
$table->foreignId('sender_id');
$table->text('text');
$table->timestamps();
});

php artisan migrate



Now, let's add the necessary relationships in the ChatMessage model. Open the ChatMessage.php file in the app/Models directory and update it as follows:
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Let's build a CMS with Filament 3 and Laravel 11 | #-3 Social Auth & Article, Commenting

 Programing Coderfunda     July 01, 2024     No comments   

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

30 June, 2024

Jquery passing data attributes to modal on click link

 Programing Coderfunda     June 30, 2024     No comments   

I am trying to pass some custom data attributes to a modal which is opened through a link .



The HTML snippet is as following:


Action




*

Contact









The modal snippet is as following :























I seem to be unable to set "modal-title" with the value of attribute "data-userName".



The jquery I thought would do so (only inserted alert to see if value is passed or not) :

$('#modal_contact').on('click', function() {
var $el = $(this);
var $username = $el.data('userName');
alert(username);
});




But it does not seem to work. What would be the proper approach to this ?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Weekly /r/Laravel Help Thread

 Programing Coderfunda     June 30, 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

Is there a __builtin_constant_p() for Visual C++?

 Programing Coderfunda     June 30, 2024     No comments   

Is there some function like GCC's __builtin_constant_p() for Microsoft Visual Studio? As I understand, the function returns non-zero if the argument is constant, like a string literal.



In the answer here (How to have "constexpr and runtime" alias) is a nice use case of it.



EDIT:
My idea was instead of writing something like:

#include
int foo() {
return strlen("text");
}




I could write:

#include
// template_strlen() would be a function that gets the length of a compile-time const string via templates
#define STRLEN(a) (__builtin_constant_p(a) ? template_strlen(a) : strlen(a))
int foo() {
return STRLEN("text");
}




(I guess that is about what was written in the linked question.)
All I need for that is a variant of __builtin_constant_p().
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Updating matplotlib graph using tkinter

 Programing Coderfunda     June 30, 2024     No comments   

I am writing a GUI using tkinter that has a graph inside the main and only window. I have to update the value of the graph every 2 seconds. I have been able to do this by using tkinter canvas.draw(). My problem is that every time the canvas is drawn (these 2 seconds), the GUI freezes for some time, and if for example I am writing a value in an entry or selecting a value of a list in the GUI, the GUI stops working and I have to click again with the mouse in the entry, so it is not convenient. I guess that the GUI is redrawing completely all the window. However I only want to redraw the graph. By the way, I am using matplolib for the graph.


So my questions are:



* Is it possible to avoid this problem?

* If it is not possible, what are the alternatives? maybe creating another tkinter window only for the graph?.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Is Laravel Reverb ready for production use?

 Programing Coderfunda     June 30, 2024     No comments   

Is Laravel Reverb ready for production use? When I tried it a couple of months ago it was janky. submitted by /u/goiter12345
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

29 June, 2024

Combine information in multiple columns into one column on different sheet

 Programing Coderfunda     June 29, 2024     No comments   

How do I take data that populates in to different columns on one sheet and transfer them to another sheet, but in the same column? I have tried to run my code, however I am getting an error that says, "Exception: The parameters (number[]) don't match the method signature for SpreadsheetApp.Range.setValues.dewarData" (regarding the last line of code). I have provided a portion of my code below:
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet1 = ss.getSheetByName('Form Response Data')
const sheet2 = ss.getSheetByName('Data Overview');
let [vb] = sheet1.getDataRange().getDisplayValues().map(([a,b,c,d,e,f,au,az,ba,bb,bc,bd,be])=>
[`${az} ${ba} ${bb} ${bc}`]);
sheet2.getRange(3,10,vb.length,vb[0].length).setValues(vb);
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Mastering the Service-Repository Pattern in Laravel

 Programing Coderfunda     June 29, 2024     No comments   

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

ESP-32 With DHT-11 Sensor not returning expected output

 Programing Coderfunda     June 29, 2024     No comments   

I am trying to use the output of a DHT sensor module whose data pin I have connected to Pin 27 of my ESP-32 Dev Module. The original code uses the DHT library but I can't seem to get that to work so I am using the DHT_nonblocking library which seems to work with my sensor. Here is example code from the DHT_nonblocking library that I tried to implement into my own code to create an asynchronous web server that displays the data. The example code worked, but my own code which I added direct lines from the example code is not returning any data from the DHT sensor.


Here are the codes:


EXAMPLE CODE that works with my sensor on an ESP-32:


`
#include
/* Uncomment according to your sensortype. */
#define DHT_SENSOR_TYPE DHT_TYPE_11
//#define DHT_SENSOR_TYPE DHT_TYPE_21
//#define DHT_SENSOR_TYPE DHT_TYPE_22

static const int DHT_SENSOR_PIN = 27;
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );

/*
* Initialize the serial port.
*/
void setup( )
{
Serial.begin( 9600);
}



/*
* Poll for a measurement, keeping the state machine alive. Returns
* true if a measurement is available.
*/
static bool measure_environment( float *temperature, float *humidity )
{
static unsigned long measurement_timestamp = millis( );
/* Measure once every four seconds. */
if( millis( ) - measurement_timestamp > 3000ul )
{
if( dht_sensor.measure( temperature, humidity ) == true )
{
measurement_timestamp = millis( );
return( true );
}
}

return( false );
}

/*
* Main program loop.
*/
void loop( )
{
float temperature;
float humidity;

/* Measure temperature and humidity. If the functions returns
true, then a measurement is available. */
if( measure_environment( &temperature, &humidity ) == true )
{
Serial.print( "T = " );
Serial.print( temperature, 1 );
Serial.print( " deg. C, H = " );
Serial.print( humidity, 1 );
Serial.println( "%" );
}



}


`

---



Here are my results by executing this code:
12:34:16.068 -> T = 26.0 deg. C, H = 6.0%
12:34:19.331 -> T = 26.0 deg. C, H = 6.0%
12:34:22.634 -> T = 27.0 deg. C, H = 6.0%
12:34:25.905 -> T = 27.0 deg. C, H = 6.0%
12:34:29.180 -> T = 27.0 deg. C, H = 6.0%
12:34:32.451 -> T = 27.0 deg. C, H = 6.0%
12:34:35.722 -> T = 28.0 deg. C, H = 7.0%
12:34:38.991 -> T = 28.0 deg. C, H = 7.0%
12:34:42.262 -> T = 28.0 deg. C, H = 7.0%
12:34:45.559 -> T = 28.0 deg. C, H = 7.0%
12:34:48.825 -> T = 29.0 deg. C, H = 8.0%
12:34:52.090 -> T = 29.0 deg. C, H = 8.0%
12:34:55.392 -> T = 30.0 deg. C, H = 8.0%
12:34:58.660 -> T = 31.0 deg. C, H = 9.0%
12:35:01.924 -> T = 31.0 deg. C, H = 9.0%
12:35:05.197 -> T = 31.0 deg. C, H = 9.0%
12:35:08.466 -> T = 32.0 deg. C, H = 9.0%

MY CODE THAT DOES NOT GIVE ANY RESULTS FROM THE DHT11 SENSOR:



`
// Import required libraries
#include
#include "ESPAsyncWebServer.h"
#include
// Replace with your network credentials
const char* ssid = "SSID";
const char* password = "PASSSWORD";

#define DHTPIN 27 // Digital pin connected to the DHT sensor

// Uncomment the type of sensor in use:
#define DHTTYPE DHT_TYPE_11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

DHT_nonblocking dht(DHTPIN, DHTTYPE);

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);
static bool measure_environment( float *temperature, float *humidity )
{
static unsigned long measurement_timestamp = millis( );

/* Measure once every four seconds. */
if( millis( ) - measurement_timestamp > 3000ul )
{
if( dht.measure( temperature, humidity ) == true )
{
measurement_timestamp = millis( );
return( true );
}
}

return( false );
}
float temperature;
float humidity;
String readDHTTemperature() {
if( measure_environment( &temperature, &humidity ) == true )
{
Serial.print( "T = " );
Serial.print( temperature, 1 );
Serial.print( " deg. C");

return String(temperature);

}}

String readDHTHumidity() {
if( measure_environment( &temperature, &humidity ) == true )
{

Serial.print( "H = " );
Serial.print( humidity, 1 );
Serial.println( "%" );

return String(humidity);

}}

const char index_html[] PROGMEM = R"rawliteral(





html {
font-family: Arial;
display: inline-block;
margin: 0px auto;
text-align: center;
}
h2 { font-size: 3.0rem; }
p { font-size: 3.0rem; }
.units { font-size: 1.2rem; }
.dht-labels{
font-size: 1.5rem;
vertical-align:middle;
padding-bottom: 15px;
}





ESP32 DHT Server






Temperature
%TEMPERATURE%
°C





Humidity
%HUMIDITY%
%



setInterval(function ( ) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("temperature").innerHTML = this.responseText;
}
};
xhttp.open("GET", "/temperature", true);
xhttp.send();
}, 10000 ) ;

setInterval(function ( ) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("humidity").innerHTML = this.responseText;
}
};
xhttp.open("GET", "/humidity", true);
xhttp.send();
}, 10000 ) ;

)rawliteral";

// Replaces placeholder with DHT values
String processor(const String& var){
//Serial.println(var);
if(var == "TEMPERATURE"){
return readDHTTemperature();
}
else if(var == "HUMIDITY"){
return readDHTHumidity();
}
return String();
}

void setup(){
// Serial port for debugging purposes
Serial.begin(115200);

// dht.begin();

// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}

// Print ESP32 Local IP Address
Serial.println(WiFi.localIP());

// Route for root / web page
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/html", index_html, processor);
});
server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/plain", readDHTTemperature().c_str());
});
server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/plain", readDHTHumidity().c_str());
});

// Start server
server.begin();
}

void loop(){

}



`


Here are my results by running this code:
12:27:40.469 -> Connecting to WiFi..
12:27:40.469 -> 10.0.0.236
12:27:47.375 -> T = 0.0 deg. CH = 0.0%
12:28:32.344 -> T = 0.0 deg. CH = 0.0%
12:29:32.312 -> T = 0.0 deg. CH = 0.0%
12:30:32.378 -> T = 0.0 deg. CH = 0.0%



Why is this happening?


The wiring, baud rate of the Serial Monitor is right, and I have tried everything from this website:
https://randomnerdtutorials.com/solved-dht11-dht22-failed-to-read-from-dht-sensor/, but the output keeps saying the temperature and the humidity are 0 or null. How can I change the code which creates a web server to give the right results? Thanks!


(Sorry for any bad grammar or formatting. Let me know if you need any more details. Thanks again!)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Simple concat two array of objects problem

 Programing Coderfunda     June 29, 2024     No comments   

plan_cookie = plan_cookie.concat(JSON.stringify(protect_plan_from_db));


alert("2.1 after CONCAT plan_cookie = " + JSON.stringify(plan_cookie));


/*


2.1 after CONCAT plan_cookie =
"[{"id":1,"productId":1,"planDescription":"No Protection Plan","originalPrice":0,"salePrice":0,"active":1},
{"id":2,"productId":1,"planDescription":"1 Year Extension Protection Plan","originalPrice":69.99,"salePrice":69.99,"active":1},
{"id":3,"productId":1,"planDescription":"2 Year Extension Protection Plan","originalPrice":89.99,"salePrice":89.99,"active":1},
{"id":4,"productId":1,"planDescription":"3 Year Extension Protection Plan","originalPrice":109.99,"salePrice":109.99,"active":1},
{"id":5,"productId":1,"planDescription":"4 Year Extension Protection Plan","originalPrice":129.99,"salePrice":129.99,"active":1}]
[{"id":6,"productId":3,"planDescription":"No Protection Plan","originalPrice":0,"salePrice":0,"active":1},
{"id":7,"productId":3,"planDescription":"1 Year Extension Protection Plan","originalPrice":79.99,"salePrice":79.99,"active":1},
{"id":8,"productId":3,"planDescription":"2 Year Extension Protection Plan","originalPrice":99.99,"salePrice":99.99,"active":1}]"


*/
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Call trace in java

 Programing Coderfunda     June 29, 2024     No comments   

Is there a way to output a call trace for a particular thread in java?



I do not want a stack trace. I would like a sequence of calls on each object for tracing.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

08 June, 2024

will the jobs need to be reconfigured after we update any Plugins in Jenkins?

 Programing Coderfunda     June 08, 2024     No comments   

Willing to update plug-ins in the jenkins windows machine, I have used those plug-ins in many jobs as required, So once update completes, will the jobs automatically works fine, or should I change configuration on each job, after the update.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Appending an element which is returned from a function that is imported from another file

 Programing Coderfunda     June 08, 2024     No comments   

I am working on a demo webpack app and there is a function that I have imported to my index.js file which is returning a div element with some text inside of it. The app starts with a component function that is appending a button. The button has an event listener which has an append method in it's body. The append method within the event listener has a function call passed as a parameter which returns the div element that I would like to put up on the page. The function has a console.log within it's body and this log shows the div element, but the element does not append and there are no errors in the console to tell me why it isn't being appended. Would someone be able to explain why this code doesn't append the element to the DOM please?


index.js
import _ from 'lodash';
import searchPage from './search.js'
import './index.css';

function component() {
const button = document.createElement('button')
button.classList.add('button')
button.textContent = 'click me'

return button;
}

document.body.appendChild(component());

function searchPageComponent() {
document.body.remove()

const searchPageVar = searchPage()
console.log(searchPageVar)

return searchPageVar
}

const button = document.querySelector('.button')

button.addEventListener('click', () => {

document.body.appendChild(searchPageComponent())
})




search.js
export default function searchPage() {
const stockSearchPage = document.createElement('div')
stockSearchPage.setAttribute('id', 'search')
stockSearchPage.innerHTML = 'Search Page'
console.log('search for stocks')

return stockSearchPage
}



webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
mode: 'development',
entry: {
index: './src/index.js',
print: './src/search.js',
},
devtool: 'inline-source-map',
devServer: {
static: './dist',
},
plugins: [
new HtmlWebpackPlugin({
title: 'Webpack-demo',
}),
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
publicPath: '/',
},
module: {
rules: [
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
],
},
optimization: {
runtimeChunk: 'single',
},
};



Click me button
Missing div *appears in console with no errors as to why not appended to the page
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

SELECT INTO USING UNION QUERY

 Programing Coderfunda     June 08, 2024     No comments   

I want to create a new table in SQL Server with the following query. I am unable to understand why this query doesn't work.



Query1: Works

SELECT * FROM TABLE1
UNION
SELECT * FROM TABLE2




Query2: Does not Work.
Error: Msg 170, Level 15, State 1, Line 7
Line 7: Incorrect syntax near ')'.

SELECT * INTO [NEW_TABLE]
FROM
(
SELECT * FROM TABLE1
UNION
SELECT * FROM TABLE2
)




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

07 June, 2024

podman - Failed to stop any containers by using "sudo podman stop"

 Programing Coderfunda     June 07, 2024     No comments   

I have encountered a problem with podman. I have successfully ran couple containers within it. But when I issue "sudo podman stop/restart xxx", I always get below error (used pgadmin4 as an example), then the container status stuck at "Stopping". To recover from it, I have to restart the computer.
WARN[0010] StopSignal SIGTERM failed to stop container mypgadmin4 in 10 seconds, resorting to SIGKILL
Error: given PID did not die within timeout



Below is my environment
Ubuntu 24.04
Kernel: 6.8.0-35-generic #35-Ubuntu SMP PREEMPT_DYNAMIC
Remote login through ssh
Podman is installed through Ubuntu official repos using apt install.

Podman details:
Client: Podman Engine
Version: 4.9.3
API Version: 4.9.3
Go Version: go1.22.1
Built: Thu Jan 1 00:00:00 1970
OS/Arch: linux/amd64



podman ps details
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
03a444daf9a5 docker.io/dpage/pgadmin4:latest 20 hours ago Stopping 0.0.0.0:5050->80/tcp mypgadmin4



Podman inspect details:
[
{
"Id": "03a444daf9a56b0e1d662da466ef657d3e760b83966b1b931f085b9ec4c2dee5",
"Created": "2024-06-07T08:13:52.48940452Z",
"Path": "/entrypoint.sh",
"Args": [
"/entrypoint.sh"
],
"State": {
"OciVersion": "1.1.0",
"Status": "stopping",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1354,
"ConmonPid": 1352,
"ExitCode": 0,
"Error": "container 03a444daf9a56b0e1d662da466ef657d3e760b83966b1b931f085b9ec4c2dee5 must be in Created or Stopped state to be started: container state improper",
"StartedAt": "2024-06-08T04:16:37.753214803Z",
"FinishedAt": "2024-06-08T04:13:29.582636564Z",
"Health": {
"Status": "",
"FailingStreak": 0,
"Log": null
},
"CheckpointedAt": "0001-01-01T00:00:00Z",
"RestoredAt": "0001-01-01T00:00:00Z",
"StoppedByUser": true
},
"Image": "52957d72b44aeb31109430b2b681a4867a94825c02ac7cfeca31decfb65a4e18",
"ImageDigest": "sha256:61fd25f428c155027fb2aa74b913d317af11a14f55e6135484b5e86a8840520b",
"ImageName": "docker.io/dpage/pgadmin4:latest",
"Rootfs": "",
"Pod": "",
"ResolvConfPath": "/run/containers/storage/overlay-containers/03a444daf9a56b0e1d662da466ef657d3e760b83966b1b931f085b9ec4c2dee5/userdata/resolv.conf",
"HostnamePath": "/run/containers/storage/overlay-containers/03a444daf9a56b0e1d662da466ef657d3e760b83966b1b931f085b9ec4c2dee5/userdata/hostname",
"HostsPath": "/run/containers/storage/overlay-containers/03a444daf9a56b0e1d662da466ef657d3e760b83966b1b931f085b9ec4c2dee5/userdata/hosts",
"StaticDir": "/var/lib/containers/storage/overlay-containers/03a444daf9a56b0e1d662da466ef657d3e760b83966b1b931f085b9ec4c2dee5/userdata",
"OCIConfigPath": "/var/lib/containers/storage/overlay-containers/03a444daf9a56b0e1d662da466ef657d3e760b83966b1b931f085b9ec4c2dee5/userdata/config.json",
"OCIRuntime": "crun",
"ConmonPidFile": "/run/containers/storage/overlay-containers/03a444daf9a56b0e1d662da466ef657d3e760b83966b1b931f085b9ec4c2dee5/userdata/conmon.pid",
"PidFile": "/run/containers/storage/overlay-containers/03a444daf9a56b0e1d662da466ef657d3e760b83966b1b931f085b9ec4c2dee5/userdata/pidfile",
"Name": "mypgadmin4",
"RestartCount": 0,
"Driver": "overlay",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "containers-default-0.57.4",
"EffectiveCaps": null,
"BoundingCaps": [
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_NET_BIND_SERVICE",
"CAP_SETFCAP",
"CAP_SETGID",
"CAP_SETPCAP",
"CAP_SETUID",
"CAP_SYS_CHROOT"
],
"ExecIDs": [],
"GraphDriver": {
"Name": "overlay",
"Data": {
"LowerDir": "/var/lib/containers/storage/overlay/a5c7f871d710f522023ca5dfdad42ae08922c22a6521ef6586cfc5be868d455e/diff:/var/lib/containers/storage/overlay/dc86a1c3f885aa3c52c12d8d284601453b8351a39d389643c68ef48743e1d1cf/diff:/var/lib/containers/storage/overlay/9b97c28998b2e858ec85ca6bd90bd5bac65796ec9ba935cfc207e5b2a6cdbd8f/diff:/var/lib/containers/storage/overlay/449060aaadfe49aa1bff299b09d0d7cfed4ee0613aac066a6a6c5cc31297b422/diff:/var/lib/containers/storage/overlay/ee986652d35f7ce871f3ff7ec6bccfbaf9d2cca2fbd84d2f4ec9dc985a69d1fc/diff:/var/lib/containers/storage/overlay/17bb2f5a79fd2fa0d6392b0c285632f551cdba15f00d7fd8370016fbf29ed38c/diff:/var/lib/containers/storage/overlay/6874fb546f2470531ac32bfeb5cb02e559ed7ed0ee8948e01f40d3f5bc90cb34/diff:/var/lib/containers/storage/overlay/bfcef14a6c361df75f0788cf35434d68d59683667538048dc4563146bd599aa6/diff:/var/lib/containers/storage/overlay/2a1fd15f5b430cbeaaaa09526b890da406b895ac1dbb7507d4f17bb84500ca6d/diff:/var/lib/containers/storage/overlay/e1f4108a9613a1b6d2a06b76d96166e8173849d406c0293c453459801c17e5f0/diff:/var/lib/containers/storage/overlay/a8581de914bb2816ffe235a6b98aa3761d188cbba6b7e0b45d20e7329d8d2f73/diff:/var/lib/containers/storage/overlay/74f98c324854f69f351d8c3c17822ca47b473d63f268c4bb8d2ed1d1dc966ded/diff:/var/lib/containers/storage/overlay/d4fa294b332976ab868c91a9b2115e89138635f3439dc0255a7bcfeae3fc67f2/diff:/var/lib/containers/storage/overlay/9c212d5aefe774f9ed137f7a5e497dd71046ef0f80a7bae994e0857068879fd3/diff:/var/lib/containers/storage/overlay/a6e7ea5b0f1081955cb735c56d1d4ef51c516ec66ce897b063957d1a9218cc0e/diff:/var/lib/containers/storage/overlay/02f2bcb26af5ea6d185dcf509dc795746d907ae10c53918b6944ac85447a0c72/diff",
"MergedDir": "/var/lib/containers/storage/overlay/f5378473fddf6cce0f561698ecc0d35ff6cb2df7762bc5b16d93811671157310/merged",
"UpperDir": "/var/lib/containers/storage/overlay/f5378473fddf6cce0f561698ecc0d35ff6cb2df7762bc5b16d93811671157310/diff",
"WorkDir": "/var/lib/containers/storage/overlay/f5378473fddf6cce0f561698ecc0d35ff6cb2df7762bc5b16d93811671157310/work"
}
},
"Mounts": [
{
"Type": "volume",
"Name": "fcc5478dcd526de788efa231bae5f93c9466e9ae40b1ce98af6930c11d1b0941",
"Source": "/var/lib/containers/storage/volumes/fcc5478dcd526de788efa231bae5f93c9466e9ae40b1ce98af6930c11d1b0941/_data",
"Destination": "/var/lib/pgadmin",
"Driver": "local",
"Mode": "",
"Options": [
"nodev",
"exec",
"nosuid",
"rbind"
],
"RW": true,
"Propagation": "rprivate"
}
],
"Dependencies": [],
"NetworkSettings": {
"EndpointID": "",
"Gateway": "10.88.0.1",
"IPAddress": "10.88.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "da:52:dd:8b:88:dc",
"Bridge": "",
"SandboxID": "",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"443/tcp": null,
"80/tcp": [
{
"HostIp": "",
"HostPort": "5050"
}
]
},
"SandboxKey": "/run/netns/netns-e16d008f-10f1-81b1-8f01-851badc15f3a",
"Networks": {
"podman": {
"EndpointID": "",
"Gateway": "10.88.0.1",
"IPAddress": "10.88.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "da:52:dd:8b:88:dc",
"NetworkID": "podman",
"DriverOpts": null,
"IPAMConfig": null,
"Links": null,
"Aliases": [
"03a444daf9a5"
]
}
}
},
"Namespace": "",
"IsInfra": false,
"IsService": false,
"KubeExitCodePropagation": "invalid",
"lockNumber": 6,
"Config": {
"Hostname": "03a444daf9a5",
"Domainname": "",
"User": "pgadmin",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"container=podman",
"PYTHONPATH=/pgadmin4",
"PGADMIN_DEFAULT_EMAIL=xxxx@live.com",
"PGADMIN_DEFAULT_PASSWORD=xxxx",
"HOME=/home/pgadmin",
"HOSTNAME=03a444daf9a5"
],
"Cmd": null,
"Image": "docker.io/dpage/pgadmin4:latest",
"Volumes": null,
"WorkingDir": "/pgadmin4",
"Entrypoint": "/entrypoint.sh",
"OnBuild": null,
"Labels": null,
"Annotations": {
"io.container.manager": "libpod",
"org.opencontainers.image.stopSignal": "15"
},
"StopSignal": 15,
"HealthcheckOnFailureAction": "none",
"CreateCommand": [
"podman",
"run",
"--name",
"mypgadmin4",
"-p",
"5050:80",
"-e",
"PGADMIN_DEFAULT_EMAIL=xxxx@live.com",
"-e",
"PGADMIN_DEFAULT_PASSWORD=xxxx",
"-d",
"docker.io/dpage/pgadmin4:latest"
],
"Umask": "0022",
"Timeout": 0,
"StopTimeout": 10,
"Passwd": true,
"sdNotifyMode": "container"
},
"HostConfig": {
"Binds": [
"fcc5478dcd526de788efa231bae5f93c9466e9ae40b1ce98af6930c11d1b0941:/var/lib/pgadmin:rprivate,rw,nodev,exec,nosuid,rbind"
],
"CgroupManager": "systemd",
"CgroupMode": "private",
"ContainerIDFile": "",
"LogConfig": {
"Type": "journald",
"Config": null,
"Path": "",
"Tag": "",
"Size": "0B"
},
"NetworkMode": "bridge",
"PortBindings": {
"80/tcp": [
{
"HostIp": "",
"HostPort": "5050"
}
]
},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": [],
"CapDrop": [],
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": [],
"GroupAdd": [],
"IpcMode": "shareable",
"Cgroup": "",
"Cgroups": "default",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "private",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": [],
"Tmpfs": {},
"UTSMode": "private",
"UsernsMode": "",
"ShmSize": 65536000,
"Runtime": "oci",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": 0,
"OomKillDisable": false,
"PidsLimit": 2048,
"Ulimits": [
{
"Name": "RLIMIT_NPROC",
"Soft": 4194304,
"Hard": 4194304
}
],
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"CgroupConf": null
}
}
]



Can I ask what caused this issue and how can I fix it please?


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

Any recommendations for subscriptions & entitlements package?

 Programing Coderfunda     June 07, 2024     No comments   

Hey everyone

I'm working on a SaaS product & want to add subscription plans & entitlements associated with each plan to it. The features in the product will then be available to users based on the subscribed plan & what entitlements are associated with that plan.

Do you folk have any recommendations for a package which can handle this? I'm not looking for billing support, so Cashier wont cut it here. Other than that I came across 2-3 Laravel packages which seem to have been abandoned by their maintainers. submitted by /u/the_kautilya
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Fluent API Marking Abstract Nullable Field as Required

 Programing Coderfunda     June 07, 2024     No comments   

I'm working on implementing a library to enforce the Auditable Entity design pattern, aiming for easy implementation across projects for both Entities and their configuration. Here's my current setup:
{
DateTime CreatedOn { get; set; }
DateTime? UpdatedOn { get; set; }
TId CreatedById { get; set; }
T CreatedBy { get; set; }
TId? UpdatedById { get; set; }
T? UpdatedBy { get; set; }
}

public abstract class AuditableEntity : IAuditable
{
public DateTime CreatedOn { get; set; }
public DateTime? UpdatedOn { get; set; }
public TId CreatedById { get; set; }
public T CreatedBy { get; set; }
public TId? UpdatedById { get; set; }
public T? UpdatedBy { get; set; }
}

public abstract class AuditableEntityTypeConfiguration : IEntityTypeConfiguration
where Th : AuditableEntity
where T : class
{
public virtual void Configure(EntityTypeBuilder builder)
{
builder.Property(e => e.CreatedOn).IsRequired();
builder.Property(e => e.UpdatedOn);

builder.HasOne(x => x.CreatedBy)
.WithMany()
.HasForeignKey(x => x.CreatedById)
.IsRequired();

builder.HasOne(x => x.UpdatedBy)
.WithMany()
.HasForeignKey(x => x.UpdatedById);
}
}

public class Paper : AuditableEntity
{
public Guid Id { get; set; }
...

}```

However, when I attempt to make a migration, it always returns changes making the previously nullable property UpdatedById to now be required.

I've tried adding this to my OnModelCreating in addition to implementing the abstract class as AuditableEntity in my DbContext:

```modelBuilder.Entity().Property(p => p.UpdatedById).IsRequired(false);
modelBuilder.Entity().Property(p => p.UpdatedById).IsRequired(false);



Upon running the migration, I am left with:


Unable to create a 'DbContext' of type '{MyDbContext}'. The exception 'The property 'Paper.UpdatedById' cannot be marked as nullable/optional because the type of the property is 'Guid' which is not a nullable type. Any property can be marked as non-nullable/required, but only properties of nullable types can be marked as nullable/optional.' was thrown while attempting to create an instance. For the different patterns supported at design time, see here.


Does anyone have any ideas on how to resolve this?
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