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

06 April, 2024

Detecting .NET8 with Inno Setup and InnoDependenciyInstaller

 Programing Coderfunda     April 06, 2024     No comments   

I am looking at using InnoDependencyInstaller and it has a function that it uses under the hood:


Dependency_AddDotNet80
procedure Dependency_AddDotNet80;
begin
To detect .NET 8 using Inno Setup, you can use a combination of registry checks and custom code execution. Here's a basic example of how you can achieve this:

1. **Registry Check**: Check the registry to see if .NET 8 is installed. .NET 8 would be installed under a registry key specific to its version.

2. **Custom Code Execution**: If the registry check indicates .NET 8 is not installed, you can prompt the user to install it. You can execute custom code to check for the presence of .NET 8 assemblies or use InnoDependencyInstaller to install .NET 8 automatically.

Below is a sample script demonstrating how you can accomplish this:

```pascal
[Setup]
AppName=MyApp
AppVersion=1.0
DefaultDirName={pf}\MyApp

[Code]
function IsDotNet8Installed: Boolean;
var
  regKey: string;
begin
  // Check the registry to see if .NET 8 is installed
  regKey := 'Software\Microsoft\NET Framework Setup\NDP\v8\Full';
  Result := RegKeyExists(HKLM, regKey) or RegKeyExists(HKCU, regKey);
end;

procedure InstallDotNet8;
begin
  // Custom code to install .NET 8 or use InnoDependencyInstaller
  // Example:
  // ShellExec('open', 'https://dotnet.microsoft.com/download/dotnet/8.0', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

function InitializeSetup: Boolean;
begin
  // Check if .NET 8 is installed
  if not IsDotNet8Installed then
  begin
    // Prompt the user to install .NET 8
    if MsgBox('This application requires .NET 8. Would you like to install it now?', mbConfirmation, MB_YESNO) = IDYES then
    begin
      InstallDotNet8;
      Result := False; // Abort setup
      Exit;
    end
    else
    begin
      // .NET 8 not installed and user declined installation
      MsgBox('.NET 8 is required to install this application. Setup will now exit.', mbError, MB_OK);
      Result := False; // Abort setup
      Exit;
    end;
  end;

  // .NET 8 is installed, continue setup
  Result := True;
end;
```

In this script:

- `IsDotNet8Installed` function checks the registry to see if .NET 8 is installed.
- `InstallDotNet8` procedure executes custom code to install .NET 8 or launches a browser to download it.
- `InitializeSetup` function is called before the setup begins. It checks if .NET 8 is installed. If not, it prompts the user to install it.

You may need to adjust the registry key path based on the specific registry location where .NET 8 is installed on your system. Additionally, replace the `InstallDotNet8` procedure with the appropriate code to install .NET 8 or utilize InnoDependencyInstaller to handle the installation automatically.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

05 April, 2024

Not able to stream in Flutter, throwing Platform exception

 Programing Coderfunda     April 05, 2024     No comments   

Here i am using 'apivideo_live_stream ' package for streaming purposes,Facing one issue while streaming time


[Issue]: Encountering an Exception when streaming Time in Flutter. Error Message: 'PlatformException(failed_to_start_stream, java.lang.IllegalArgumentException: Only one audio stream is supported by FLV, null, null)'. This issue is a significant roadblock in our current project, rendering it unable to run. Seeking assistance from the community to resolve this critical issue. Any support in resolving this matter would be greatly appreciated


////creating live stream controller instance
ApiVideoLiveStreamController createLiveStreamController(
BuildContext context) {
return ApiVideoLiveStreamController(
initialAudioConfig: config.audio,
initialVideoConfig: config.video,
onConnectionSuccess: () {
log('Connection succeeded');
},
onConnectionFailed: (error) {
log('on error failed1: $error');
Utils.showCustomDialog(context, 'Connection failed',
"Something went wrong, Please try again later"
// error
);
if (isStreaming) {
manualStopButtonClicked(context);
} else {
setIsStreaming(false);
}
// if (mounted) {

// }
},
onDisconnection: () async {
log('on error failed:2 ');
// Utils.snackBar('Disconnected', context);
// if (mounted) {
if (isStreaming) {
manualStopButtonClicked(context);
} else {
setIsStreaming(false);
}
// }
},
onError: (error) {
log('on error failed:3 $error');
// Get error such as missing permission,...
Utils.showCustomDialog(
context, 'Error', 'Something went wrong, Please try again later');
// if (mounted) {
if (isStreaming) {
manualStopButtonClicked(context);
} else {
setIsStreaming(false);
}
// }
});
}

//initialize controller
await _controller.initialize().catchError((exception) {
Utils.snackBar('Something went wrong, Please try again Later', context);
});



This the code for start stream
void onStartStreamingButtonPressed(BuildContext context) async {
_isStreamingStarted = true;
await _controller.setAudioConfig(config.audio);
startStreaming().then((_) {
setIsStreaming(true);
_isStreamingStarted = false;
notifyListeners();

startTimer();
Utils.snackBar("Streaming Started..!", context);
}).catchError((error) {
_isStreamingStarted = false;
if (error is PlatformException) {
log("strat stream 1 $error");
;
Utils.showCustomDialog(context, "Error",
"Something went wrong in server side, Please try again Later");
} else {
log("strat stream 2 $error");

Utils.showCustomDialog(
context, "Error", "Something went wrong , Please try again Later");
}
});
notifyListeners();
}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Enabling authentication in swagger

 Programing Coderfunda     April 05, 2024     No comments   

I created a asp.net core empty project running on .net6. I am coming across an issue when I am trying to enable authentication in swagger. Swagger UI runs as expected, the only issue is whenever I click on the Authorize green button on the swagger UI it will pop up but say Unknown Security definition type and give me two options Authorize and Close. It does not show under Available authorizations Bearer(http,Bearer) and allow me to enter a jwt value. I ran into this article that goes over bearer authentication but it isn't much help for me. Am I missing something in the .AddSwaggerGen()?



builder.Services.AddAuthorization();

builder.Services.AddSwaggerGen(options =>
{
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Scheme = "Bearer",
BearerFormat = "JWT",
In = ParameterLocation.Header,
Name = "Authorization",
Description = "Bearer Authentication with JWT Token",
Type = SecuritySchemeType.Http
});
options.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Id = "Bearer",
Type = ReferenceType.SecurityScheme
}
},
new List()
}
});
});

var app = builder.Build();
app.UseAuthorization();
app.UseAuthentication();
......
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Symfony custom field type with data transformer not working properly when in an embedded collection form

 Programing Coderfunda     April 05, 2024     No comments   

I am having a problem in Symfony with a custom data transformer on a custom form field - but only when this is used in a collection/embedded form within my main form. If I use the same custom field type and transformer for field directly in the main form, then it works perfectly.
Basically I have an app that is a database of all of my music/films/etc. Each item is stored in an entity called AVItem. For each of these items I can have zero or more tracks and I do this with a CollectionType. Within this embedded form/collection I have simple text fields and also a Collection of EntityType and they all work perfectly when submitting the main form; however, only the one field that uses my custom field type and transformer does not.
My custom field is for a "duration". In the database I save any lengths of time purely as an integer of seconds; however, I display it and want it entered as a string in the form [HH:]mm:ss. When displaying, the custom field and transformer works, it reads the number of seconds from the entity and then the "transform" method correctly displays that as HH:mm:ss. However, when I submit the main form and one of those tracks has something entered into it, when the "reverseTransform" method is called, the value it receives is always null!
However, in my main entity, where I also have a filled called "totalRunningTime" which also uses the same custom field type and transformer, the transform and reverseTransform always work perfectly.
This seems to be an issue purely within the Collection/embedded form.
Does anyone have an ideas?
Here are some code snippets.


This is my custom data transformer:
class TimeDurationTransformer implements DataTransformerInterface
{
private ?string $invalidMessage = null;

public function __construct( ?string $invalidMessage = null )
{
$this->invalidMessage = $invalidMessage;
}

/**
* Transform an integer (number of seconds) into a string of the form HH:mm:ss.
*
* @param mixed $value
* @return mixed
*/
public function transform( mixed $value ) : mixed
{
if ( ( null === $value ) || ( intval( $value ) == 0 ) ):
return null;
endif;

return sprintf( '%02d:%02d:%02d', ( $value/ 3600 ), ( $value / 60 % 60 ), ( $value% 60 ) );
}

/**
* Transform a string of the form HH:mm:ss into a number of seconds as an integer.
*
* @param mixed $value
* @return mixed
*/
public function reverseTransform( mixed $value ) : mixed
{
if ( ( null === $value ) || empty( $value ) || ( strlen( $value ) < 1 ) ) :
return null;
endif;

$matchResult = preg_match( pattern: '/^((\d{1,3}):)?(\d{1,2}):(\d{1,2})$/', subject: $value, matches: $matches, flags: PREG_UNMATCHED_AS_NULL );
// If the string entered does not match the pattern, throw an exception
if ( ( false === $matchResult) || ( 0 === $matchResult ) ) :
throw new TransformationFailedException( message: $this->invalidMessage, invalidMessage: $this->invalidMessage );
else:
if ( $matchResult === 1 && ( count( $matches ) == 5 ) ) :
if ( round( $matches[4] ) != null ):
return( round( $matches[4] ) + ( $matches[3] ? ( $matches[3] * 60 ) : 0 ) + ( $matches[3] ? ( $matches[2] * 3600 ) : 0 ) );
endif;
endif;
throw new TransformationFailedException( message: $this->invalidMessage, invalidMessage: $this->invalidMessage );
endif;
}
}



This is my custom field type:
class TimeDurationType extends AbstractType
{
private $translator;

public function __construct( TranslatorInterface $translator ) {
$this->translator = $translator;
}

public function buildForm( FormBuilderInterface $builder, array $options ) : void
{
$builder->addModelTransformer( new StuggiBearTimeDurationTransformer( invalidMessage: $options[ 'invalid_message' ] ) );
}

public function configureOptions( OptionsResolver $resolver ): void
{
$resolver->setDefaults( [
'data_class' => null,
'required' => false,
'constraints' => [
new PositiveOrZero(),
],
'invalid_message' => $this->translator->trans( 'message.assert.time_duration_format' ),
'attr' => [
'placeholer' => '',
],
] );
}

public function getParent(): string
{
return TextType::class;
}
}



Within my main form for my entity AVItem, I have one field that uses this custom field type - and it works fine:
public function buildForm( FormBuilderInterface $builder, array $options ): void
{
$this->editType = $options['edit_type'];
$this->isWishlistItem = $options[ 'isWishlistItem' ];

$builder
...
->add( 'totalRunningTime', TimeDurationType::class, [
'required' => false,
'label' => $this->translator->trans( 'form.field.label.total_running_time' ),
'label_html' => true,
'attr' => [
'placeholder' => 'HH:mm:ss',
],
'empty_data' => null,
] )
...



Within this form I then have the collection of Tracks:
$builder
...

->add( 'tracks', CollectionType::class, [
'label' => $this->translator->trans( 'form.field.label.tracks' ),
'label_html' => true,
'entry_type' => TrackEmbeddedFormType::class,
'entry_options' => [
'label' => false,
],
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'empty_data' => [],
] )
...



...and then the embedded form type for the tracks:
$builder
->add( 'seriesEpisodeNumber', null, [
'required' => false,
'label' => $this->translator->trans( 'form.field.label.atce_series_episode_number' ),
] )
->add( 'title', null, [
'required' => ( $this->editType == FormEditType::SEARCH ) ? false : true,
'label' => $this->translator->trans( 'form.field.label.atce_title' ),
'label_html' => true,
] )
->add( 'additionalArtistsActors', EntityType::class, [
'required' => false,
'label' => $this->translator->trans( 'form.field.label.atce_additional_artists_actors' ),
'mapped' => true,
'class' => PersonGroup::class,
'by_reference' => true,
'multiple' => true,
'expanded' => false,
'choices' => [],
] )
->add( 'comment', null, [
'required' => false,
'mapped' => true,
'label' => $this->translator->trans( 'form.field.label.atce_comment' ),
'label_html' => true,
] )
->add( 'trackChapterNumber', null, [
'required' => true,
'label' => $this->translator->trans( 'form.field.label.atce_number' ),
'label_html' => true,
] )
->add( 'duration', TimeDurationType::class, [
'required' => false,
'label' => $this->translator->trans( 'form.field.label.atce_duration' ),
'label_html' => true,
'attr' => [
'placeholder' => 'HH:mm:ss',
],
'empty_data' => null,
] );
...



So, as I mentioned, the field "totalRunningTime" works perfectly with the data transformer, converting between integer seconds and a HH:mm:ss string and back.
However, the "duration" field within my collection/embedded tracks form only works reading from the database (the "transform" function works), but when I go to submit the form, the "reverseTransform" function always receives null.


If I change this field to be one of the standard types such as TextType or the like, then the value from the field seems to get passed.


Any help would be greatly appreciated.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

I need help beefing up my A/B testing package

 Programing Coderfunda     April 05, 2024     No comments   

I developed a A/B testing package for laravel a while back ago and I'm bringing it back.
https://github.com/pivotalso/laravel-ab

Eventually I want to beef it up to back it with a SaaS, but I'd really like more laravel devs to test drive it so I can make sure large issues are handled.

I also plan on beefing it up into feature flagging/user flagging, but I want to make sure this package is useful before I dev it further.

There are examples on how to use it here

https://docs.pivotal.so/docs/ab/laravel/installation/

Please ignore images on the site, it's still all under development.
AND if you decide to try the reporting saas, ignore the payment stuff, I havent done payment and wont until I feel comfortable enough the project is worth something. submitted by /u/IAmRules
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Firebase realtime rules - not working on child

 Programing Coderfunda     April 05, 2024     No comments   

Building a Firebase Realtime database with auth - but I
can't even get this started - returns permission denied
{
"rules": {
"forms": {
"$formid": {
".read": "true",
".write": "true"
}
}
}
}



ultimately I'd like to apply a rule like such
{
"rules": {
"forms": {
"$formid": {
".read": "auth.uid == data.child('userId').val()",
".write": "auth.uid != 'null'"
}
}
}
}



Data is formatted
forms




* $formId (eg -Nan39eo)



* userId










Console logging when rules are changed at the root to true returns that my authid is the same as the formId.userId
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

04 April, 2024

consume COM library from C# to rust

 Programing Coderfunda     April 04, 2024     No comments   

Question




I want to rewrite my project from C# to rust.
But I stuck in Segmentation Fault situation.
I think I misunderstood something, or meet crate limitation, hope for some help.


Rust Code






* find interface UUID
regedit capture

* find CLSID
regedit capture

* other id (I'm not sure shall we need it)
regedit capture



use windows::core::{GUID, HRESULT, IUnknown, IUnknown_Vtbl, interface};
use windows::Win32::System::Com::{
COINIT_APARTMENTTHREADED,
CLSCTX_ALL,
CoInitializeEx,
CoCreateInstance};

// define interface
#[interface("288EFDEC-3CF0-4F6C-8473-4E4CD47A93C7")]
unsafe trait Inhicshisx: IUnknown {
fn VPNGetRandomX(&self) -> HRESULT;
}

fn run() -> Result {
unsafe {
// 2F5AECD5-B5CD-41E1-8265-E2F6AA4548CB
const CLSID: GUID = GUID {
data1: 0x2F5AECD5,
data2: 0xB5CD,
data3: 0x41E1,
data4: [0x82, 0x65, 0xE2, 0xF6, 0xAA, 0x45, 0x48, 0xCB],
};

// initialize runtime
CoInitializeEx(Some(ptr::null_mut() as *mut c_void), COINIT_APARTMENTTHREADED)?;

// create COM object
let hisx: Inhicshisx = CoCreateInstance(&CLSID, None, CLSCTX_ALL)?;

// call object function
let value = hisx.VPNGetRandomX();
}

Ok(())
}



C# Part






* add a reference
regedit capture
* call function




using CSHISXLib;
string MyStr0;
CSHISXLib.Inhicshisx CSHISXLibObj = new CSHISXLib.nhicshisx();
MyStr0 = CSHISXLibObj.VPNGetRandomX();
Console.WriteLine(MyStr0);




* It works.






Update information




According to @IInspectable help, I can generate interface by oleview.exe tool.



* generated interface




[
odl,
uuid(288EFDEC-3CF0-4F6C-8473-4E4CD47A93C7),
helpstring("Inhicshisx Interface"),
dual,
oleautomation
]
interface Inhicshisx : IDispatch {
[id(0x00000001), helpstring("method VPNGetRandomX")]
HRESULT VPNGetRandomX([out, retval] BSTR* strRandom);
[id(0x00000002), helpstring("method VPNH_SignX")]
HRESULT VPNH_SignX(
[in] BSTR strRandom,
[in, optional, defaultvalue("")] BSTR strCardType,
[in, optional, defaultvalue("")] BSTR strServiceType,
[out, retval] BSTR* strRet);
}




* Rust code change




use windows::core::BSTR;

#[interface("288EFDEC-3CF0-4F6C-8473-4E4CD47A93C7")]
unsafe trait Inhicshisx: IDispatch {
fn VPNGetRandomX(&self) -> BSTR;
fn VPNH_SignX(&self, *mut BSTR, *mut BSTR, *mut BSTR) -> BSTR;
}



But it still cause Segmentation Fault, hope some advice 🙏
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Check if value exists in enum in TypeScript

 Programing Coderfunda     April 04, 2024     No comments   

I receive a number type = 3 and have to check if it exists in this enum:
export const MESSAGE_TYPE = {
INFO: 1,
SUCCESS: 2,
WARNING: 3,
ERROR: 4,
};



The best way I found is by getting all Enum Values as an array and using indexOf on it. But the resulting code isn't very legible:
if( -1 < _.values( MESSAGE_TYPE ).indexOf( _.toInteger( type ) ) ) {
// do stuff ...
}



Is there a simpler way of doing this?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Why can I not see any of my points when adding them to my scene?

 Programing Coderfunda     April 04, 2024     No comments   

I have created a program for java fx to enter points in for an array. The points are to be shown with a line drawn between the maximal points. Also if you left mouse click it adds a point and recalculates the maximal points. If you right click it removes the point from the display. The problem I am running into is I am reading in a file with the points but nothing is showing in my display. I have even tried to manually add points and still nothing shows in the display. What am I missing?


I have tried everything I can to understand why no points are showing and am at a loss. I know it is something simple, but I cannot figure it out.
The points that should be added from the text file are

This is what it should look like when initially ran

This is what it actually looks like

I have corrected the mouse event so if I click in the upper left it will add points



Point.java
package application;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public final class Point implements Comparable {
private final double x;
private final double y;

public Point(double x, double y) {
this.x = x;
this.y = y;
}

public double getX() {
return x;
}

public double getY() {
return y;
}

public boolean isBelowAndLeftOf(Point other) {
return this.x
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel Gems - Response Macros 💎

 Programing Coderfunda     April 04, 2024     No comments   

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

Running Laravel queue workers for smaller projects

 Programing Coderfunda     April 04, 2024     No comments   

Did you know that you can run your Laravel queue workers by using a cron schedule? This is a great way to use the amazing queue features that Laravel provides, without the configuration.


https://christalks.dev/post/running-laravels-queue-worker-using-a-cron-schedule-696b2e2e

Please do leave any comments, criticisms and constructive feedback! submitted by /u/chrispage1
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

03 April, 2024

Get absolute x,y of a child from the relative x,y of the parent

 Programing Coderfunda     April 03, 2024     No comments   

Note the following structure:


HTML:










CSS:
body {
padding: 100px;
background: aqua;
}

.container {
position: relative;
padding: 0 !important;
touch-action: none;
-webkit-user-select: none;
user-select: none;
width: 400px;
height: 400px;
border: 2px solid black;
}

.wrapper {
position: relative;
z-index: 1;
width: 100%;
height: 100%;
padding: 0 !important;
overflow: hidden;
background-color: black;
}

.image {
position: relative;
max-width: none !important;
max-height: none !important;
pointer-events: none;
width: 100%;
height: 100%;
transform: translate(var(--translate-x, 0px), var(--translate-y, 0px)) scale(var(--scale, 0));
--scale: 2;
--translate-x: 170px;
--translate-y: -100px;
}

img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
background: red;
}



If you prefer, here is the JSFiddle link.


When I click on the parent (.wrapper element) I will get an x,y. Let's suppose I click on the top right corner (in the example it would be close to the dog's eye). The value I should get relative to this element is something close to (x: 300, y: 0).


However, if we consider the real image (which has dimensions 1000x500) we know that this click region (the dog's left eye) corresponds to x:505 and y:205 (approximately).


What I want is precisely that. From the 5 variables:



* X of the click (relative to parent)

* Y of the click (relative to parent);

* CSS attribute --scale;

* CSS attribute --translate-x;

* CSS attribute --translate-y;






Get the absolute x, y of the image (considering its real size).


Comments:




The image can be moved within the container. For this I am using the Zoomist plugin. It was the only plugin I found that did this behavior of being able to zoom and move the image within a container of a pre-fixed size.


If there is another solution (another plugin for example) that would be better for my purpose, it would be welcome. Basically it all comes down to being able to zoom and move an image within a region and when clicking on a region (that is part of the image) I get its real x,y.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry

 Programing Coderfunda     April 03, 2024     No comments   

I'm migrating a modular app into a microservices app using spring cloud, when I finished migrating a module into microservice and ran it, a problem came up saying :



Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry



This is the error :

An attempt was made to call a method that does not exist. The attempt was made from the following location:

org.springframework.data.rest.core.support.UnwrappingRepositoryInvokerFactory.(UnwrappingRepositoryInvokerFactory.java:57)

The following method did not exist:

org.springframework.plugin.core.PluginRegistry.of(Ljava/util/List;)Lorg/springframework/plugin/core/PluginRegistry;

The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

jar:file:/~/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

It was loaded from the following location:

file:/~/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry



This is my pom.xml :


4.0.0

org.springframework.boot
spring-boot-starter-parent
2.3.0.RELEASE


org.sid
SF-postpros
0.0.1-SNAPSHOT
SF-postpros
Demo project for Spring Boot


1.8
Hoxton.SR4




org.springframework.boot
spring-boot-starter-actuator


org.springframework.boot
spring-boot-starter-logging




com.h2database
h2
runtime


org.springframework.boot
spring-boot-starter-data-jpa


javax.validation
validation-api
2.0.1.Final


com.querydsl
querydsl-apt


com.querydsl
querydsl-jpa


com.querydsl
querydsl-core


org.springframework.plugin
spring-plugin-core
1.2.0.RELEASE


org.springframework.boot
spring-boot-starter-security


org.springframework.cloud
spring-cloud-starter-netflix-eureka-client


org.springframework.cloud
spring-cloud-starter-netflix-zuul



org.springframework.boot
spring-boot-starter-test
test


org.junit.vintage
junit-vintage-engine




org.springframework.security
spring-security-test
test



org.junit.jupiter
junit-jupiter-engine
test


org.junit.platform
junit-platform-launcher
test



com.google.code.gson
gson


com.fasterxml.jackson.datatype
jackson-datatype-jsr310


com.fasterxml.jackson.core
jackson-databind


com.fasterxml.jackson.core
jackson-core


com.fasterxml.jackson.core
jackson-annotations



io.springfox
springfox-swagger-ui
2.9.2


io.springfox
springfox-swagger2
2.9.2


org.apache.commons
commons-lang3


org.springframework.boot
spring-boot-starter-log4j2


org.springframework.boot
spring-boot-starter-aop


org.springframework.boot
spring-boot-starter-logging




org.springframework.boot
spring-boot-starter-data-rest


mysql
mysql-connector-java


org.springframework.boot
spring-boot-starter-data-redis


org.springframework.boot
spring-boot-starter-logging




org.springframework.boot
spring-boot-starter-thymeleaf


org.springframework.boot
spring-boot-starter-batch


commons-io
commons-io
2.6


org.springframework.boot
spring-boot-starter-websocket


org.webjars
sockjs-client
1.0.2


org.webjars
stomp-websocket
2.3.3


org.webjars
bootstrap
4.1.3


org.webjars
jquery
3.3.1-1


redis.clients
jedis
jar


org.springframework.boot
spring-boot-starter-web


org.springframework.boot
spring-boot-starter-logging




org.springframework.boot
spring-boot-starter-mail


nz.net.ultraq.thymeleaf
thymeleaf-layout-dialect


org.projectlombok
lombok
1.18.4
provided


org.xhtmlrenderer
flying-saucer-pdf
9.1.4


org.apache.pdfbox
pdfbox
2.0.11


org.apache.pdfbox
pdfbox-tools
2.0.11


com.github.jai-imageio
jai-imageio-jpeg2000
1.3.0


net.sf.dozer
dozer
5.5.1


com.google.guava
guava
25.1-jre


org.springframework.cloud
spring-cloud-starter-openfeign


org.springframework.boot
spring-boot-starter-logging








org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import







org.springframework.boot
spring-boot-maven-plugin


com.mysema.maven
apt-maven-plugin
1.1.3



process


target/generated-sources
com.querydsl.apt.jpa.JPAAnnotationProcessor





org.apache.maven.plugins
2.19.1
maven-surefire-plugin


**/*.class




org.junit.platform
junit-platform-surefire-provider
1.0.2










this is my SwaggerConfig.java :
package org.sid.SFpostpros.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.Collections;

// TODO: Auto-generated Javadoc

/**
* The Class SwaggerConf.
*/
@Configuration
@EnableSwagger2
public class SwaggerConf implements WebMvcConfigurer {

/**
* Api.
*
* @return the docket
*/
@Bean
public Docket api() {

return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build().apiInfo(this.custInfo());
}

/**
* Cust info.
*
* @return the api info
*/
public ApiInfo custInfo() {

return new ApiInfo("Test", // Title
"Spring Boot Services", // Description
"1.0", // Version
"TOS", // Terms of Service
new Contact("Test", "Test.com", "test@test.com"), // Contact
"Test license", // License
"License", Collections.emptyList());
}

/**
* Adds the resource handlers.
*
* @param registry the registry
*/
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {

registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");

registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}



Can someone help me because i tried so many things and nothing worked.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

i am providing src to Image tag by array of object but it is showing blank page rather showing images . have i done anything wrong here?

 Programing Coderfunda     April 03, 2024     No comments   

import React from 'react'
import Image from 'next/image'
import "./work.scss"

function Work() {
const workObject = [
{
path: "/work/1.webp",
desc:"Maccabi Tzair"
},
{
path: "/work/2.webp",
desc:"Maccabi Tzair"
},
{
path: "/work/3.webp",
desc:"Maccabi Tzair"
},
{
path: "/work/4.webp",
desc:"Maccabi Tzair"
},
{
path: "/work/6.webp",
desc:"Maccabi Tzair"
},
{
path: "/work/7.webp",
desc:"Maccabi Tzair"
},
{
path: "/work/1.webp",
desc:"Maccabi Tzair"
},
]
return (

{workObject.map((obj) => {

})}

)
}

export default Work



i am providing src to Image tag by array of object but it is showing blank page rather showing images . have i done anything wrong here?please help i am trying it from an hour now
i am using next'js to build a image container it'll show on button clicked
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Step-by-step guide to linking gnuplot to Octave within Virtual Studio Code (VSC)

 Programing Coderfunda     April 03, 2024     No comments   

I am aware of a number of previous questions (here, here and here for example) pointing out to the need to modify a file named .octaverc.


Now, there are different files with that name (here). In Windows 11 and Octave 8.3.0 keeps two files in here:





I tried opening them with Notepad, and inserting the phrase graphics_toolkit("gnuplot") at the end, but I haven't been able to later save the file in any form due to lack of admin privileges even in my own laptop at home and logging in as admin (going to cmd line and setting up an admin profile just for this with net user administrator /active:yes).


Unfortunately, the extensions for Octave in VSC do not have too many preference options to link to gnuplot.


I am not sure how to set up a new .octaverc file in the working directory. Would it be for each folder? Would it be a text file? Would I find the wd from inside VSC? Would it also have to have the . of hidden file in the name? Would it bear an extension, such as .txt?


So I am lost and wasting a ton of time on an issue that is probably easy to solve with some more detailed steps.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Best Authentication Practice for Next.js (app router) with Laravel API

 Programing Coderfunda     April 03, 2024     No comments   

Hey everyone! I recently switched my frontend to Next.js (using the app router) while keeping Laravel for the API. What's the best way to handle user authentication now? I know Laravel recommends Sanctum with cookie-based sessions, but since Next's app router isn't a SPA, what are you all using? Cookies with Sanctum, tokens, or something else? Thanks for the insights! submitted by /u/Derperderpington
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

02 April, 2024

Add extensions to Laravel Herd without Homebrew

 Programing Coderfunda     April 02, 2024     No comments   

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

Using Timeframe parameters Pinescript indicator

 Programing Coderfunda     April 02, 2024     No comments   

I'm trying to create an indicator that uses the "Auto Fibo Retracement" technical indicator, but I want the timeframe on which the indicator is based not to be the one on the chart, but one to be selected in the indicator parameters.
I don't know what is the exact function to use and where into to code ?


Here is the code that I use :
//@version=5
indicator("Test Auto Fib Retracement", overlay=true)

devTooltip = "Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot."
depthTooltip = "The minimum number of bars that will be taken into account when calculating the indicator."
// pivots threshold
threshold_multiplier = input.float(title="Deviation", defval=3, minval=0, tooltip=devTooltip)
depth = input.int(title="Depth", defval=10, minval=2, tooltip=depthTooltip)
reverse = input(false, "Reverse", display = display.data_window)
var extendLeft = input(false, "Extend Left    |    Extend Right", inline = "Extend Lines")
var extendRight = input(true, "", inline = "Extend Lines")
var extending = extend.none
if extendLeft and extendRight
extending := extend.both
if extendLeft and not extendRight
extending := extend.left
if not extendLeft and extendRight
extending := extend.right
prices = input(false, "Show Prices", display = display.none)
levels = input(false, "Show Levels", inline = "Levels", display = display.none)
levelsFormat = input.string("Values", "", options = ["Values", "Percent"], inline = "Levels", display = display.none)
labelsPosition = input.string("Left", "Labels Position", options = ["Left", "Right"], display = display.none)
var int backgroundTransparency = input.int(85, "Background Transparency", minval = 0, maxval = 100, display = display.none)

import TradingView/ZigZag/7 as zigzag

update()=>
var settings = zigzag.Settings.new(threshold_multiplier, depth, color(na), false, false, false, false, "Absolute", true)
var zigzag.ZigZag zigZag = zigzag.newInstance(settings)
var zigzag.Pivot lastP = na
var float startPrice = na
var float height = na
settings.devThreshold := ta.atr(10) / close * 100 * threshold_multiplier
if zigZag.update()
lastP := zigZag.lastPivot()
if not na(lastP)
var line lineLast = na
if na(lineLast)
lineLast := line.new(lastP.start, lastP.end, xloc=xloc.bar_time, color=color.gray, width=1, style=line.style_dashed)
else
line.set_first_point(lineLast, lastP.start)
line.set_second_point(lineLast, lastP.end)

startPrice := reverse ? lastP.start.price : lastP.end.price
endPrice = reverse ? lastP.end.price : lastP.start.price
height := (startPrice > endPrice ? -1 : 1) * math.abs(startPrice - endPrice)
[lastP, startPrice, height]

[lastP, startPrice, height] = update()

_draw_line(price, col) =>
var id = line.new(lastP.start.time, lastP.start.price, time, price, xloc=xloc.bar_time, color=col, width=1, extend=extending)
line.set_xy1(id, lastP.start.time, price)
line.set_xy2(id, lastP.end.time, price)
id

_draw_label(price, txt, txtColor) =>
x = labelsPosition == "Left" ? lastP.start.time : not extendRight ? lastP.end.time : time
labelStyle = labelsPosition == "Left" ? label.style_label_right : label.style_label_left
align = labelsPosition == "Left" ? text.align_right : text.align_left
labelsAlignStrLeft = txt + '\n ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ \n'
labelsAlignStrRight = ' ' + txt + '\n ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏ \n'
labelsAlignStr = labelsPosition == "Left" ? labelsAlignStrLeft : labelsAlignStrRight
var id = label.new(x=x, y=price, xloc=xloc.bar_time, text=labelsAlignStr, textcolor=txtColor, style=labelStyle, textalign=align, color=#00000000)
label.set_xy(id, x, price)
label.set_text(id, labelsAlignStr)
label.set_textcolor(id, txtColor)

_wrap(txt) =>
"(" + str.tostring(txt, format.mintick) + ")"

_label_txt(level, price) =>
l = levelsFormat == "Values" ? str.tostring(level) : str.tostring(level * 100) + "%"
(levels ? l : "") + (prices ? _wrap(price) : "")

_crossing_level(series float sr, series float r) =>
(r > sr and r < sr[1]) or (r < sr and r > sr[1])

processLevel(bool show, float value, color colorL, line lineIdOther) =>
float m = value
r = startPrice + height * m
crossed = _crossing_level(close, r)
if show and not na(lastP)
lineId = _draw_line(r, colorL)
_draw_label(r, _label_txt(m, r), colorL)
if crossed
alert("Autofib: " + syminfo.ticker + " crossing level " + str.tostring(value))
if not na(lineIdOther)
linefill.new(lineId, lineIdOther, color = color.new(colorL, backgroundTransparency))
lineId
else
lineIdOther

show_0 = input(true, "", inline = "Level0", display = display.data_window)
value_0 = input(0, "", inline = "Level0", display = display.data_window)
color_0 = input(#2862ff, "", inline = "Level0", display = display.data_window)

show_0_236 = input(false, "", inline = "Level0", display = display.data_window)
value_0_236 = input(0.236, "", inline = "Level0", display = display.data_window)
color_0_236 = input(#f44336, "", inline = "Level0", display = display.data_window)

show_0_382 = input(false, "", inline = "Level1", display = display.data_window)
value_0_382 = input(0.382, "", inline = "Level1", display = display.data_window)
color_0_382 = input(#81c784, "", inline = "Level1", display = display.data_window)

show_0_5 = input(true, "", inline = "Level1", display = display.data_window)
value_0_5 = input(0.5, "", inline = "Level1", display = display.data_window)
color_0_5 = input(#2862ff, "", inline = "Level1", display = display.data_window)

show_0_618 = input(true, "", inline = "Level2", display = display.data_window)
value_0_618 = input(0.618, "", inline = "Level2", display = display.data_window)
color_0_618 = input(#9698a1, "", inline = "Level2", display = display.data_window)

show_0_65 = input(false, "", inline = "Level2", display = display.data_window)
value_0_65 = input(0.65, "", inline = "Level2", display = display.data_window)
color_0_65 = input(#009688, "", inline = "Level2", display = display.data_window)

show_0_786 = input(true, "", inline = "Level3", display = display.data_window)
value_0_786 = input(0.786, "", inline = "Level3", display = display.data_window)
color_0_786 = input(#ff9800, "", inline = "Level3", display = display.data_window)

show_1 = input(true, "", inline = "Level3", display = display.data_window)
value_1 = input(1, "", inline = "Level3", display = display.data_window)
color_1 = input(#f23645, "", inline = "Level3", display = display.data_window)

show_1_272 = input(false, "", inline = "Level4", display = display.data_window)
value_1_272 = input(1.272, "", inline = "Level4", display = display.data_window)
color_1_272 = input(#81c784, "", inline = "Level4", display = display.data_window)

show_1_414 = input(false, "", inline = "Level4", display = display.data_window)
value_1_414 = input(1.414, "", inline = "Level4", display = display.data_window)
color_1_414 = input(#f44336, "", inline = "Level4", display = display.data_window)

show_1_618 = input(false, "", inline = "Level5", display = display.data_window)
value_1_618 = input(1.618, "", inline = "Level5", display = display.data_window)
color_1_618 = input(#2962ff, "", inline = "Level5", display = display.data_window)

show_1_65 = input(false, "", inline = "Level5", display = display.data_window)
value_1_65 = input(1.65, "", inline = "Level5", display = display.data_window)
color_1_65 = input(#2962ff, "", inline = "Level5", display = display.data_window)

show_2_618 = input(false, "", inline = "Level6", display = display.data_window)
value_2_618 = input(2.618, "", inline = "Level6", display = display.data_window)
color_2_618 = input(#f44336, "", inline = "Level6", display = display.data_window)

show_2_65 = input(false, "", inline = "Level6", display = display.data_window)
value_2_65 = input(2.65, "", inline = "Level6", display = display.data_window)
color_2_65 = input(#f44336, "", inline = "Level6", display = display.data_window)

show_3_618 = input(false, "", inline = "Level7", display = display.data_window)
value_3_618 = input(3.618, "", inline = "Level7", display = display.data_window)
color_3_618 = input(#9c27b0, "", inline = "Level7", display = display.data_window)

show_3_65 = input(false, "", inline = "Level7", display = display.data_window)
value_3_65 = input(3.65, "", inline = "Level7", display = display.data_window)
color_3_65 = input(#9c27b0, "", inline = "Level7", display = display.data_window)

show_4_236 = input(false, "", inline = "Level8", display = display.data_window)
value_4_236 = input(4.236, "", inline = "Level8", display = display.data_window)
color_4_236 = input(#e91e63, "", inline = "Level8", display = display.data_window)

show_4_618 = input(false, "", inline = "Level8", display = display.data_window)
value_4_618 = input(4.618, "", inline = "Level8", display = display.data_window)
color_4_618 = input(#81c784, "", inline = "Level8", display = display.data_window)

show_neg_0_236 = input(false, "", inline = "Level9", display = display.data_window)
value_neg_0_236 = input(-0.236, "", inline = "Level9", display = display.data_window)
color_neg_0_236 = input(#f44336, "", inline = "Level9", display = display.data_window)

show_neg_0_382 = input(false, "", inline = "Level9", display = display.data_window)
value_neg_0_382 = input(-0.382, "", inline = "Level9", display = display.data_window)
color_neg_0_382 = input(#81c784, "", inline = "Level9", display = display.data_window)

show_neg_0_618 = input(false, "", inline = "Level10", display = display.data_window)
value_neg_0_618 = input(-0.618, "", inline = "Level10", display = display.data_window)
color_neg_0_618 = input(#009688, "", inline = "Level10", display = display.data_window)

show_neg_0_65 = input(false, "", inline = "Level10", display = display.data_window)
value_neg_0_65 = input(-0.65, "", inline = "Level10", display = display.data_window)
color_neg_0_65 = input(#009688, "", inline = "Level10", display = display.data_window)

lineId0 = processLevel(show_neg_0_65, value_neg_0_65, color_neg_0_65, line(na))
lineId1 = processLevel(show_neg_0_618, value_neg_0_618, color_neg_0_618, lineId0)
lineId2 = processLevel(show_neg_0_382, value_neg_0_382, color_neg_0_382, lineId1)
lineId3 = processLevel(show_neg_0_236, value_neg_0_236, color_neg_0_236, lineId2)
lineId4 = processLevel(show_0, value_0, color_0, lineId3)
lineId5 = processLevel(show_0_236, value_0_236, color_0_236, lineId4)
lineId6 = processLevel(show_0_382, value_0_382, color_0_382, lineId5)
lineId7 = processLevel(show_0_5, value_0_5, color_0_5, lineId6)
lineId8 = processLevel(show_0_618, value_0_618, color_0_618, lineId7)
lineId9 = processLevel(show_0_65, value_0_65, color_0_65, lineId8)
lineId10 = processLevel(show_0_786, value_0_786, color_0_786, lineId9)
lineId11 = processLevel(show_1, value_1, color_1, lineId10)
lineId12 = processLevel(show_1_272, value_1_272, color_1_272, lineId11)
lineId13 = processLevel(show_1_414, value_1_414, color_1_414, lineId12)
lineId14 = processLevel(show_1_618, value_1_618, color_1_618, lineId13)
lineId15 = processLevel(show_1_65, value_1_65, color_1_65, lineId14)
lineId16 = processLevel(show_2_618, value_2_618, color_2_618, lineId15)
lineId17 = processLevel(show_2_65, value_2_65, color_2_65, lineId16)
lineId18 = processLevel(show_3_618, value_3_618, color_3_618, lineId17)
lineId19 = processLevel(show_3_65, value_3_65, color_3_65, lineId18)
lineId20 = processLevel(show_4_236, value_4_236, color_4_236, lineId19)
lineId21 = processLevel(show_4_618, value_4_618, color_4_618, lineId20)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

I made this code, but I am not understanding how JavaScript is handling the swapping??? (I have seen this before in an article but didnt explain)

 Programing Coderfunda     April 02, 2024     No comments   

What is the name or official term of what I want to understand below in JavaScript??


I have never been able to find a clear article explanation of what arrays do behind the scenes when swapping numbers (I think this is a short way of replacing values, if im not wrong).




const swapNumbers = (numbers: number[]) => {
const swap = numbers.map((x: number, index: number) =>
index % 2 !== 0 ? numbers[index - 1] : index === numbers.length - 1 && numbers.length % 2 !== 0 ? numbers[index] : numbers[index + 1]);

console.log(swap);
};

swapNumbers([1, 2, 3, 4]);
swapNumbers([1, 2, 5, 6, 8]);





I want to understand what this is exactly doing (I want to understand the long way)... is this numbers[index + 1] (short way, which is placing the next number in line) the same as this (long way) numbers[index + 1] = numbers[index] or numbers[index + 1] = x?


What is the condition to be able to do this? (is it only in maps and other es6 functions? or can I use this in a regular for loop e.g. numbers[index - 1];?)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

After upgrade to V11 from V10, all routes disappeared and no images are shown

 Programing Coderfunda     April 02, 2024     No comments   

Hi,

as i wrote in the title, after upgraded to V11, all my routes disappeared and no images are shown.
It seems like the framework cannot get the right path...

I am testing it on wamp, another project didn't have this issue.
I have installed (and use) spatie permission plugin, but even if i disable it, nothing changes.

Anybody had this problem? submitted by /u/djsnake81
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Different types of Integer division in Python

 Programing Coderfunda     April 02, 2024     No comments   

In terms of the resulting value (ignoring the resulting data type), are the following the same in Python if x and y are both numbers?
int(x / y)

x // y



If so, which is better to use in real application? And why?


P.S. Are there any other methods in Python that achieve similar result but more suitable in different use cases? For example, if y is 2^n, then we can do bitwise shifting - that's all I know.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

01 April, 2024

possible to delete a mongodb catch block

 Programing Coderfunda     April 01, 2024     No comments   

I have updated my mongodb driver which forces me to use two completion blocks: .then() .catch() instead of a single callback. The consequence of this is that any error in my stack down the line will jump back up to the mongodb .catch() and potentially cascade processes all over again. Any 'done' block should only be called once. Code that was once easily traceable and was called only once has lost it's simplicity and coherence when migrating from a single callback to two blocks: then() and catch().
DB.insertOne(something).then( (r) =>
{
done({success:true});
}).catch( (e) =>
{
done({success:false, message:e.code});
});



My question - is it possible to delete the catch block, once the insert command has successfully completed? I want to do this because I do not want the mongodb .catch() block executing when irrelevant and unrelated events crash occur down the line. I am looking for something like this.
DB.insertOne(something).then( (r) =>
{
delete this.catch;//does not work
done({success:true});
}).catch( (e) =>
{
done({success:false, message:e.code});
});



note also that I do need the catch block in general. I need the catch block to execute once - for example if the insert command were to return an error for attempting to insert the same document with the same ._id (for example).
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Predicting on new data using locally weighted regression (LOESS/LOWESS)

 Programing Coderfunda     April 01, 2024     No comments   

How to fit a locally weighted regression in python so that it can be used to predict on new data?



There is statsmodels.nonparametric.smoothers_lowess.lowess, but it returns the estimates only for the original data set; so it seems to only do fit and predict together, rather than separately as I expected.



scikit-learn always has a fit method that allows the object to be used later on new data with predict; but it doesn't implement lowess.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Audit services?

 Programing Coderfunda     April 01, 2024     No comments   

I’ve built a medium sized Laravel app and was wondering if there are any companies/people I can hire to audit my code and give feedback and help me to improve my code architecture. Thanks. submitted by /u/jamlog
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

A little April Fools' fun from a shifty Shift

 Programing Coderfunda     April 01, 2024     No comments   

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

Creating Your Own PHP Helpers in a Laravel Project

 Programing Coderfunda     April 01, 2024     No comments   

---



Laravel provides many excellent helper functions that are convenient for doing things like working with arrays, file paths, strings, and routes, among other things like the beloved dd() function.


You can also define your own set of helper functions for your Laravel applications and PHP packages, by using Composer to import them automatically.


If you are new to Laravel or PHP, let’s walk through how you might go about creating your own helper functions that automatically get loaded by Laravel.


Creating a Helpers file in a Laravel App




The first scenario you might want to include your helper functions is within the context of a Laravel application. Depending on your preference, you can organize the location of your helper file(s) however you want, however, here are a few suggested locations:




*
app/helpers.php


*
app/Http/helpers.php






I prefer to keep mine in app/helpers.php in the root of the application namespace.


Autoloading




To use your PHP helper functions, you need to load them into your program at runtime. In the early days of my career, it wasn’t uncommon to see this kind of code at the top of a file:
require_once ROOT . '/helpers.php';




PHP functions cannot be autoloaded. However, we have a much better solution through Composer than using require or require_once.


If you create a new Laravel project, you will see an autoload and autoload-dev keys in the composer.json file:
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},




If you want to add a helpers file, composer has a files key (which is an array of file paths) that you can define inside of autoload:
"autoload": {
"files": [
"app/helpers.php"
],
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},




Once you add a new path to the files array, you need to dump the autoloader:
composer dump-autoload



Now on every request the helpers.php file will be loaded automatically because Laravel requires Composer’s autoloader in public/index.php:
require __DIR__.'/../vendor/autoload.php';



Defining Functions




Defining functions in your helpers class is the easy part, although, there are a few caveats. All of the Laravel helper files are wrapped in a check to avoid function definition collisions:
if (! function_exists('env')) {
function env($key, $default = null) {
// ...
}
}




This can get tricky, because you can run into situations where you are using a function definition that you did not expect based on which one was defined first.


I prefer to use function_exists checks in my application helpers, but if you are defining helpers within the context of your application, you could forgo the function_exists check.


By skipping the check, you’d see collisions any time your helpers are redefining functions, which could be useful.


In practice, collisions don’t tend to happen as often as you’d think, and you should make sure you’re defining function names that aren’t overly generic. You can also prefix your function names to make them less likely to collide with other dependencies.


Helper Example




I like the Rails path and URL helpers that you get for free when defining a resourceful route. For example, a photos resource route would expose route helpers like new_photo_path, edit_photo_path`, etc.


When I use resource routing in Laravel, I like to add a few helper functions that make defining routes in my templates easier. In my implementation, I like to have a URL helper function that I can pass an Eloquent model and get a resource route back using conventions that I define, such as:
create_route($model);
edit_route($model);
show_route($model);
destroy_route($model);



Here’s how you might define a show_route in your app/helpers.php file (the others would look similar):
if (! function_exists('show_route')) {
function show_route($model, $resource = null)
{
$resource = $resource ?? plural_from_model($model);

return route("{$resource}.show", $model);
}
}

if (! function_exists('plural_from_model')) {
function plural_from_model($model)
{
$plural = Str::plural(class_basename($model));

return Str::kebab($plural);
}
}




The plural_from_model() function is just some reusable code that the helper route functions use to predict the route resource name based on a naming convention that I prefer, which is a kebab-case plural of a model.


For example, here’s an example of the resource name derived from the model:
$model = new App\LineItem;
plural_from_model($model);
// => line-items

plural_from_model(new App\User);
// => users




Using this convention you’d define the resource route like so in routes/web.php:
Route::resource('line-items', 'LineItemsController');
Route::resource('users', 'UsersController');



And then in your blade templates, you could do the following:

{{ $lineItem->name }}




Which would produce something like the following HTML:

Line Item #1




Packages




Your Composer packages can also use a helpers file for any helper functions you want to make available to projects consuming your package.


You will take the same approach in the package’s composer.json file, defining a files key with an array of your helper files.


It’s imperative that you add function_exists() checks around your helper functions so that projects using your code don’t break due to naming collisions.


You should choose proper function names that are unique to your package, and consider using a short prefix if you are afraid your function name is too generic.


Learn More




Check out Composer’s autoloading documentation to learn more about including files, and general information about autoloading classes.



The post Creating Your Own PHP Helpers in a Laravel Project 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

31 March, 2024

There are two solutions for one board, using different chips. But one of their i2c address is the same. How to resolve conflict in one dts?

 Programing Coderfunda     March 31, 2024     No comments   

Two chips A and B conflict with 0x62 on i2c bus 10. If A@62 and B@62 are configured on dts, Linux loads the driver of A. If B@62 is in front, it will load the driver of B. Whoever is in front will Which driver will be loaded, and is there any way to make the two chips compatible in one DTS.


i2cdetect -r -y 10
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- UU -- UU -- UU -- UU --
60: UU -- UU -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --


i2cdetect -r -y 9
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- 0c -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- 37 -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- UU 62 UU -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- UU -- UU UU -- --


Hardware can't modify the address. If two dts are used, there will be two firmwares, which is inconvenient.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to properly integrate against 3rd party services

 Programing Coderfunda     March 31, 2024     No comments   

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

Weekly /r/Laravel Help Thread

 Programing Coderfunda     March 31, 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

Positioning agent randomly within GIS space

 Programing Coderfunda     March 31, 2024     No comments   

I am looking to randomly position a fixed number of 'People' agents into my GIS space with regions. I currently have a table with a column for region and have identically named GIS regions in my GIS map.
Each 'Person' has a parameter 'region' which into which I map the value of the 'region' column in my table to. I then need to find some way to set the position of the agent to a random point inside the assigned region.


I have tried:
GISRegion myRegion = main.map.searchFirstRegion(region);
Point pt = myRegion.randomPointInside();
setXYZ( pt.x, pt.y, pt.z );



in the "On startup" field for my Person Agent but it seems that main.map.searchFirstRegion(region); does not do a good job of getting the correct region, as agents are distributed in places where there is no region (i.e in the sea):
Image


Ideally, I would like to use void setLocation(region) but setLocation takes in a Point or INode variable whereas the 'region' parameter is a string. Is there a way to search the list of regions by name for the matching region and return that region?
Thanks!
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