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

01 July, 2024

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

How to use Filament 3 with Laravel 11 | Beginner Course

 Programing Coderfunda     June 07, 2024     No comments   

How to install filament 3 from scratch with Laravel 11. submitted by /u/Tilly-w-e
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

06 June, 2024

Confused about how to use Microsoft.AspNetCore.SystemWebAdapters while trying to port from old ASP.NET website to new ASP.NET Core web app

 Programing Coderfunda     June 06, 2024     No comments   

I created a new ASP.NET Core 8 MVC web app, and added Microsoft.AspNetCore.SystemWebAdapters dependency to it.


Program.cs:
using OldHandlers;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddSystemWebAdapters(); // Register SystemWebAdapters

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();

// Register SystemWebAdapters middleware
app.UseSystemWebAdapters();

// Define endpoints
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/myhandler", async context =>
{
var adapter = new AspNetCoreHttpContextAdapter(context);
var handler = new MyHandler();
handler.ProcessRequest(adapter);
});
});

app.UseAuthorization();
app.MapRazorPages();

app.Run();



And I have:
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.SystemWebAdapters;
using System.Threading.Tasks;
using OldHandlers;

public class AspNetCoreHttpContextAdapter : IHttpContextAdapter
{
private readonly HttpContext _context;

public AspNetCoreHttpContextAdapter(HttpContext context)
{
_context = context;
}

public string ResponseContentType
{
get => _context.Response.ContentType;
set => _context.Response.ContentType = value;
}

public void WriteResponse(string content)
{
_context.Response.WriteAsync(content);
}

public async Task ReadRequestBodyAsync()
{
using (StreamReader reader = new StreamReader(_context.Request.Body))
{
return await reader.ReadToEndAsync();
}
}

public void SetStatusCode(int statusCode)
{
_context.Response.StatusCode = statusCode;
}

public object GetRouteData(string key)
{
return _context.Items[key];
}
}



In my old website, I created a new handler:
public class MyHttpHandler : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
var adapter = new SystemWebHttpContextAdapter(new HttpContextWrapper(context));
var handler = new MyHandler();
handler.ProcessRequest(adapter);
}

public bool IsReusable => false;
}



and:
using System.IO;
using System.Threading.Tasks;
using System.Web;
using OldHandlers;

public class SystemWebHttpContextAdapter : IHttpContextAdapter
{
private readonly HttpContextBase _context;

public SystemWebHttpContextAdapter(HttpContextBase context)
{
_context = context;
}

public string ResponseContentType
{
get => _context.Response.ContentType;
set => _context.Response.ContentType = value;
}

public void WriteResponse(string content)
{
_context.Response.Write(content);
}

public async Task ReadRequestBodyAsync()
{
using (StreamReader reader = new StreamReader(_context.Request.InputStream))
{
return await reader.ReadToEndAsync();
}
}

public void SetStatusCode(int statusCode)
{
_context.Response.StatusCode = statusCode;
}

public object GetRouteData(string key)
{
return _context.Items[key];
}
}



I also created a .NET Standard 2.0 library to contain the concrete handler implementation:
namespace OldHandlers
{
public class MyHandler
{
public void ProcessRequest(IHttpContextAdapter context)
{
context.ResponseContentType = "text/plain";
context.WriteResponse("Hello, World!");
}
}
}

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace OldHandlers
{
public interface IHttpContextAdapter
{
string ResponseContentType { get; set; }
void WriteResponse(string content);
Task ReadRequestBodyAsync();
void SetStatusCode(int statusCode);
object GetRouteData(string key);
}
}



What I don't understand is that, if I use Microsoft.AspNetCore.SystemWebAdapters, then do I need to create my adapter classes, AspNetCoreHttpContextAdapter and SystemWebHttpContextAdapter?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laracord: Create Discord bots with Laravel

 Programing Coderfunda     June 06, 2024     No comments   

Hello everyone! I'd like to share what I think is a pretty fun little project I've been working on since January called Laracord.

I set out to make a Discord bot late last year quickly matching DiscordPHP with Laravel Zero. While it was pretty easy to get up and rolling, it quickly became clear that DiscordPHP, being a raw library structured around the Discord API, was missing some serious DX leaving a lot to be desired.

In January I decided to abstract what I had so far and do an initial release. Fast-forward a few months and Laracord has grown far past what I initially had in mind. It is packed with features and I think it is turning out to be pretty fun to use!

If this sounds like your cup of tea, I'd love for you to check it out:

Features



* Out of the box support for databases, caching, and many other Laravel features.
* Instantly generate working bot commands and event listeners with 0 knowledge.
* Automatic handling of registering/updating/unregistering application slash commands.
* Easy to use interaction routing for persistence on message buttons and actions.
* Generate asynchronous services/tasks that run parallel to the bot.
* Optional HTTP Server with native Laravel routing and Livewire support.
* Fully configurable and extendable.
* Beautiful console logging with timestamps.
* Fully documented and maintained.




Documentation



* Website:
https://laracord.com /> * Docs:
https://laracord.com/docs /> * Discord:
https://laracord.com/discord />

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

Laravel fatigue - want to try something else

 Programing Coderfunda     June 06, 2024     No comments   

Just to start off - I LOVE Laravel - it is my go to / most comfortable framework and I've built alot of sites and apps with it over the years.

But I'm finding myself a little fatigued with it - like I want to 'try something else' for building a small app. Any other Laravel devs ever been in a similar boat? Where did you end up? Django? Flask? Node? - just curious - looking for something 'fresh' to use for my next project. submitted by /u/jusjohns82
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Dereferencing an l-value

 Programing Coderfunda     June 06, 2024     No comments   

I am trying to follow DirectX 12 guidebook (Introduction to 3D Game Programming). In there there is this code:
_device->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(byteSize),
D3D12_RESOURCE_STATE_COMMON,
nullptr,
IID_PPV_ARGS(defaultBuffer));



When I try to reproduce this code in my project, I get this error: C2102 '&' requires l-value.
I have brief understanding of all r/l -value stuff (though I am no expert).
Function signature:
HRESULT CreateCommittedResource( const D3D12_HEAP_PROPERTIES *pHeapProperties, D3D12_HEAP_FLAGS HeapFlags,

const D3D12_RESOURCE_DESC *pDesc,

D3D12_RESOURCE_STATES InitialResourceState,

const D3D12_CLEAR_VALUE *pOptimizedClearValue,

REFIID riidResource,

_COM_Outptr_opt_ void **ppvResource)
The error, obviously, is about the 1st and the 3rd parameters.


As far as I understand, calling a class constructor within function call scope creates a temporary variable which expires as soon as the the execution flow moves to the called function body, so using a pointer to it within the function body is wrong (it "points" to a destructed value).
What's more surprising, I have obtained the guidebook sample code. I compiled it and it's OK, there are no errors. Moreover, the program runs OK (everything is drawn properly), so my thoughts on dangling pointer were wrong. I want to understand the thing and hear opinion from an experienced coder.
I suspect that maybe some errors have been suppresed via ProjectSettings. Or else, it has to do something with out-dated SDK version or older compiler (v140) I had to install to run the sample.
I can apply sample code if necessary.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

05 June, 2024

Tough job market?

 Programing Coderfunda     June 05, 2024     No comments   

I’ve been looking for a new job (United States) and LinkedIn shows “100+ applicants” on every Laravel job listing.

Larajobs is great but I haven’t been hearing back— some when I go through the process, they make a comment that they have interviews booked “all day”

I’m not seeing a ton of Laravel listings as there were 2-3 years ago. Just curious if anyone else is experiencing the same? Just a saturated market or what?

(Obviously not looking for a job over Reddit, just for other opinions) submitted by /u/Adventurous-Bug2282
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

First-party support for Sentry in Forge

 Programing Coderfunda     June 05, 2024     No comments   

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

Laravel Pennant: first-party feature flags

 Programing Coderfunda     June 05, 2024     No comments   

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

Why does `placeholder-shown:no-underline` work but `placeholder:no-underline` doesn't?

 Programing Coderfunda     June 05, 2024     No comments   

I expected placeholder:no-underline to remove the underline of an input's placeholder. However, placeholder-shown:no-underline does work. But I don't understand the CSS that is being created. Why does one work and the other not?


Example:

https://play.tailwindcss.com/gZIVyRDi6y
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel Packages - Variable Validation & Sanitization

 Programing Coderfunda     June 05, 2024     No comments   

Self-taught Noob question... I'm probably over thinking this and being too paranoid, but something along the way gave me the impression that incoming variables need to be validated and sanitized.

There is no magic bullet built-in functionality that does that, right? I'm using the "Validator" package in combination with strip_tags(Purifier::clean($var) and I already added both of them to my custom-built controllers. I'm left wondering if that was wasteful and I'm particularly concerned about any outside packages I'm using.

If I need to add some code to the outside packages, then that would mean re-adding it every time they update/we adopt a package too, correct?

Thoughts and suggestions for best practices? submitted by /u/altdevD
[link] [comments]
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