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

31 May, 2024

Python interpreter if statement issue

 Programing Coderfunda     May 31, 2024     No comments   

So, I am making a really simple Python interpreter. But, there is a part in the interpreter that checks for if statements. But, whenever I use this interpreted if statement, it checks every other indented line (which is what code should be executed if the statement is true). My code is shown below.
def tof(c):
if eval(c) == True:
return True
elif eval(c) == False:
return False

def interpret(code):
lines = code.splitlines()
for line in lines:
if line.startswith("//") or line.strip() == "" or line.startswith(" "):
continue
if line.startswith("write(") and line.endswith(")"):
if line[6] == '"' and line[-2] == '"':
print(line[7:-2])
elif line[6:-1].isdigit():
print(line[6:-1])
else: # not done yet (variables)
v = line[6:-1]
exec(f"print({v})")
if line.startswith("if ") and line.endswith(" then"):
one = line.split("if ")[1]
c = one.split(" then")[0]
if tof(c) == True:
for x in lines:
if x.startswith(" "):
interpret(x.split(" ")[1])
elif tof(c) == False:
continue
if line[2] == "=" or line[1] == "=": # not done yet (variables)
if line[2] == "=":
a = line.split(" = ")[0]
b = line.split(" = ")[1]
exec(f"{a} = {b}")

code = '''
if 1 + 1 == 2 then
write("This should execute once!")
if 1 + 3 == 4 then
// asterisk are there to tell which message is which.
write("This should execute once! **")
'''

interpret(code)



I tried breaking the loop as soon as it sees an unindented piece of code, but if I put something like this:
if True then
write("Hello, World!")
write("Stops here :(")
write("Never gets here..")
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

The Modern Index.php File (A brief look at Livewire Volt)

 Programing Coderfunda     May 31, 2024     No comments   

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

Google workspace add-on install trigger with toolbar failed

 Programing Coderfunda     May 31, 2024     No comments   

It is very weird! The same code(attached below), user take diff installation ways, diff effects.


Success situation:
User A -> click menu item in Add-on menu to install trigger(Google sheet onEdit trigger).
User A can call that trigger when edit something in sheet.
All other users can call that trigger when edit something in sheet.


Failure situation:
User -> click the button in the sidebar by the toolbar icon to install the same trigger.
User A can call that trigger when edit something in sheet.
All other users cannot call that trigger when edit something in sheet.


Error screenshot
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Eloquent JoinWith Package for Laravel

 Programing Coderfunda     May 31, 2024     No comments   

---



The Eloquent JoinWith package by Mohammed Safadi lets you join existing HasOne and BelongsTo model relationships with a new joinWith() method. According to the package's readme, JoinWith will execute a single query instead of two separate queries, which can translate to faster and more efficient queries.


To use this package, you can either use the package's JoinWith trait or extend the package's provided JoinWithModel class:
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Safadi\EloquentJoinWith\Database\Concerns\JoinWith;

class User extends Model
{
use JoinWith;

// ...
}



You can then call the joinWith() method, which resembles the with() method:
$user = User::joinWith('profile')
->select('users.id', 'users.name')
->first();

// Nested relationships
$user = User::joinWith('profile.country')->first();

// More complex example
$orders = Orders::joinWith(['user' => function ($query) {
$query->where('users.status', '=', 'verified');
}])->get();



This package works specifically with HasOne and BelongsTo model relationships—at the time of writing, other relationships are not supported. You can learn more about this package, get full installation instructions, and view the source code on GitHub at msafadi/laravel-eloquent-join-with.



The post Eloquent JoinWith Package for Laravel appeared first on Laravel News.


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

Introducing laravel-command-bus!

 Programing Coderfunda     May 31, 2024     No comments   

Hello Laravel developers! I'm excited to announce the release of laravel-command-bus, a package designed to simplify and enhance command handling in your Laravel applications.

With this package, you can:

* Organize Your Code: Cleanly separate command logic from your controllers.
* Boost Maintainability: Keep your application code more readable and maintainable.
* Leverage Middleware: Easily add middleware to your commands for additional functionality.
* Implement CQRS Effortlessly: Separate your command and query responsibilities with ease.




Whether you're building a small app or a large enterprise solution, laravel-command-bus will help you manage commands more efficiently. Check it out on GitHub and give it a try today! submitted by /u/Crafty-Savings6727
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

30 May, 2024

Recoding an entire data frame using label-value pairs stored in a different dataframe

 Programing Coderfunda     May 30, 2024     No comments   

Suppose I have a dataframe:
df
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Snowflake: How to flatten the ACCESS_HISTORY View

 Programing Coderfunda     May 30, 2024     No comments   

in snowlake.account_usage.access_history DIRECT_OBJECTS_ACCESSED and BASE_OBJECTS_ACCESSED contains the objects that were involved in the query


Although it’s great to have these information, the format however prohibits us from joining this data with another object data to gain more insight about how the objects was used by the query (e.g. which warehouse this query was executed? How long did it take to execute? Was there an error encountered? Who executed it? etc.)


is there a way to flatten it ?


flatten the access_history view
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

AVD users facing issue with Error code: 0x3000047 Extended error code: 0x0

 Programing Coderfunda     May 30, 2024     No comments   

Users get disconnected from AVD machines with error code 0x3000047 Extended error code: 0x0


Here are the logs that we see


[{"Code":-2147467259,"CodeSymbolic":"ConnectionFailedAdTrustedRelationshipFailure","Time":"2024-05-30T12:01:46.7398504Z","Message":"Exception of type 'Microsoft.RDInfra.RDAgent.Service.AddUserToLocalGroupAdTrustedRelationshipFailureException' was thrown.","ServiceError":false,"Source":"RDAgent"}]


Is there a way to resolve/aviod this issue ?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How do I replace `serviceWorkerVersion` with `{{flutter_service_worker_version}}` template token?

 Programing Coderfunda     May 30, 2024     No comments   

In my index.html in my flutter web app, I have a serviceWorker script. Flutter now complaints like this:
[ +3 ms] Warning: In index.html:60: Local variable for "serviceWorkerVersion" is deprecated. Use "{{flutter_service_worker_version}}" template token instead.



The of the index.html is defined like this:




var serviceWorkerVersion = null;
var scriptLoaded = false;
function loadMainDartJs() {
if (scriptLoaded) {
return;
}
scriptLoaded = true;
var scriptTag = document.createElement('script');
scriptTag.src = 'main.dart.js';
scriptTag.type = 'application/javascript';
document.body.append(scriptTag);
}

if ('serviceWorker' in navigator) {
// Service workers are supported. Use them.
window.addEventListener('load', function () {
// Wait for registration to finish before dropping the tag.
// Otherwise, the browser will load the script multiple times,
// potentially different versions.
var serviceWorkerUrl = 'flutter_service_worker.js?v=' + serviceWorkerVersion;
navigator.serviceWorker.register(serviceWorkerUrl)
.then((reg) => {
function waitForActivation(serviceWorker) {
serviceWorker.addEventListener('statechange', () => {
if (serviceWorker.state == 'activated') {
console.log('Installed new service worker.');
loadMainDartJs();
}
});
}
if (!reg.active && (reg.installing || reg.waiting)) {
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
waitForActivation(reg.installing || reg.waiting);
} else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console.log('New service worker available.');
reg.update();
waitForActivation(reg.installing);
} else {
// Existing service worker is still good.
console.log('Loading app from service worker.');
loadMainDartJs();
}
});

// If service worker doesn't succeed in a reasonable amount of time,
// fallback to plaint tag.
setTimeout(() => {
if (!scriptLoaded) {
console.warn(
'Failed to load app from service worker. Falling back to plain tag.',
);
loadMainDartJs();
}
}, 4000);
});
} else {
// Service workers not supported. Just drop the tag.
loadMainDartJs();
}





How do I replace serviceWorkerVersion with a {{flutter_service_worker_version}} template instead, as the warning suggests ?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Is GARNET really a drop-in replacement for REDIS?

 Programing Coderfunda     May 30, 2024     No comments   

I am experimenting with ASPIRE and GARNET, the latter replacing REDIS. According to the documentation:



Thus, one can use Garnet with unmodified Redis clients available in
most programming languages, for example, with StackExchange.Redis in
C#.



As far as I know, there is no Garnet library for Aspire, but it can be used by specifying the image:
var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddRedis("cache", port: 6379).WithImage("ghcr.io/microsoft/garnet")



When starting from the aspire starter template, I tried to add distributed caching to the "Counter" page:
protected override async Task OnInitializedAsync()
{
var bytes = await cache.GetAsync("counter");
if (bytes != null)
{
currentCount = BitConverter.ToInt32(bytes);
}
}

public async Task IncrementCount()
{
currentCount++;
await cache.SetAsync("counter", BitConverter.GetBytes(currentCount));
}



Works seamlessly with Redis. However, it fails with Garnet:



StackExchange.Redis.RedisServerException: ERR unknown command
at StackExchange.Redis.RedisDatabase.ScriptEvaluateAsync(String script,
RedisKey[] keys, RedisValue[] values, CommandFlags flags) in
/_/src/StackExchange.Redis/RedisDatabase.cs:line 1551
at Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.SetAsync(String
key, Byte[] value, DistributedCacheEntryOptions options,
CancellationToken token)
at AspireAppHybridCache.Web.Components.Pages.Counter.IncrementCount() in
D:\Workspace\playground\AspireAppHybridCache\AspireAppHybridCache.Web\Components\Pages\Counter.razor:line
28



Am I missing something essential here?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

29 May, 2024

MissingSchemaError in mongoose

 Programing Coderfunda     May 29, 2024     No comments   

My schemas:


`const facultySchema = new Schema({
title: {
type: String,
required: true
},
groups: [{
type: Schema.Types.ObjectId,
ref: 'Group'
}]
})


export default model('Faculty', facultySchema)`


`const groupSchema = new Schema({
title: {
type: String,
required: true
},
students: [{
type: Schema.Types.ObjectId,
ref: 'Student',
}],
journals: [{
type: Schema.Types.ObjectId,
ref: 'Journal'
}]
})


export default model('Group', groupSchema)`


here is my service whe i have error MissingSchemaError: Schema hasn't been registered for model "Group". This error happend when i try to populate groups


`class FacultyService {
getFaculties = async () => {
const faculties = await Faculty.find().populate('groups')

if(!faculties) return null

return faculties
}



}


export const facultyService = new FacultyService()`


when i add code const gr = await Group.find() to my getFaculties fucction error disappear.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Images getting loaded really slow on github pages

 Programing Coderfunda     May 29, 2024     No comments   

I created HTML/CSS/JavaScript landing page, with a lot of photos (around 300). About 290 photos are displayed with lightgalleryjs for a modal carousel and I added loading="lazy" attribute to each image.


When I view the website on browser via local server it's fine and loads fast but when I upload it to GitHub pages it takes about 10 - 15 seconds to load the images, a background video (without loading lazy) at the header also takes a lot of time to load (it wasn't the case with GitHub pages before I imported the photos for lightgalleryjs).


How do I solve the slow loading of images?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Spring Boot can't autowire @ConfigurationProperties

 Programing Coderfunda     May 29, 2024     No comments   

Here is my FileStorageProperties class:

@Data
@ConfigurationProperties(prefix = "file")
public class FileStorageProperties {
private String uploadDir;
}




This gives me saying : not registered via @enableconfigurationproperties or marked as spring component.



And here is my FileStorageService :

@Service
public class FileStorageService {

private final Path fileStorageLocation;

@Autowired
public FileStorageService(FileStorageProperties fileStorageProperties) {
this.fileStorageLocation = Paths.get(fileStorageProperties.getUploadDir())
.toAbsolutePath().normalize();

try {
Files.createDirectories(this.fileStorageLocation);
} catch (Exception ex) {
throw new FileStorageException("Could not create the directory where the uploaded files will be stored.", ex);
}
}

public String storeFile(MultipartFile file) {
// Normalize file name
String fileName = StringUtils.cleanPath(file.getOriginalFilename());

try {
// Check if the file's name contains invalid characters
if(fileName.contains("..")) {
throw new FileStorageException("Sorry! Filename contains invalid path sequence " + fileName);
}

// Copy file to the target location (Replacing existing file with the same name)
Path targetLocation = this.fileStorageLocation.resolve(fileName);
Files.copy(file.getInputStream(), targetLocation, StandardCopyOption.REPLACE_EXISTING);

return fileName;
} catch (IOException ex) {
throw new FileStorageException("Could not store file " + fileName + ". Please try again!", ex);
}
}

public Resource loadFileAsResource(String fileName) {
try {
Path filePath = this.fileStorageLocation.resolve(fileName).normalize();
Resource resource = new UrlResource(filePath.toUri());
if(resource.exists()) {
return resource;
} else {
throw new MyFileNotFoundException("File not found " + fileName);
}
} catch (MalformedURLException ex) {
throw new MyFileNotFoundException("File not found " + fileName, ex);
}
}
}




This gives me error saying : could not autowire no beans of type found.



And here is my project structure :







And when I try to run it, it gives me :


---




APPLICATION FAILED TO START



Description:



Parameter 0 of constructor in com.mua.cse616.Service.FileStorageService required a bean of type 'com.mua.cse616.Property.FileStorageProperties' that could not be found.



The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)



Action:



Consider defining a bean of type 'com.mua.cse616.Property.FileStorageProperties' in your configuration.


---




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

How can I diff a directory for only files of a specific type?

 Programing Coderfunda     May 29, 2024     No comments   

I have a question about the diff command
if I want a recursive directory diff but only for a specific file type, how to do that?


I tried using the exclude option but can only use one pattern only:
diff /destination/dir/1 /destination/dir/2 -r -x *.xml



with the command I can only exclude xml file type, even though there are files in the folder image type (png, gif, jpg), txt, php, etc.


How can I diff only certain file types?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Access log file not created in docker container for spring boot aplication

 Programing Coderfunda     May 29, 2024     No comments   

I have a Spring-Boot application that does not create an access log file of the embedded Tomcat server while running inside a docker container. But when run outside of the container it does create a file.


Iam using a custom log configuration:
@Configuration
public class LoggingConfiguration {

@Bean
public WebServerFactoryCustomizer connectorCustomizer(final AccessLogProperties accessLogProperties) {
return tomcat -> {
final JsonAccessLogValve logValve = new JsonAccessLogValve();
logValve.setEnabled(accessLogProperties.isEnabled());
logValve.setBuffered(accessLogProperties.isBuffered());
logValve.setRenameOnRotate(accessLogProperties.isRenameOnRotate());
logValve.setRotatable(accessLogProperties.isRotate());
logValve.setPrefix(accessLogProperties.getPrefix());
logValve.setSuffix(accessLogProperties.getSuffix());
logValve.setPattern(accessLogProperties.getPattern());
tomcat.addContextValves(logValve);
};
}
}



The properties are configured in my application.yml and made available through: AccessLogProperties.class
...
json-access-log:
enabled: true
buffered: false
pattern: "%{yyy-MM-dd'T'hh:mm:ssZ}t %I %l %u %a %r %q %s (%D ms) %{Authorization}i"
rename-on-rotate: true
rotate: true
prefix: chalkup-${ACTIVE_APP_ENVIRONMENT}
suffix: .access
...



locally a file is created in the root of my project under ./logs and there a file chalkup-local.access is created and appended with info.


sofar running in intellij results in the access file I need.


When I run the app in a docker container. No file is created:


docker config:
FROM eclipse-temurin:21-alpine
ADD ./target/chalkup-*.jar chalkup.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/chalkup.jar"]

chalk-up:
container_name: chalk-up
build:
dockerfile: Dockerfile
context: .
environment:
ACTIVE_APP_ENVIRONMENT: test
entrypoint:
- java
- -agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n
- -Djava.security.egd=file:/dev/./urandom
- -jar
- /chalkup.jar
- -Dspring.profiles.active=local
volumes:
- /tmp/logs:/logs
ports:
- "8080:8080"
- "5005:5005"
depends_on:
- wiremock



But when I look in the /logs dir in the running container. I only see the regular logfile but NOT the access log file


Changed the basedir, no success
changed read/write permissions in the container. No success
configured the regular access log
server:
tomcat:
basedir: .
accesslog:
enabled: true


But this one also does not appear in the container, while it does when running outside the container
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

10 May, 2024

How can I document types in a multidimensional array to fix type hinting?

 Programing Coderfunda     May 10, 2024     No comments   

I have some template files that have default arguments defined at the top of each file. I can't get type hinting for these values to work correctly; it just says there is no reference. I am including the WordPress core files in Intelephense, so it understands what a WP_Post is, I just can't get it to understanding typing on a multidimensional aray.


I found this GitHub issue which discusses a similar problem, and includes some suggestions on things to try. No matter which method I used, all I can get it to respond with for $args["post"] is `No references found for 'post'".


Eventually, I found this WordPress forums thread discussing a similar issue, and links to this WordPress core file which includes the "WordPress-y" way to do document multidimensional arrays, but even this still results in the same message.


That's how I've gotten to this point, but this doesn't seem to be working correctly either, because the reference pop-up looks quite odd (screenshot below), and doesn't seem to do anything for type hinting.










Also, I understand that perhaps a class structure would be better, and I will look in to that, but that entails retooling our templating system, so that will take time. For now, I'd like to get type hinting working in this use if at all possible.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

If Sail isn't production ready.... why are we using it?

 Programing Coderfunda     May 10, 2024     No comments   

New to Laravel, not new to docker. Been enjoying Sail in local development because it "just worked" but going to deploy to a server I see that it's not production ready.

One of the main selling points of docker is that you have the same infrastructure on all environments, local/qa/prod/whatever. If I have to build a Dockerfile for everything except localhost, why wouldn't I just use that Dockerfile for localhost? Is it supposed to be a tool for that small area of "i just init'ed my project and have not made a first time deployment yet"?

Make it make sense submitted by /u/NBehrends
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to get an actual type object with generic class?

 Programing Coderfunda     May 10, 2024     No comments   

I get an error with Caused by: java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.test.QueryOrderInfo


bizContent is a json String, I want to parse it to an QueryOrderInfo object
public static void main(String[] args) {
BaseResponse queryOrderInfoBaseResponse = null;
try {
queryOrderInfoBaseResponse = new ObjectMapper().readValue("{\"returnCode\":\"SUCCESS\",\"biz_content\":\"{\\\"mchReserved\\\":\\\"1\\\",\\\"cmbOrderId\\\":\\\"900119022715203210134445\\\",\\\"dscAmt\\\":\\\"0\\\",\\\"payType\\\":\\\"ZF\\\",\\\"orderId\\\":\\\"9001004180329103417277\\\",\\\"txnTime\\\":\\\"20190227152032\\\",\\\"merId\\\":\\\"3089991701207X7\\\",\\\"currencyCode\\\":\\\"156\\\",\\\"txnAmt\\\":\\\"1\\\",\\\"tradeState\\\":\\\"S\\\"}\",\"sign\":\"kGE7mwX/ubRlPsPZGNydjY3uCjILgGuxD4j1e/inyC/DlHn5o7LkISpmrH0YQvoZT6lyOxtr9uIkKnqVcTMZNYeYIBU+Tz8NRaPZHuFr/qQb0+fUgEgq5j9ovaFczAF8wrnEfIRYBEqp0ERtK7NG+X6eZLIr9nNVy31eKcnFx1tToJ/zPYN91GOKOtTrJaJrKeDY4+r3ctzsDhnD+TO2MX5zfvW0WLoUjvX5geiYLVpt022BiyxSJyOsrDS858RBmZ5FbVlYP0v/WqwX+J8VY1kDSLxvPtSZuPnsluJPXw6ccnYNH8dir0VgrYfrWRvnupctIm2elCmL7ES6KzDTGg==\",\"encoding\":\"UTF-8\",\"version\":\"0.0.1\",\"signMethod\":\"01\",\"respCode\":\"SUCCESS\"}", new TypeReference() {
});
QueryOrderInfo queryOrderInfo = queryOrderInfoBaseResponse.fromJson();
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}



BaseResponse class
@NoArgsConstructor
@Data
public class BaseResponse {

private String returnCode;
@JsonProperty(value = "biz_content")
private String bizContent;
private String sign;
private String encoding;
private String version;
private String signMethod;
private String respCode;

private String errCode;
private String respMsg;

private T data;

public T fromJson() {
try {
return new ObjectMapper().readValue(this.bizContent, new TypeReference() {
});
} catch (JsonProcessingException e) {
return null;
}
}
}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Just deployed Laravel Octane + Swoole with Forge. From 70-80% CPU to 30% CPU with 1700 request per minute. We went from 16,000 slow requests (>= 100ms) in the last hour, to only 114 slow request in the last hour.

 Programing Coderfunda     May 10, 2024     No comments   

= 100ms) in the last hour, to only 114 slow request in the last hour. " title="Just deployed Laravel Octane + Swoole with Forge. From 70-80% CPU to 30% CPU with 1700 request per minute. We went from 16,000 slow requests (>= 100ms) in the last hour, to only 114 slow request in the last hour. " />
submitted by /u/Ciberman
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

09 May, 2024

Deploy your Laravel Dockerfile simply with high availability and security

 Programing Coderfunda     May 09, 2024     No comments   

* Sample :
https://github.com/Andrew-Kang-G/docker-blue-green-runner?tab=readme-ov-file#how-to-start-with-a-php-sample-real-https-self-signed-ssl />
*

With your project and its sole Dockerfile, Docker-Blue-Green-Runner manages the remainder of the Continuous Deployment (CD) process with wait-for-it, consul-template and Nginx.
*

On Linux, you only need to have docker, docker-compose and some helping libraries such as git, curl, bash, yq installed.

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

Use Vue or React Components in a Livewire App with MingleJS

 Programing Coderfunda     May 09, 2024     No comments   

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

From Skeptic to Advocate: How I Built My Ideal Laravel Stack – Feedback Appreciated!

 Programing Coderfunda     May 09, 2024     No comments   

Hello r/Laravel!

I've been working with Laravel professionally over my last few projects, and it has surprisingly become my go-to for creating websites, even when I was initially quite skeptical about it (shout out to my coworker for helping me overcome this skepticism!).

To share this journey and the insights I've gained, I've finally launched a tech blog focused on IT Homelabs and software development, with my very first post dedicated to creating what I consider the perfect Laravel stack.

Here’s what I’ve put together for a robust, Laravel environment:

* Vue.js for interactive, reactive components.
* Inertia.js for seamless integration of Vue.js within Laravel, making SPAs more manageable.
* Laravel Sail for a straightforward, Docker-based local development setup.
* TailwindCSS for intuitive and flexible styling.
* VSCode Devcontainer to ensure consistency across development environments.




This guide is the product of my professional experience and aims to help others bootstrap their Laravel projects with a solid foundation and great developer experience. The motivation behind this guide is not only to share it with other developers but also as a reference for myself when setting up new projects.

I'm excited to share this with you and would love to hear your feedback or engage in discussions about Laravel setups and best practices. Your insights would be incredibly valuable and much appreciated!

rasmusgodske.com/posts/setting-up-the-perfect-laravel-stack

Thanks for checking it out—I'm eager to see how it can help others and to learn from your experiences as well! submitted by /u/rasmus-godske
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Pitching the perfect Laracon talk (an interview with Michael Dyrynda, organiser of Laracon Australia)

 Programing Coderfunda     May 09, 2024     No comments   

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

Hiding shipping method from Woocommerce cart page ISSUE

 Programing Coderfunda     May 09, 2024     No comments   

I tried to use different codes to hide shipping method from Woocommerce cart page. The codes work until I delete a product from the cart. Once I delete a product the shipping section returns. After I refresh the page its work again.


One of the codes I tried:
add_filter( 'woocommerce_cart_needs_shipping', 'filter_cart_needs_shipping' );
function filter_cart_needs_shipping( $needs_shipping ) {
if ( is_cart() ) {
$needs_shipping = false;
}
return $needs_shipping;
}



I tried this code also:
function disable_shipping_calc_on_cart( $show_shipping ) {
if( is_cart() ) {
return false;
}
return $show_shipping;
}
add_filter( 'woocommerce_cart_ready_to_calc_shipping', 'disable_shipping_calc_on_cart', 99 );



I put the code in my theme function.php file. The problem is the same for both codes.


I use WordPress 6.5.2, WooCommerce 8.8.3 and Twenty Twenty-Four theme.


How can this problem be solved?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

08 May, 2024

Transaction aware model events/observables.

 Programing Coderfunda     May 08, 2024     No comments   

So, back in the day.. Laravel 5 day there was this issue in which model events and observers didn't respect db transaction logic, basically, model events and observer methods would have run when you interact with a model from inside a transaction and before it was committed which means that the event will process before the model was actually saved, and of course another problem was that the changed made by the events/observers didn't rollback if the you rollback the transaction.

So came laravel-transactional-events package to solve this.

later, Laravel 8.17 introduced a new method DB::afterCommit that allows one to achieve the same of this package. Yet, it lacks transaction-aware behavior support for Eloquent events.

And i wonder, did Laravel 10 solved this issue? i'm aware of ShouldHandleEventsAfterCommit which takes care of the observers, however, how about the model events that is listened to from within the boot method? will those respect it as well? How about any other events? and not queued events? submitted by /u/Independent-Desk-407
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Rule::array() and whereJsonOverlaps() for MySQL in Laravel 11.7

 Programing Coderfunda     May 08, 2024     No comments   

---



This week, the Laravel team released v11.7, with a Rule::array() validation method, a whereJsonOverlaps() method for MySQL, a Slack OpenID provider for Laravel Socialite, and more.


Introduce the Rule::array() Method




Jakub Potocký contributed the Rule::array() method used to validate multiple array keys using the array validation rule. This method enables using this rule with arrays and collections without having the concatenate dynamic values:
use Illuminate\Validation\Rule;

// Before
['array:' . MyBackedEnum::VALUE->value . ',' . MyBackedEnum::VALUE_2->value];

// After examples
Rule::array('key_1', 'key_2', 'key_3');
Rule::array(['key_1', 'key_2', 'key_3']);
Rule::array(collect(['key_1', 'key_2', 'key_3']));
Rule::array([UnitEnum::key_1, UnitEnum::key_2, UnitEnum::key_3]);
Rule::array([BackedEnum::key_1, BackedEnum::key_2, BackedEnum::key_3]);



See Pull Request #51250 for full details.


Stringable Support in blank() and filled() Helpers




Stefan R. contributed support for Stringable values in the blank() and filled() helpers:
// true
filled(str('FooBar '));

// true
blank(str(' '));



Add "whereJsonOverlaps()" for MySQL




Benjamin Ayles contributed support for MySQL's json_overlaps feature that compares two JSON documents:
User::whereJsonOverlaps('languages', ['en', 'fr'])->exists();
User::whereJsonDoesntOverlap('languages', ['en', 'fr'])->exists();



See Pull Request #51288 for more details and discussion.


Add PasswordResetLinkSent Event




Matt Jones contributed a new event called PasswordResetLinkSent which fires when a password reset link is sent. See Pull Request #51253 for more details.


Laravel Socialite Provider for Slack OpenID




Maarten Paauw contributed a separate Slack OpenID provider for Laravel Socialite. See Pull Request #704 for details and links to the Slack documentation.


Release notes




You can see the complete list of new features and updates below and the diff between 11.6.0 and 11.7.0 on GitHub. The following release notes are directly from the changelog:


v11.7.0






* [11.x] Fix SesV2Transport to use correct EmailTags argument by @Tietew in
https://github.com/laravel/framework/pull/51265 />

* [11.x] Add Databases nightly workflow by @Jubeki in
https://github.com/laravel/framework/pull/51218 />

* [11.x] update "min" and "max" rule comments by @browner12 in
https://github.com/laravel/framework/pull/51274 />

* [11.x] Fix namespace and improvement PSR in ClassMakeCommandTest.php by @saMahmoudzadeh in
https://github.com/laravel/framework/pull/51280 />

* [11.x] improvement test coverage for view components. by @saMahmoudzadeh in
https://github.com/laravel/framework/pull/51271 />

* [11.x] Introduce method Rule::array() by @Jacobs63 in
https://github.com/laravel/framework/pull/51250 />

* [11.x] Fix docblock for collection pluck methods by @SanderMuller in
https://github.com/laravel/framework/pull/51295 />

* [11.x] Add tests for handling non-baked enum and empty string requests by @hrant1020 in
https://github.com/laravel/framework/pull/51289 />

* blank and filled now support stringable by @lava83 in
https://github.com/laravel/framework/pull/51300 />

* [11.x] Fix ratio validation for high ratio images by @ahmedbally in
https://github.com/laravel/framework/pull/51296 />

* [11.x] Add int|float support to e method by @trippo in
https://github.com/laravel/framework/pull/51314 />

* [11.x] Add release notes by @driesvints in
https://github.com/laravel/framework/pull/51310 />

* [11.x] Stringable is also an interface of symfony by @lava83 in
https://github.com/laravel/framework/pull/51309 />

* [11.x] Add some tests and improvement test coverage for Str::camel by @saMahmoudzadeh in
https://github.com/laravel/framework/pull/51308 />

* [11.x] Using the ?? Operator (Null Coalescing Operator) by @saMahmoudzadeh in
https://github.com/laravel/framework/pull/51305 />

* [11.x] Add ability to override the default loading cached Routes for application by @ahmedabdel3al in
https://github.com/laravel/framework/pull/51292 />

* [11.x] Add ->whereJsonOverlaps() for mysql by @parkourben99 in
https://github.com/laravel/framework/pull/51288 />

* [11.x] Add InteractsWithInput methods to ValidatedInput by @aydinfatih in
https://github.com/laravel/framework/pull/51316 />

* [11.x] Adding PasswordResetLinkSent event by @Muffinman in
https://github.com/laravel/framework/pull/51253 />






The post Rule::array() and whereJsonOverlaps() for MySQL in Laravel 11.7 appeared first on Laravel News.


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

Raspberry PI CM4 Gstreamer: Segmentation fault

 Programing Coderfunda     May 08, 2024     No comments   

I have a program developed for Raspberry PI CM4 with Bullseye OS that receives video from RPI NoIR Camera V2 Gstreamer pipeline and uses OpenCV for further processing.
However, after successfully working for some time program crashes with segmentation fault and backtrace shows next:
0x0000007fe0fd8930 in GstLibcameraSrcState::requestCompleted(libcamera::Request*) ()
from /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstlibcamera.so
(gdb) bt full
#0 0x0000007fe0fd8930 in GstLibcameraSrcState::requestCompleted(libcamera::Request*) ()
at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstlibcamera.so
#1 0x0000007fe0ec2750 in libcamera::Camera::requestComplete(libcamera::Request*) ()
at /lib/aarch64-linux-gnu/libcamera.so.0.0
#2 0x0000007fe0ef33d4 in libcamera::PipelineHandler::completeRequest(libcamera::Request*) ()
at /lib/aarch64-linux-gnu/libcamera.so.0.0
#3 0x0000007fe0f2ecd4 in libcamera::RPi::CameraData::checkRequestCompleted() ()
at /lib/aarch64-linux-gnu/libcamera.so.0.0
#4 0x0000007fe0f2ede8 in libcamera::RPi::CameraData::handleState() ()
at /lib/aarch64-linux-gnu/libcamera.so.0.0
#5 0x0000007fe0eaa750 in libcamera::ipa::RPi::IPAProxyRPi::processStatsCompleteThread(libcamera::ipa::RPi::BufferIds const&) () at /lib/aarch64-linux-gnu/libcamera.so.0.0
#6 0x0000007fe0e13088 in libcamera::Object::message(libcamera::Message*) ()
at /lib/aarch64-linux-gnu/libcamera-base.so.0.0
#7 0x0000007fe0e15490 in libcamera::Thread::dispatchMessages(libcamera::Message::Type) ()
at /lib/aarch64-linux-gnu/libcamera-base.so.0.0
#8 0x0000007fe0e0c804 in libcamera::EventDispatcherPoll::processEvents() ()
at /lib/aarch64-linux-gnu/libcamera-base.so.0.0
#9 0x0000007fe0e151b8 in libcamera::Thread::exec() () at /lib/aarch64-linux-gnu/libcamera-base.so.0.0
#10 0x0000007fe0ec6cf0 in libcamera::CameraManager::Private::run() ()
at /lib/aarch64-linux-gnu/libcamera.so.0.0
#11 0x0000007ff760bcac in () at /lib/aarch64-linux-gnu/libstdc++.so.6
#12 0x0000007ff6fdb648 in start_thread (arg=0x7fe0cff740) at pthread_create.c:477



My pipeline for gstreamer looks like this:
string p_line1 = "libcamerasrc ";
string p_line2 = "! video/x-raw, format=RGBx, width=640, height=480, framerate=30/1 ";
string p_line3 = "! videoflip method=rotate-180 ! videoconvert ! video/x-raw, format=(string)BGR ";
string p_line4 = "! appsink";
string pipeline = p_line1 + p_line2 + p_line3 + p_line4;



I followed this tutorial to install gstreamer
https://qengineering.eu/install-gstreamer-1.18-on-raspberry-pi-4.html />

What can be the cause of the problem and how do i fix it? Thanks in advance!
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Accessing composite QWidget

 Programing Coderfunda     May 08, 2024     No comments   

My code creates a composite widget, it is made of a button and a label.

It is part of broader code where this composite widget it is the element of a list.

But now let's focus on my problem that is:

How do I get to know the text in QPushButton?
This is the code:
myList = QListWidget(layout)
...
#this happens within a loop inside a method of the class

item = QtWidgets.QListWidgetItem()
item_widget = QtWidgets.QWidget()
line_push_button = QtWidgets.QPushButton("text I want to get")
line_push_button.clicked.connect(self.clicked)
line_text = QtWidgets.QLabel("some text")

item_layout = QtWidgets.QHBoxLayout()
item_layout.addWidget(line_push_button)
item_layout.addWidget(line_text)

item_widget.setLayout(item_layout)
myList.insertItem(i, item)
myList.setItemWidget(item, item_widget)



At runtime I can access myList, then I need to loop through the items of the list accessing for each of them the text in the button.

Since list element doesn't have a finChild, findChildren method I don't know what to do.

I don't understand how this kind of traversing works in PyQT
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to fitler on text array column with supabase-js

 Programing Coderfunda     May 08, 2024     No comments   

I have a table i Supabase which looks like this:



I want to use supabase-js client library to filter on phone_numbers (which is a text array).

If I do like this:
const { data, error } = await supabaseClient.from('profiles').select('*').contains('phone_numbers', ["123456"])



I get no result back.


If I do this in raw SQL it works (I get the row with id 2 back):
select * from profiles where phone_numbers @> array['123456'];



What am I doing wrong in the javascript filter?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

07 May, 2024

Announcing WireUse

 Programing Coderfunda     May 07, 2024     No comments   

I've created a package that I hope will be useful to others using Laravel and Livewire. It's still in early development, so I'd like to gather some feedback and also find out if the idea I have is living. :)

You can find the package and source-code on my GitHub:
https://github.com/foxws/wireuse

The idea of WireUse is based on something I used a lot in VueJS with VueUse. I want to stay as minimal as possible, and provide useful traits and features that you can use to build your own components.

To give you an idea of a small part of what is currently features included in WireUse:

* Force the usage of route-keys for making model connections.
* Component/Livewire recursive registration with caching.
* CSS class helpers that can be easily overruled or be used in other parts in the component
* Form helpers, like toCollection, toFluent, has, filled, ratelimiting, etc.- ..
* Blade/view helpers, like hash
* Action classes - useful for building tabs and dialogs




It is only a small selection, as I'm still building the documentation. I also need to add more tests, but also need to find out what's actually useful or not.

You can see the package live in action on [
https://foxws.nl/](https://foxws.nl/, and checkout the documentation for more details. Please let me know your thoughts, and let me know what features would be useful to be included as wel.

Things planned are form building, some sort of query/scout builders, but the priority is getting a decent platform to build upon and letting the user choose it own solutions.

Thanks, and please let me know your feedback! submitted by /u/francoisfox
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Optimize Your Eloquent Queries with AI

 Programing Coderfunda     May 07, 2024     No comments   

---



The Laravel Slower package is designed for Laravel developers who want to enhance the performance of their applications. This package identifies slow queries and suggests optimizations such as indexing and other improvements.


Depending on how you configure your application's scheduler, you could run the following commands each day to analyze and clean up old records:
php artisan slower:clean /*{days=15} Delete records older than 15 days.*/
php artisan slower:analyze /*Analyze the records where is_analyzed=false*/



Recommendations created with the slower:analyze command are stored in the database table created by this package, which you can review after AI analysis is completed. As part of the AI analysis, this package's main features include:



* A configurable slow threshold

* Configurable AI models like Chat GPT-4

* Disable AI and only log slow queries

* Configurable prompt for AI

* Disable slow query analysis






The README includes an example analysis to help you visualize what you can expect with this package:
/*
select count(*) as aggregate
from "product_prices"
where "product_id" = '1'
and "price" = '0'
and "discount_total" > '0'
*/

dd($model->recommendation);

/*
Indexing: Effective database indexing can significantly speed up query performance. For your query, consider adding a combined (composite)
index on product_id, price, and discount_total. This index would work well
because the where clause covers all these columns.
*/

/*
CREATE INDEX idx_product_prices
ON product_prices (product_id, price, discount_total);
*/



You can learn more about this package, get full installation instructions, and view the source code on GitHub.



The post Optimize Your Eloquent Queries with AI appeared first on Laravel News.


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

Moonshine is an Open-source Admin Panel for Laravel

 Programing Coderfunda     May 07, 2024     No comments   

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

from xgboost import XGBClassifier & import xgboost as xgb

 Programing Coderfunda     May 07, 2024     No comments   

I have already installed xgboost (using pip on anaconda),and import xgboost as xgb is fine.However when I am using from xgboost import XGBClassifier ,there is an error:




ImportError: cannot import name 'XGBClassifier'




information for platform:

1.windows 7

2.(base) C:\Users\george>pip list
DEPRECATION: The default format will switch to columns in the future. You can us
e --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.con
f under the [list] section) to disable this warning.
alabaster (0.7.10)
anaconda-client (1.6.9)
anaconda-navigator (1.7.0)
anaconda-project (0.8.2)
asn1crypto (0.24.0)
astroid (1.6.1)
astropy (2.0.3)
attrs (17.4.0)
Babel (2.5.3)
backports.shutil-get-terminal-size (1.0.0)
beautifulsoup4 (4.6.0)
bitarray (0.8.1)
bkcharts (0.2)
blaze (0.11.3)
bleach (2.1.2)
bokeh (0.12.13)
boto (2.48.0)
boto3 (1.9.42)
botocore (1.12.42)
Bottleneck (1.2.1)
certifi (2018.1.18)
cffi (1.11.4)
chardet (3.0.4)
click (6.7)
cloudpickle (0.5.2)
clyent (1.2.2)
colorama (0.3.9)
comtypes (1.1.4)
conda (4.4.10)
conda-build (3.4.1)
conda-verify (2.0.0)
contextlib2 (0.5.5)
cryptography (2.1.4)
cycler (0.10.0)
Cython (0.27.3)
cytoolz (0.9.0)
dask (0.20.1)
datashape (0.5.4)
decorator (4.2.1)
distributed (1.24.1)
docutils (0.14)
entrypoints (0.2.3)
et-xmlfile (1.0.1)
fastcache (1.0.2)
featuretools (0.4.0)
filelock (2.0.13)
Flask (0.12.2)
Flask-Cors (3.0.3)
future (0.17.1)
gevent (1.2.2)
glob2 (0.6)
greenlet (0.4.12)
h5py (2.7.1)
heapdict (1.0.0)
html5lib (1.0.1)
idna (2.6)
imageio (2.2.0)
imagesize (0.7.1)
ipython (6.2.1)
ipython-genutils (0.2.0)
ipywidgets (7.1.1)
isort (4.2.15)
itsdangerous (0.24)
jdcal (1.3)
jedi (0.11.1)
Jinja2 (2.10)
jmespath (0.9.3)
jsonschema (2.6.0)
jupyter (1.0.0)
jupyter-client (5.2.2)
jupyter-console (5.2.0)
jupyter-core (4.4.0)
jupyterlab (0.31.4)
jupyterlab-launcher (0.10.2)
lazy-object-proxy (1.3.1)
llvmlite (0.21.0)
locket (0.2.0)
lxml (4.1.1)
MarkupSafe (1.0)
matplotlib (2.1.2)
mccabe (0.6.1)
menuinst (1.4.11)
mistune (0.8.3)
mpmath (1.0.0)
msgpack (0.5.6)
msgpack-python (0.5.1)
multipledispatch (0.4.9)
navigator-updater (0.1.0)
nbconvert (5.3.1)
nbformat (4.4.0)
networkx (2.1)
nltk (3.2.5)
nose (1.3.7)
notebook (5.4.0)
numba (0.36.2)
numexpr (2.6.4)
numpy (1.14.0)
numpydoc (0.7.0)
odo (0.5.1)
olefile (0.45.1)
openpyxl (2.4.10)
packaging (16.8)
pandas (0.23.4)
pandocfilters (1.4.2)
parso (0.1.1)
partd (0.3.8)
path.py (10.5)
pathlib2 (2.3.0)
patsy (0.5.0)
pep8 (1.7.1)
pickleshare (0.7.4)
Pillow (5.0.0)
pip (9.0.3)
pkginfo (1.4.1)
plotly (3.4.2)
pluggy (0.6.0)
ply (3.10)
prompt-toolkit (1.0.15)
psutil (5.4.8)
py (1.5.2)
pycodestyle (2.3.1)
pycosat (0.6.3)
pycparser (2.18)
pycrypto (2.6.1)
pycurl (7.43.0.1)
pyflakes (1.6.0)
Pygments (2.2.0)
pylint (1.8.2)
pyodbc (4.0.22)
pyOpenSSL (17.5.0)
pyparsing (2.2.0)
PySocks (1.6.7)
pytest (3.3.2)
python-dateutil (2.6.1)
pytz (2017.3)
PyWavelets (0.5.2)
pywin32 (222)
pywinpty (0.5)
PyYAML (3.12)
pyzmq (17.1.2)
QtAwesome (0.4.4)
qtconsole (4.3.1)
QtPy (1.3.1)
requests (2.18.4)
retrying (1.3.3)
rope (0.10.7)
ruamel-yaml (0.15.35)
s3fs (0.1.6)
s3transfer (0.1.13)
scikit-image (0.13.1)
scikit-learn (0.19.1)
scipy (1.0.0)
seaborn (0.8.1)
Send2Trash (1.4.2)
setuptools (38.4.0)
simplegeneric (0.8.1)
singledispatch (3.4.0.3)
six (1.11.0)
snowballstemmer (1.2.1)
sortedcollections (0.5.3)
sortedcontainers (1.5.9)
Sphinx (1.6.6)
sphinxcontrib-websupport (1.0.1)
spyder (3.2.6)
SQLAlchemy (1.2.1)
statsmodels (0.8.0)
sympy (1.1.1)
tables (3.4.2)
tblib (1.3.2)
terminado (0.8.1)
testpath (0.3.1)
toolz (0.9.0)
tornado (5.1.1)
tqdm (4.28.1)
traitlets (4.3.2)
typing (3.6.2)
unicodecsv (0.14.1)
urllib3 (1.22)
wcwidth (0.1.7)
webencodings (0.5.1)
Werkzeug (0.14.1)
wheel (0.30.0)
widgetsnbextension (3.1.0)
win-inet-pton (1.0.1)
win-unicode-console (0.5)
wincertstore (0.2)
wrapt (1.10.11)
xgboost (0.81)
xlrd (1.1.0)
XlsxWriter (1.0.2)
xlwings (0.11.5)
xlwt (1.3.0)
zict (0.1.3)




Anyone has any ideas how to fix this?I have read some information which recommend to update xcode(it supposed to be used on Mac) and some recommed alter the name of xgboost.py to another(no sight of this file)



Anyone knows please kindly give some advice.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Automaticall generate pass through to child object function

 Programing Coderfunda     May 07, 2024     No comments   

I would like to automatically forward a function call to a child in python, so that the parent class has said function and then forwards the call to the child and returns the result to the caller. Something like this:
class child:
def __init__(self):
self.b = 1

def dosomething(self, a=1):
print("child dosomething", a, self.b)
return 'returning stuff'

class parent:
def __init__(self):
self.child = child()

# I could do this for every func in child:
def dosomething(self, *args, **kwargs):
return self.child.dosomething()

p = parent()
p.dosomething()




Since I don't want to risk typos or forgetting to update the parent this should be done automatically and not like shown above, especially if child has lots of functions.


I was able to do something similar to this by implementing getattr for the parent class, but this way neither my IDE nor the interpreter knows about the methods in parent / child which is not what I want.


Another way I was exploring was to get all methods of the child using
def get_methods(x):
return [
[method, getattr(x, method)]
for method in dir(x)
if callable(getattr(x, method))
if not method.startswith("_")
]



and then somehow attach them to my parent class.
I can do that using setattr(parent,'dosomething',func_from_get_methods(child))
and then call it the same way as before, but this wont work, since parent has no self.b.


So, is there any pythonic way to do this?


P.S. I'm not talking about subclassing.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

06 May, 2024

Build Your SaaS In Days With SaaSykit

 Programing Coderfunda     May 06, 2024     No comments   

---



SaaSykit is a feature-rich Laravel SaaS boilerplate that helps you build and launch your SaaS application in days instead of months.


SaaSykit is a robust framework that includes everything needed to run a modern SaaS. It help your launch fast, iterate on your SaaS ideas quickly, save time and effort, and focus on implementing your core SaaS features instead of reinventing the wheel by building every component from scratch to run your SaaS.


SaaSykit features in a nutshell:



* 💰 Payment provider integration (Stripe, Paddle & Lemon Squeezy)

* 💻 Easy product, plan, discount and pricing management

* 👩 Stunning admin panel and user dashboard (powered by FilamentPHP)

* 🚪 Beautiful checkout process

* 🗓️ Ready-to-use components (hero sections, features, testimonials, and more)

* 🥑 Built-in user authentication and social login (Google, Facebook, X, and more)

* 📈 SaaS metric tracking in a beautiful dashboard

* 🎨 Customizable landing page styling for your branding

* 💌 Email templates and transactional emails

* 📝 Built-in Blog

* 🚧 Integrated Roadmap

* 🧒 User / role management

* 🌍 Fully translatable and SEO-optimized

* 🚀 One-line deployment

* and much more






Building a SaaS has never been easier. Check out SaaSykit to know more.



The post Build Your SaaS In Days With SaaSykit appeared first on Laravel News.


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

How to get the very last non-list element of a multidimensional list in Python 3 [duplicate]

 Programing Coderfunda     May 06, 2024     No comments   

I want to retrieve the very last element of a multidimensional list, like this:
GetLastElement([[2, 3], [2, [3, 4], [5, 6]]]) # Returns 6
GetLastElement([[3, [4]]]) # Returns 4



The problem is that I can't find an easy solution, and it affects readability. For example, if I wanted to get the last element, I would use [...][-1] instead of defining Last and using Last([...]) repeatedly—until I forget that I'm working on another project that doesn't contain Last.


I expect the answers to be non-recursive (meaning, they don't use recursion). Importing is fine for me.


This is what I except the GetLastElement function to be
def GetLastElement(List_to_get):
ToReturn = List_to_get
while True:
if isinstance(ToReturn, list):
ToReturn = ToReturn[-1]
else:
return ToReturn



However, I want to shorten it in one line of code without using def or lambda.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Mermaid Diagrams in Laravel - Feedback Wanted

 Programing Coderfunda     May 06, 2024     No comments   

I've started pulling together a package to streamline the process of including Mermaid JS Diagrams in a Laravel project. For example, to create flowcharts, process diagrams or other business information that you want to present to users in a visual format. So far, we're using this to visualise a few of our more complex business processes (the package can create diagrams from lists, arrays or Eloquent Collections).

Mermaid can already be used in Github Markdown and in Notion so I'm picking that it'll become a popular request from business users who want diagrams powered by business data. This package will make that a lot faster to implement.

Would love any feedback or advice on making the package easier to use and simpler for developers to pull into existing projects.


https://github.com/icehouse-ventures/laravel-mermaid submitted by /u/PeterThomson
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Module 'SquareReaderSDK' not found in IOS

 Programing Coderfunda     May 06, 2024     No comments   

I'm encountering an issue with integrating the SquareReaderSDK into my iOS project. Despite following the documentation and ensuring that I've properly added the SDK to my project, Xcode still reports that it cannot find the SquareReaderSDK module.


Here are the steps I've taken so far:




*

I've added the SquareReaderSDK framework to my project by dragging it into the "Frameworks, Libraries, and Embedded Content" section of my target settings.


*

I've made sure that the framework is listed under "Link Binary With Libraries" in the "Build Phases" settings for my target.


*

I've imported the SquareReaderSDK module in the appropriate files where I need to use it.






I've tried cleaning the build folder, deleting derived data, and restarting Xcode, but the issue persists.


Is there anything else I might be missing or any additional steps I need to take to properly integrate the SquareReaderSDK into my project? Any help or insights would be greatly appreciated.


Versions:




*

"react-native": "0.72.3",


*

"react-native-square-reader-sdk": "^1.4.3"






Device:

IOS simulator: IPhone 15


Error Screenshot:





I have followed the documnentation of sqaure reader sdk.


https://github.com/square/react-native-square-reader-sdk/blob/master/docs/get-started.md#step-5-install-reader-sdk-for-ios
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Weekly /r/Laravel Help Thread

 Programing Coderfunda     May 06, 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

05 May, 2024

How to setup routeEnhancer for EXT:news which works in redirct module for linking accross languages

 Programing Coderfunda     May 05, 2024     No comments   

While everything works fine on list, detail and category pages with routeEnhancers setup as given in the documentation – I'm struggling to get it working on the redirects module.


Configuring the linkhandler as described here, I'm able to select a news entry as target. By using an additional param for the language (e.g. L=1) the redirect works as aspected and the user get's the selected target news entry – but only as long as there is no routeEnhancer for news.


With an active routeEnhancer the generated URL consists of both languages and looks something like this: www.domain.com/newsdetailpage-default-lang/newstitle-target-langguage.


Are there any suggestions how to solve that?


(TYPO3 v12.4 and News v11.4.1)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Python bypass Cloudflare using headless selenium while opening the new tab

 Programing Coderfunda     May 05, 2024     No comments   

I have a website to be scraped, daily around 10k-20k visits to the page. I did it for more than 1 month, and everything is fine.



* I can access it using the non-selenium browser.

* For now, using the Selenium browser, there is Cloudflare which blocks me from visiting. After 3 to 5 click on Cloudflare block, it still distinguishes me as a bot.

* However, under the same Selenium browser, I open this website using a new tab, and it works. However, I still need to click on Cloudflare once to visit the website.






Tried:



* Pass in user agent

* options.add_experimental_option('useAutomationExtension', False)

* options.add_argument('--disable-blink-features=AutomationControlled')

* Selenium headless: How to bypass Cloudflare detection using Selenium

* selenium_stealth (don't know whether in a correct way)




def getDriver():
options = webdriver.ChromeOptions()
# chrome_options.add_argument("--headless")

broswer = uc.Chrome(options=options, version_main=113)

return broswer



How can I modify it to make it work using headless mode?


Current setting: undetected chrome, version = 113
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Can you defer evaluation of a variable used in a view removal transition?

 Programing Coderfunda     May 05, 2024     No comments   

I've got a parent view that presents one of a couple of views, depending on the value of an observed variable.


In the simple example below, RainbowView is presented when the @Published variable "settings.showRainbow" is true.


The RainbowView sets "settings.showRainbow" to false when the user taps one of the colours of the rainbow, which causes the parent view to remove it, and display another view. The tap location is also set by RainbowView.


When RainbowView is removed, its removal transition animation is to zoom in around the location where the user tapped.


It works perfectly ... except, of course, that the value of the removal transition's .scale anchor, the variable "tapLocation", is set when the view is presented, rather than when it is removed.


What I'd like, is for SwiftUI to wait to capture the anchor location until the point in time where the view is about to be removed.


Does anyone know if this is possible? I could make the child view responsible for animating itself when it's about to be dismissed (which works OK), but I would prefer to have the parent view be responsible for the removal animation.


Here's a code snippet:
if settings.showRainbow {
RainbowView()
.transition(AnyTransition
.asymmetric(
insertion: .opacity,
removal: .scale(scale: 24,
anchor: tapLocation)))
} else {
OtherView()
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Firebase Functions V2 - Use custom domain for http calls [duplicate]

 Programing Coderfunda     May 05, 2024     No comments   

I'm using Firebase functions v2 and I would like to use a custom domain name for HTTP calls. I already searched before posting but all answers are for Firebase functions v1.


Here is the function showed in the Firebase console:

https://-ltnwgqwdfq-uc.a.run.app />


And here is what I would like to achieve:

https://.my-domain.com />


Here is what I tried:


In firebase.json file
{
"hosting": {
"rewrites": [
{
"source": "/api/function-name",
"function": {
"functionId": "function-name"
},
{
"source": "!/@(api)/**",
"destination": "/index.html"
}
]
}
// [...]



I deployed only the hosting part and when I try to run the google cloud function it works well:

https://function-name-ltnwgqwdfq-uc.a.run.app />


But impossible to run the custom domain name function (it redirects me to a 404 HTML page):

https://my-domain.com/function-name
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Two div blocks on same line

 Programing Coderfunda     May 05, 2024     No comments   

How to center on the same "line" two div blocks?



First div:






Second div:
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

04 May, 2024

Uncaught TypeError: Cannot read property 'filter' of undefined

 Programing Coderfunda     May 04, 2024     No comments   

My custom filter is giving me an error.



Uncaught TypeError: Cannot read property 'filter' of undefined



code :

angular.module('PatientApp', []).filter('ageFilter', function() {
// birthday is a date
function calculateAge(birthday) {
var dateOut = new Date(birthday);
dateOut.setDate(dateOut.getDate() + 1);
var ageDifMs = Date.now() - dateOut .getTime();
// miliseconds from epoch
var ageDate = new Date(ageDifMs);
return Math.abs(ageDate.getUTCFullYear() - 1970);
}
return function(birthdate) {
return calculateAge(birthdate);
};
});
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

any alternative to using execCommand("removeformat")

 Programing Coderfunda     May 04, 2024     No comments   

I am trying to add a button that removes format of selected text.
There are several wysiwyg editors available, but I am researching it's implementation from scratch.
execCommand("removeformat") doesn't strip certain tags (h2) but works with (b, em). We can strip each tag.


For example we have


12345





we can select "234" and usind window.getSelection()
we could transform it to


1


234


5





But there is a lot of edge cases. And it is hard to check every case.
If we have a nested DOM structure, it’s difficult to tell using text nodes which tag should be copied from and to which if we select "hello" here.

3 hello 5




the output will could be

3

hello

5




If we selected whole text node we can remove some tags.
123



to
123



It is quite hard to understand how we convert these nodes especially when we selected several text nodes.
We can get text nodes using this approach How to get nodes lying inside a range with javascript?



Are there any libraries that provides those methods
bold, unbold text and removeFormatting or an algorithm.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Different output in VisualStudio and Codeblocks

 Programing Coderfunda     May 04, 2024     No comments   

I need a linear interpolation in 2D array. The output in Codeblocks is correct, but in VisualStudio is not.


I got 2 main functions.




*

Linear interpolation in 1D array:
Function is Y(X) and the result is Y(x).


*

Linear interpolation in 2D array:
Function is Y(X1, X2) and the result is Y(x, y).






And function to test it.
#include
#include
#include

double lin_int(int size, double* X, const double* Y, double x){
int i;
if (x >= *(X + size-1)){
return *(Y + size-1);
} else
if (x = x && *(X + i - 1) *(X1+m) && y > *(X2+n)) return *(Y+m*n-1); //по X1 и X2 больше оба значения x, y - возвращаем Y[m][n]
if (x < *(X1)) x = *(X1); //по X1 значение x меньше X1[0] - ставим x = X1[0]
if (y < *(X2)) y = *(X2); //по X2 значение y меньше X2[0] - ставим y = X2[0]
if (x > *(X1+m-1)) x = *(X1+m-1); //по X1 значение x больше X1[m] - ставим x = X1[m]
if (y > *(X2+n-1)) y = *(X2+n-1); //по X2 значение y больше X2[n] - ставим y = X2[n]
for (i = 0; i < n-1; i++){
if (x == *(X1 + i)){ //Проверка что мы в узле X1
in_X1 = true;
break;
} else
if (x > *(X1 + i) && x < *(X1 + i + 1)) break; //Если не в узле, фиксируем индекс предыдущего узла
}
for (j = 0; j < m-1; j++){
if (y == *(X2 + j)){ //Проверка что мы в узле X2
in_X2 = true;
break;
} else
if (y > *(X2 + j) && y < *(X2 + j + 1)) break; //Если не в узле, фиксируем индекс предыдущего узла
}

if (in_X1 && in_X2) { //Если попали в два узла сетки, возвращаем уже известное значение
return *((Y + i*n) + j);
} else
if (in_X1) { //Если в узле только по X1, возвращаем lin_int между узлами X2
return lin_int(n, X2, (Y+i*n), y);
} else
if (in_X2) { //Если в узле только по X2, возвращаем lin_int между узлами X1
x1 = *((Y+i*n)+j);
x2 = *((Y+(i+1)*n)+j);
if (*(X1+i+1) == *(X1+i)){
return x1 + (x2-x1) * (x-*(X1+i)) / (*(X1+i)*2); //два совпадающих значения в узлах
}
return x1 + (x2-x1) * (x-*(X1+i)) / (*(X1+i+1) - *(X1+i));
} else { //Если ни в какой узел не попали
if (*(X1+i+1) == *(X1+i)){
return x1 + (x2-x1) * (x-*(X1+i)) / (*(X1+i)*2); //два совпадающих значения в узлах
}
x1 = lin_int(n, X2, (Y+i*n), y); //Если не попали ни в какой узел, вычисляем x1, x2 и возвращаем lin_int между ними
x2 = lin_int(n, X2, (Y+(i+1)*n), y);
return x1 + (x2-x1) * (x-*(X1+i)) / (*(X1+i+1) - *(X1+i));
}
}

void test_lin_int_mass(void){
double X1[4] = { 0.3, 1.0, 4.0, 10.0 };
double X2[3] = { 0.0, 90.0, 180.0 };
double Y[4][3] =
{/* 0 90 180 */
/*0.3*/ {1.0, -0.107, -0.5},
/*1.0*/ {1.3, -0.3, -0.7},
/*4.0*/ {1.5, -0.2, -0.6},
/*10.*/ {1.53, -0.253, -0.5}
};

double i,j;
for (i=0; i
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Getting a wrong output all the time

 Programing Coderfunda     May 04, 2024     No comments   

I was just trying out a code for finding whether a number is an Armstrong number or not. But it was getting the same output for all the inputs even it is a Armstrong number. So I used an online compiler and it worked.
#include
#include

int main() {
int originalNum, num, lastDigit, digits, sum;

/* Input number from user */
printf("Enter any number to check Armstrong number: ");
scanf("%d", &num);

sum = 0;
originalNum = num;

/* Calculate the number of digits in the input number */
for (digits = 0; originalNum > 0; digits++) {
originalNum /= 10;
}

originalNum = num;

/* Compute the sum of the cubes of individual digits */
while (originalNum > 0) {
lastDigit = originalNum % 10;
sum += pow(lastDigit, digits);
originalNum /= 10;
}

/* Check if the sum equals the original number */
if (sum == num) {
printf("%d is an Armstrong number.\n", num);
} else {
printf("%d is not an Armstrong number.\n", num);
}

return 0;
}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Moonshine is an Open-source Admin Panel for Laravel

 Programing Coderfunda     May 04, 2024     No comments   

---



Moonshine is an open-source package for Laravel offering an admin panel you can use for MVPs, back-office applications, and content management systems. You can make an admin panel with authorization and CRUD in minutes.


Moonshine Demo Admin



Moonshine is a tool for rapid development using the package's CMS features, and other features that make you productive using familiar tools like Blade, Livewire, and Alpine:



* Moonshine helps you create functionality rapidly

* There is no binding to models; you can take whatever data you like

* Form and table builder

* Lightweight and easy to use AlpineJs

* Tailwind CSS and Blade, familiar to the vast majority of Laravel developers

* Ability to use Blade and Livewire components

* Convenient template builder, change colors and overall design






To start with Moonshine, chect out the Installation guide. The documentation is another good place to start, along with the MoonShine 2 video guide.



The post Moonshine is an Open-source Admin Panel for Laravel appeared first on Laravel News.


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

03 May, 2024

Bag: Immutable Value Objects for Laravel (and PHP)

 Programing Coderfunda     May 03, 2024     No comments   

Hey folks,

I recently published a new package called Bag that provides immutable value objects for Laravel (and PHP in general). It relies on Laravel Collections and Validation and some other parts of the Laravel framework.

It's heavily inspired by spatie/laravel-data, so if you're familiar with it but are interested in the safety of immutable value objects, then you should definitely check out Bag. For a more detailed comparison of the two libraries, check out the Why Bag? page. Full docs can be found here.

I'm gearing up for a 1.0 release (see: the roadmap) and would love y'alls feedback. Feel free to either comment here, or open up issues on the GitHub repo.

You can install it using composer require dshafik/bag.

Thanks for reading, I'll leave you with Bag's cute little mascot:


https://preview.redd.it/tv90hmgt61yc1.png?width=1280&format=png&auto=webp&s=b5bb623104f2993b1ce03fb17633887b4dc69bb0 submitted by /u/dshafik
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

What do you use to make API documentation?

 Programing Coderfunda     May 03, 2024     No comments   

I have previously used some packages, which basically generated documentation by getting those giant ugly docblocks above each controller method. What is the standard today? I think ideally I would like to have a directory with json/yaml file for each request/resource, maybe the chance to reuse files that hold responses, and a cli command that generates a pretty page, which search and everything. submitted by /u/iShouldBeCodingAtm
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

I'm still unsure how DeferrableProvider improves performance

 Programing Coderfunda     May 03, 2024     No comments   

Referring to the documentation, it states:

Deferring the loading of such a provider will improve the performance of your application, since it is not loaded from the filesystem on every request.

Based on my understanding, consider this example: class RiakServiceProvider extends ServiceProvider implements DeferrableProvider { public function register(): void { $this->app->singleton(Connection::class, function (Application $app) { return new Connection($app['config']['riak']); }); } public function provides(): array { return [Connection::class]; } }

If laravel instantiates the RiakServiceProvider class and calls the register method (regardless of whether I resolve the Connection::class out of the container), how does it optimize the performance of the application? submitted by /u/foremtehan
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Filament Context Menu

 Programing Coderfunda     May 03, 2024     No comments   

Filament Context Menu Plugin lets you add right-click context menus for faster actions on pages & tables.

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

NativePHP Windows Builds are Here

 Programing Coderfunda     May 03, 2024     No comments   

---



Windows support for NativePHP was announced, which means that you can now build applications for the Windows platform. Windows builds are working, and with that, all platforms will get new versions of PHP to work with.



I know many of you have been patiently waiting for this. Over the months, we've racked up quite a few issues as folks have attempted to find some way to get Windows builds working.


I totally get this enthusiasm, Windows support was always on the cards, but we stated early on that Windows support was going to take a while longer for one main reason: a lack of static builds of PHP for Windows with enough extensions baked in to support booting a Laravel application.



To start building for Windows, update to the latest version of nativephp/electron via Composer:
composer require nativephp/electron



You can now build for Windows even while on another OS using the OS argument via the build command:
php artisan native:build win



Along with Windows support, this release introduces broader support for multiple versions of PHP. This release enables full Laravel 11 support using PHP 8.2 or PHP 8.3 to develop your applications. NativePHP binaries are expected to happen more regularly.


You can learn more about this release from the GitHub discussion. 



The post NativePHP Windows Builds are Here appeared first on Laravel News.


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

02 May, 2024

Why does S3.deleteObject not fail when the specified key doesn't exist?

 Programing Coderfunda     May 02, 2024     No comments   

Using the AWS SDK for Node, why do I not get an error when trying to delete an object that doesn't exist (i.e. the S3 key is wrong)?



If I specify a non-existent bucket on the other hand, an error is produced.



If you consider the following Node program, the Key parameter lists a key which doesn't exist in the bucket, yet the error argument to the callback is null:

var aws = require('aws-sdk')

function getSetting(name) {
var value = process.env[name]
if (value == null) {
throw new Error('You must set the environment variable ' + name)
}
return value
}

var s3Client = new aws.S3({
accessKeyId: getSetting('AWSACCESSKEYID'),
secretAccessKey: getSetting('AWSSECRETACCESSKEY'),
region: getSetting('AWSREGION'),
params: {
Bucket: getSetting('S3BUCKET'),
},
})
picturePath = 'nothing/here'
s3Client.deleteObject({
Key: picturePath,
}, function (err, data) {
console.log('Delete object callback:', err)
})
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Is there a way to get a model's many to many relationship by reference?

 Programing Coderfunda     May 02, 2024     No comments   

I'm constantly exhausting my PHP's memory limit. I believe it's due to loading too many models into memory. My current setup is works something like this: I have 75 models that have many other related models (~243) that belong to many other related models (~6) with pivot data.

Once we get down to it, I'm looking at 120k+ models loaded into memory. That last set of models being a majority of those but I know there are tons upon tons of duplicates in there.

Is there anyway to call these relationships by reference with eloquent? submitted by /u/pitcherc
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

NativePHP now supports Windows!

 Programing Coderfunda     May 02, 2024     No comments   

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

Is Laravel the most complete out-of-the-box framework?

 Programing Coderfunda     May 02, 2024     No comments   

I do a lot of full-stack solo projects for clients. Simple stuff for the most part, nothing crazy. Mainly for clients who want something more custom and more advanced than a typical Wordpress/Shopify site, but don’t have the capacity to hire a boutique agency or an internal team. So they end up with skilled freelance work as a happy medium.

Most projects involve authentication, database optimization, occasionally caching if a high volume site, and occasionally store-based state management if there is a lot of custom functionality. I use Tailwind and Blade for the front-end views, and write my own controllers and database schema.

So far, I am loving Laravel. Coming from React and Next.Js, it is a breath of fresh air. I can easily scan a page and know exactly what the propose of the functions are, and how they should look. In contrast, most React applications I open look like JavaScript soup for the first 10 minutes while I orient myself.

I never knew I needed separation of concerns and functional programming, but coming from JavaScript frameworks, it is so much easier to develop this way. I only have to focus on one thing at a time, and solutions are usually very straightforward to conceptualize since each function is usually only responsible for a few actions. As an added bonus there aren’t properties being passed down through multiple layers of components which makes debugging much easier.

I don’t think I’ll ever go back to JavaScript frameworks (maybe Svelte or Solid), but this framework has truly made programming fun again.

Are there any other frameworks that can really compete with Laravel from an ecosystem standpoint? It has minimal amount of dependencies, good performance, excellent debugging tools, excellent routing and rendering features, an excellent ORM, and many more features that would have been external dependencies in other frameworks.

I can’t believe it took me this long to find Laravel. I thought it was just a back-end framework and had never really looked into it before a few weeks ago, but I am certainly glad that I did.

Taylor Orwell, you are a God among men. Thanks to you I never have to wonder what tech stack is best for a project anymore, the answer will always be Laravel. Does anyone have a “buy me a coffee” link for him? He definitely deserves it. Probably the only time I’ve been so in awe of a single developer other than when I first played Stardew Valley by Eric Barone. submitted by /u/techdaddykraken
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Replicate Laravel PHP Client

 Programing Coderfunda     May 02, 2024     No comments   

---



The Replicate Laravel package is a PHP client for the Replicate API, an API to run and fine-tune open-source AI models. Here's a quick example from the package's readme of using the Replicate Laravel client:
use HalilCosdu\Replicate\Facades\Replicate;

$response = Replicate::createModel($data)

// Response methods
$response->body(); // string
$response->json($key = null, $default = null); // mixed
$response->object(); // object
$response->collect($key = null); // Illuminate\Support\Collection
$response->status(); // int
$response->successful(); // bool
$response->redirect(); // bool
$response->failed(); // bool
$response->clientError(); // bool
$response->header($header); // string
$response->headers(); // array



At the release of this post, the Replicate Laravel client has the following endpoints:



* Account

* Models

* Predictions

* Trainings

* Model collection

* Deployments

* Model hardware

* And more...






For usage examples, see the complete Replicate API documentation. The Replicate API lets you generate images, text, videos, music, speech, and more using thousands of community models. To start using Replicate Laravel in your own applications, check out this package on GitHub at halilcosdu/laravel-replicate.



The post Replicate Laravel PHP Client appeared first on Laravel News.


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

Meta

Popular Posts

  • Write API Integrations in Laravel and PHP Projects with Saloon
    Write API Integrations in Laravel and PHP Projects with Saloon Saloon  is a Laravel/PHP package that allows you to write your API integratio...
  • Credit card validation in laravel
      Validation rules for credit card using laravel-validation-rules/credit-card package in laravel Install package laravel-validation-rules/cr...
  • Fast Excel Package for Laravel
      Fast Excel is a Laravel package for importing and exporting spreadsheets. It provides an elegant wrapper around Spout —a PHP package to ...
  • 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...
  • Features CodeIgniter
    Features CodeIgniter There is a great demand for the CodeIgniter framework in PHP developers because of its features and multiple advan...

Categories

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

Social Media Links

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

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

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

Loading...

Laravel News

Loading...

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