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

07 November, 2023

Marklogic SVC-FILRD error even when file is present on the filesystem

 Programing Coderfunda     November 07, 2023     No comments   

I have restored a forest from a forest backup. I am trying to open a binary file but I get an error -
1.0-ml] SVC-FILRD: xdmp:subbinary(fn:doc("mc-2022-vol57/mc-2022-vol57.ch06/graphic/mc-2022-vol57.ch06_g05.tif")/binary(), 1, 8) -- File read error: open '/var/opt/MarkLogic/Forests/content-lake-raw-1/Large/3fe/ffa6dd5438c09a48': No such file or directory



even though I can clearly see this location in the s3 bucket from where I am doing the restore. Why are some files not getting restored?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Map two different entities to the same table?

 Programing Coderfunda     November 07, 2023     No comments   

I have a table in my database with a lot of fields. Most of the time I need all those fields. There is one scenario, however, where I only need a few of the fields, and I am loading a ton of rows.



What I'd like to do is add in an Entity manually, and then simply map it to the original table, but delete the columns I don't need. I set this all up, but I get the rather self-explanatory error of:




Problem in mapping fragments
...EntitySets 'FmvHistoryTrimmed' and
'FMVHistories' are both mapped to
table 'FMVHistory'. Their primary keys
may collide.




Is there some other way I should go about this? Again, most of the time all of the columns are used, so I don't want to trim down the original entity and put the "extra" fields into a complex type.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

The user is following himself

 Programing Coderfunda     November 07, 2023     No comments   

I wrote a function for following & unfollowing users and in the first line of code I made if statement to make it so the user can't follow himself but the user can follow himself even though that


the followUser code:
const followUnfollowUser = async(req, res) => {
try {
const { id } = req.params;
const userToModify = await User.findById(id);
const currentUser = await User.findById(req.user._id);

if(userToModify === currentUser) {
return res.status(400).json({ message: "You cannot follow/unfollow yourself!" });
}

if(!userToModify || !currentUser) return res.status(400).json({ message: "User not found!" });

const isFollowing = currentUser.following.includes(id);

if (isFollowing) {
// unfollow user
await User.findByIdAndUpdate(id, { $pull: { followers: req.user._id } });
await User.findByIdAndUpdate(req.user._id, { $pull: { following: id } });
res.status(200).json({ message: "User unfollowed successfully" });
} else {
// Follow User
await User.findByIdAndUpdate(id, { $push: { followers: req.user._id } });
await User.findByIdAndUpdate(req.user._id, { $push: { following: id } });
res.status(200).json({ message: "User followed successfully" });
}
} catch (err) {
res.status(500).json({ message: err.message });
console.log("Error in follow or unfollow User: ", err.message);
}
};



Note: I'm using post method in router file. Is this fine or I should use (patch or put) for that?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

OnCollisionEnter does not work correctly at high speeds?

 Programing Coderfunda     November 07, 2023     No comments   

public class BulletController : MonoBehaviour
{
public float speed;
[SerializeField] Rigidbody rb;
[SerializeField] GameObject impactEffect;

void Start()
{
rb = GetComponent();
Destroy(gameObject, 4f);
}

void Update()
{
rb.velocity = transform.forward * speed;
}

private void OnCollisionEnter(Collision collision)
{

ContactPoint contactPoint = collision.contacts[0];
Quaternion rotation = Quaternion.FromToRotation(Vector3.forward, contactPoint.normal);
Instantiate(impactEffect, transform.position, rotation);
Destroy(this.gameObject);

}

}



Youtube Link - Listen without sound. There is a crazy fan sound :)


I am trying to make a when bullet collides with something to be destroyed and instantiate a hitteffect but OnCollisionEnter or OnTriggerEnter does not work as intended at high speed objects I guess. Sometimes impactEffect instantiates inside colision object and even sometimes on the other side of object. (See Video). I have tried to write contactPoint[0].transform and it is also same. Does anybody have a solution ?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

06 November, 2023

ABP Problem with loading @abp/ng.identity module

 Programing Coderfunda     November 06, 2023     No comments   

I have a problem with loading the built-in modules, if I am on a certain route, for example Users, and reload the page, the error crashes


the provided screens show the errors that appear when you go to the users or roles page.


enter image description here
enter image description here


Here is part of my app-routing.module.ts routing file:
import { NgModule } from '@angular/core'
import { RouterModule, Routes } from '@angular/router'

const routes: Routes = [
{
path: '',
pathMatch: 'full',
loadChildren: () => import('./pages/home/home.module').then(m => m.HomeModule),
},
{
path: 'account',
loadChildren: () => import('@abp/ng.account').then(m => m.AccountModule.forLazy()),
},
{
path: 'identity',
loadChildren: () => import('@abp/ng.identity').then(m => m.IdentityModule.forLazy()),
},
{
path: 'tenant-management',
loadChildren: () => import('@abp/ng.tenant-management').then(m => m.TenantManagementModule.forLazy()),
},
{
path: 'setting-management',
loadChildren: () => import('@abp/ng.setting-management').then(m => m.SettingManagementModule),
},
{
path: 'page-content',
loadChildren: () => import('./pages/home/pages/page-content').then(m => m.PageContentModule),
},
{
path: 'theme',
loadChildren: () => import('./pages/home/pages/theme').then(m => m.ThemeModule),
},
{
path: 'languages',
loadChildren: () => import('./pages/home/pages/languages').then(m => m.LanguagesModule),
},
{
path: 'countries',
loadChildren: () => import('./pages/home/pages/countries').then(m => m.CountriesModule),
},
{
path: 'users',
loadChildren: () => import('./pages/home/pages/users').then(m => m.UsersModule),
},
{
path: 'roles',
loadChildren: () => import('./pages/home/pages/roles').then(m => m.RolesModule),
},
{
path: 'media',
loadChildren: () => import('./pages/home/pages/media').then(m => m.MediaModule),
},
{
path: 'menu-section',
loadChildren: () => import('./pages/home/pages/menu-section').then(m => m.MenuSectionModule),
},
{
path: 'categories',
loadChildren: () => import('./pages/home/pages/categories').then(m => m.CategoriesModule),
},
]

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
})
export class AppRoutingModule {}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Recreating bar chart with R and ggplot2

 Programing Coderfunda     November 06, 2023     No comments   

Heyy, can anyone help with recreating a graph in R using ggplot2?
library(ggplot)
library(tidyverse)
library(ggthemes)



We were thinking of creating two separate graphs and combining them using patchwork or cowplot and also ggthemes for the design. Would be great if anyone with some more experience could help us with how to approach this task. Any help is much appreciated!
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Apache Pulsar implementation in a distributed system

 Programing Coderfunda     November 06, 2023     No comments   

I'm new to Apache Pulsar technology and I want to implement the Apache Pulsar in distributed system. In which one machine should have Pulsar Producer which produces the messages to the topic and the other machine should have Pulsar Consumer to consume those messages from the same topic.


Is there any way to implement the same using C# language.


Kindly help me with the guideline to implement it!
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

SQL or NoSQL batabase for online strategy

 Programing Coderfunda     November 06, 2023     No comments   

There is game (like xcraft) where I need store information about players, sessions and etc. I thought that better use PostgreSQL and after I'm stumped with this question. What better use PostgreSQL for database or NoSql solution. In this game there will be battles where it’s just like auto-battle with only pressing abilities. You will also need to store a bunch of galaxies, planets, etc. It will be mobile game.


In different sources write absolute different solution but I didn't understand what use better for this case


The fact is that in my work I have always specialized The fact is that in my work I have always specialized in web backend but not for games.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Could not access file "$libdir/age": No such file or directory in Windows

 Programing Coderfunda     November 06, 2023     No comments   

I'm trying to make apache age windows installer in order to run age in windows without using WSL2.
To compile the source code on windows machine I'm using msys2 as it can be use to build native windows software.
The make install command is successful :
# make install
/usr/bin/mkdir -p 'C:/PROGRA~1/POSTGR~1/12/lib'
/usr/bin/mkdir -p 'C:/PROGRA~1/POSTGR~1/12/share/extension'
/usr/bin/mkdir -p 'C:/PROGRA~1/POSTGR~1/12/share/extension'
/usr/bin/install -c -m 755 age.so 'C:/PROGRA~1/POSTGR~1/12/lib/age.so'
/usr/bin/install -c -m 644 .//age.control 'C:/PROGRA~1/POSTGR~1/12/share/extension/'
/usr/bin/install -c -m 644 .//age--1.1.1.sql 'C:/PROGRA~1/POSTGR~1/12/share/extension/'




and age file is present there
# ls "C:\Program Files\PostgreSQL\12\lib" |grep age
age.so
pageinspect.dll



But I'm getting Could not access file "$libdir/age": No such file or directory in psql shell.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

05 November, 2023

Should the card board or just the card be statefull?

 Programing Coderfunda     November 05, 2023     No comments   

I have a board widget and a card widget.
The card model looks like this:
class Playcard {
Playcard({
required this.front,
required this.back,
required this.flipped,
});

final String front;
final String back;
bool flipped;
}



The board widget is showing the cards from the card widget.
The cards can be flipped. Initially all cards have flipped=false. When a card is flipped=true.
To show the card with the new value flipped=true should the board or the card be stateful?
I have created a card provider that sets the value of the card to true if it is flipped.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

NSwag openapi2cscontroller: handle controller return type for errors

 Programing Coderfunda     November 05, 2023     No comments   

Is there a way to tell NSwag to generate controllers using Task as method output instead of Task?


This is how my swagger looks like
paths:
'/Products/{id}':
get:
tags:
- Products
operationId: getProductById
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/ProductResponseDto'
'404':
description: Entity not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorDto'



The generated interface looks like
/// Success

System.Threading.Tasks.Task GetProductByIdAsync(string id);



and it does not allow to return the ErrorDto in case of error.
I know it is possible to throw an exception and add a middleware to handle it, but I want to find a solution that does not involve throwing exceptions.


This is how the target is defined in the csproj
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

create a directory name from a string in python

 Programing Coderfunda     November 05, 2023     No comments   

What's the most idiomatic, clean way to convert a descriptive string to a portable directory name?


Something like description.replace(" ", "_") but that also removes / replaces punctuations and other whitespaces, and maybe other edge cases I haven't thought about.


The mapping can be lossy (you don't need to be able to reproduce the original string), it just needs to be a reasonable approximation to the given description, and of course - if there's a standard implementation somewhere that's a big bonus


Thanks!


Example:
"I'm thinking Avocado toast" -> "im_thinking_avocado_toast"
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Disable audit object on oracle 11

 Programing Coderfunda     November 05, 2023     No comments   

How can I disable audit objects on Oracle 11? I have tried

NOAUDIT ALL;
NOAUDIT NETWORK;
NOAUDIT SESSION;
NOAUDIT ALL ON DEFAULT;
NOAUDIT SELECT INSERT UPDATE DELETE EXECUTE PROCEDURE;
NOAUDIT PRIVILEGES;




But audit still generate, grows fast and, of course, my db becomes full.



When I query sys.aud, audit objects like insert, delete, update are being logged to sys.aud.



If someone has solution to this problem, please help me.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to create a new Bitbucket pull request via API?

 Programing Coderfunda     November 05, 2023     No comments   

I'm trying to create a pull request on Bitbucket Server via Rest API, following this documentation. No matter what I try, I get a (400) Bad Request. error. I found this answer and used the body text from the answer (of course, replacing my information like the repo, branch, etc.):
{
"title": "My new PR",
"description": "This is my new PR.",
"state": "OPEN",
"open": true,
"closed": false,
"fromRef": {
"id": "refs/heads/this-is-my-branch",
"repository": {
"slug": "my-repo",
"name": 'My repo',
"project": {
"key": "KE"
}
}
},
"toRef": {
"id": "refs/heads/master",
"repository": {
"slug": "my-repo",
"name": 'My repo',
"project": {
"key": "KE"
}
}
},
"locked": false,
"reviewers": [
{
"user": {
"name": "jeremywat"
}
}
]
}



This is the request (I'm using PowerShell):
Invoke-RestMethod -Headers @{Authorization = "Basic $BasicAuth"} -Body $JsonBody -ContentType 'application/json' -Method POST -Uri
https://my-bitbucket-server.com/rest/api/1.0/projects/KE/repos/my-repo/pull-requests />


The example provided in the Atlassian documentation includes some additional information in the request body and I tried including all that info as well, but still receive the same (400) Bad Request. error.


I know the credentials ($BasicAuth) are correct because I can get PRs, comment on PRs, etc. via the API with the same credentials. I can also create a new PR from the Bitbucket web interface.


So can anyone tell me what I'm doing wrong and what's the correct way to accomplish this?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

04 November, 2023

How to unload assemblies without using AppDomain.Unload?

 Programing Coderfunda     November 04, 2023     No comments   

I'm trying to make something with .Net Framework 4.8 that can load and unload other dlls .
Loading them is ok but i cant use AppDomain.CreateDomain() and unload appdomain to unload loaded assemblies.If i use the method, this exception will appear:
NotSupportedException: Specified method is not supported.
System.Runtime.Remoting.RemotingServices.IsTransparentProxy (System.Object proxy) in :0
System.Runtime.Remoting.RemotingServices.Marshal (System.MarshalByRefObject Obj, System.String ObjURI, System.Type RequestedType) in :0
System.AppDomain.GetMarshalledDomainObjRef () in :0
System.AppDomain.InvokeInDomain (System.AppDomain domain, System.Reflection.MethodInfo method, System.Object obj, System.Object[] args) (at :0)
System.Runtime.Remoting.RemotingServices.GetDomainProxy (System.AppDomain domain) (at :0)
System.AppDomain.CreateDomain (System.String friendlyName, System.Security.Policy.Evidence securityInfo, System.AppDomainSetup info) (at :0)
System.AppDomain.CreateDomain (System.String friendlyName) (at :0)



Also i have tried to use System.Runtime.Loader package instead, but it seems not supported on .net framwork. Is there any way to solve this problem? Or is there any other ways to unload assemlies?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to integrate prerender.io into react app

 Programing Coderfunda     November 04, 2023     No comments   

"I'm currently developing a React app in which the implementation of meta descriptions and OG meta tags is crucial. I'm working on blog pages where the content is dynamically generated from the database based on the URL's slug parameter. I'm using react-helmet to handle dynamic meta tags, but I've encountered an issue where I can't share the URL with other websites to ensure that the OG tags appear correctly.


I've researched the documentation for prerender.io, but I couldn't find a guide for implementing it with React. If anyone has experience implementing prerender.io with React, I would greatly appreciate your assistance."


I attempted to implement dynamic meta tags for blog pages in my React app using react-helmet. I expected that by doing so, the meta descriptions and OG (Open Graph) meta tags would be correctly set for each blog post, making it shareable on other websites and social media platforms. However, I encountered a limitation where sharing the URL with other websites didn't display the OG tags correctly, leading to issues when sharing blog posts.


I also explored the documentation for prerender.io to see if it could potentially address this issue, but I couldn't find a specific guide or example for integrating it with a React application.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

'Cannot find type in scope' error when access public enum as class variable in swift

 Programing Coderfunda     November 04, 2023     No comments   

how can I use enum under extension into another class? I have no problem to use it under function directly. However I got 'Cannot find type '.home' in scope' error when set as a variable
extension Color {

public enum ColorUsage {
case home([String])
case school([String])
case park([String])

var description: String {
switch self {
case .home: return "my home"
case .school: return "kid school"
case .park: return "family park"
}
}

func getValue() -> [String] {
switch self {
case .home(let value),
.school(let value),
.park(let value):
return value
}
}
}

func findColor(places: [ColorUsage]) {
for eachPlace in places {
...
}
}
}

class MyClass {
func useColor() {
let places = [.home(["home1", "home2"]), .school(["AAA", "BBB"]), .park(["you park", "his park"])] /// issue with 'Cannot find type '.home' in scope'
let places = Color.findColor(places: places)

let places = Color.findColor(places: [.home(["home1", "home2"]), .school(["AAA", "BBB"]), .park(["you park", "his park"])]) /// no issue
}
}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

AttributeError: 'NoneType' object has no attribute 'config' while True loop

 Programing Coderfunda     November 04, 2023     No comments   

Nothing I try works. I'm trying to change the config of a button within a function called by the button.
from tkinter import *

root= Tk()
# window config here
btn = Button(root, text="Start", command="toggle").pack()

def toggle():
if btn.config('text')[-1] == 'Start':
btn.config('text')[-1] == 'Stop'
elif btn.config('text')[-1] == 'Stop':
btn.config('text')[-1] == 'Start'

while btn.config('text')[-1] == 'Stop': # Error throws here
print('click')

root.mainloop()



It keeps throwing AttributeError: 'NoneType' object has no attribute 'config' regarding commented line
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Where should I store images with deployment on Vercel using nextjs

 Programing Coderfunda     November 04, 2023     No comments   

I have a portal which I have recently expanded to include a real estate offer. At the moment I still save all images in /public/assets/images. I don't think it's best practice to save all the images there. At least a user upload hasn't happened yet. Where and how would you store the assets?


Thank you very much!
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

03 November, 2023

Showing Direction Arrow on Line in Mapboxgl

 Programing Coderfunda     November 03, 2023     No comments   

Trying to show a arrow as indication of direction in mapboxgl. The arrow is only visible at high zoom and is not visible at low zooms.



Adding a image Layer with 'symbol-placement': 'line'



Line Layer

map.addLayer({
'id': 'route',
'type': 'line',
'source': 'mapSource',
'filter': ['==', '$type', 'LineString'],
'layout': {
'line-join': 'round',
'line-cap': 'round'
},
'paint': {
'line-color': '#3cb2d0',
'line-width': {
'base': 1.5,
'stops': [[1, 0.5], [8, 3], [15, 6], [22, 8]]
}
}
});




Arrow Layer

const url = 'img/arrow.png'
map.loadImage(url, (err, image) => {
if (err) { return; }
map.addImage('arrow', image);
map.addLayer({
'id': 'arrowId',
'type': 'symbol',
'source': 'mapSource',
'layout': {
'symbol-placement': 'line',
'symbol-spacing': 1,
'icon-allow-overlap': true,
// 'icon-ignore-placement': true,
'icon-image': 'arrow',
'icon-size': 0.045,
'visibility': 'visible'
}
});
});




No Arrow at low zoom







Arrow showing at high zoom







I have tried experimenting with symbol-spacing, but it didn't work.
Is there way to force mapbox to show arrow on low zoom?



jsfiddle.net/4jjmh2nb
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

GCP static website hosting via bucket does not serve configured error and index pages

 Programing Coderfunda     November 03, 2023     No comments   

I'm trying to serve a simple static React SPA through GCP bucket as described here:
https://cloud.google.com/storage/docs/hosting-static-website />

It is crucial for my structure that for /my_directory, the file /my_directory/index.html is served.


I think what I want is exactly described here in the "Three-object bucket" in the documentation


This is my config:





This is my file structure:





In the folder test_2023_11_03_c there is a file "index.html"


But it doesn't work.


For



*
https://storage.googleapis.com/my-bucket-name, I expect to get the main index.html served. However, instead I get a list of all files in the bucket.

*
https://storage.googleapis.com/my-bucket-name/something-that-doesnt_exist, I expect the content of my_error.html to be served. However, instead I get NoSuchKeyThe specified key does not exist.No such object: my-bucket-name/something-that-doesnt_exist

*
https://storage.googleapis.com/my-bucket-name/test_2023_11_03_c, I expect the content of the directory's index.html to be served. However, instead I get the same error: NoSuchKeyThe specified key does not exist.No such object: my-bucket-name/test_2023_11_03_c






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

PHP Input Stream Truncated at 8192 bytes

 Programing Coderfunda     November 03, 2023     No comments   

I'm working on a project on Symfony 3 as an API and Angular as a front (This is not relevant i think but hey).



When some datas are sent through a PUT request to the server, the data are truncated at 8192 bytes.



I checked for every file configurations (apache files, even cli file, .htacces file... but can't seem to find the issue.)



Weirdest thing, is the issue is on the dev server, the same request on the production server works (all the 18 000~ bytes are sent correctly), so i even tried to take the production server's php configuration file, but even that failed. Just to add on the information, the server runs on php 7.



I'm at a loss, what could i have missed ?



I'm pretty sure the issue comes from a configuration file, or a knowledge i'm missing. So help would be greatly appreciated.



Thanks.



Edit: After a bit of forcing... Here is a .tar.gz containing the files requested:




https://files.fm/u/ddghdx36
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Error: Can't determine type for tag '?attr/shapeAppearanceCornerSmall

 Programing Coderfunda     November 03, 2023     No comments   

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.






C:\Users\Rahul.gradle\caches\transforms-3\4ccff20ef7c231e6ca175cf84e24aa03\transformed\material-1.9.0\res\values\values.xml: Error: Can't determine type for tag '?attr/shapeAppearanceCornerSmall'




* Try:







Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.




* Get more help at
https://help.gradle.org />





Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.


You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.


See
https://docs.gradle.org/7.6.2/userguide/command_line_interface.html#sec:command_line_warnings />

Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.


I am getting the above error when I am trying to build the apk


I have tried to upgrade gradle but its still showing the same problem and "implementation 'com.google.android.material:material:1.6.0'" also added this code in build.gradle its still not working.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Django query sum decimal based on column

 Programing Coderfunda     November 03, 2023     No comments   

I trie to find a solution to summary fields depended on a row. In the database the SQL would be:


Database:
ACCOUNT | LIMIT | MARKET | LENDING | BALANCE
----------------------------------------------
1000010 | 200.00 | 0.00 | -234.55 | 1000.00
1000010 | 300.00 | 11.00 | 0.00 | -239.00
1000010 | -200.00 | 235.00 | -134.00 | 450.00
1000011 | 30.00 | 1.00 | -10.00 | -98.00
1000011 | -200.00 | 235.00 | -134.00 | 49.00



SQL statements:
SUM(LIMIT) as bond_limit,
SUM(MARKET) as market_value,
SUM(LENDING) as lending_value,
SUM(case when BALANCE > 0 then BALANCE else 0 end) as FREE,
SUM(case when BALANCE < 0 then BALANCE else 0 end) as MISS



This should be the result:
ACCOUNT | LIMIT | MARKET | LENDING | BOND_LIMIT | MARKET_VALUE | LENDING_VALUE | FREE | MINUS
1000010 | 200.00 | 0.00 | -234.55 | Sum(LIMIT) | Sum(MARKET) | Sum(LENDING) | Sum(BALANCE) or 0
1000010 | 300.00 | 11.00 | 0.00 | Sum(LIMIT) | Sum(MARKET) | Sum(LENDING) | Sum(BALANCE) or 0
1000010 | -200.00 | 235.00 | -134.00 | Sum(LIMIT) | Sum(MARKET) | Sum(LENDING) | Sum(BALANCE) or 0
1000011 | 30.00 | 1.00 | -10.00 | Sum(LIMIT) | Sum(MARKET) | Sum(LENDING) | Sum(BALANCE) or 0
1000011 | -200.00 | 235.00 | -134.00 | Sum(LIMIT) | Sum(MARKET) | Sum(LENDING) | Sum(BALANCE) or 0

erg = database.objects.filter(
account=ACCOUNT
).aggregate(
bond_limit=Sum('LIMIT'),
market_value=Sum('MARKET'),
lending_value=Sum('LENDING')
)

.filter(bond_number=bond_number).aggregate(bond_limit=Sum('LIMIT')
^^^^^^^^^^^
NameError: name 'bond_number' is not defined

erg.filter(BALANCE__gt=0)...
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

02 November, 2023

C++ STL Pririty Queue

 Programing Coderfunda     November 02, 2023     No comments   

Trying to do:


#include
#include \

using namespace std;

int main()

{

vector* V = new std::vector();

V[0].push_back(1);
V[0].push_back(2);
V[1].push_back(3);
V[1].push_back(4);
V[2].push_back(5);

priority_queue pq1;

return 0;

}



Getting following error:


/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/queue:425:22: error: type 'std::priority_queue::container_type' (aka 'std::vector *') cannot be used prior to '::' because it has no members
typedef typename container_type::value_type value_type;
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Cycle inside ; building could produce unreliable results: Xcode Error

 Programing Coderfunda     November 02, 2023     No comments   

I am trying to move to the new build system when compiling with Xcode 10. However, it gives the following error:
Cycle details:
→ Target 'project' : LinkStoryboards

Target 'project' has compile command with input '/Users/project/Commons/Components/ScreenshotSharing/ViewController/AppShare.storyboard'

Target 'project' : ValidateEmbeddedBinary /Users/project/Xcode/DerivedData/project-hgqvaddkhmzxfkaycbicisabeakv/Build/Products/Debug-iphoneos/project.app/PlugIns/stickers.appex

Target 'project' has process command with input '/Users/project/Resources/Info.plist'

Target 'project' has compile command with input '/Users/project/Commons/Components/ScreenshotSharing/ViewController/AppShare.storyboard'






Even after removing the problem file, I get the same for another xib/storyboard. How can I solve this error without reverting to the legacy build system?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How compare char (or wchar_t) as part of string in c++

 Programing Coderfunda     November 02, 2023     No comments   

I have two C-style null-terminated (wide)strings (not std::wstring) and I go through them by iterators and want to compare them char by char (for sorting). I don't need to use standard operators (==, >,
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to set MediaPlayerElement source in code in C++ in WinUI3?

 Programing Coderfunda     November 02, 2023     No comments   

I am working on a simple project using WinUI3 in C++, and I want to set MediaPlayerElement source in code. Microsoft provide the answers, but it is in c# as following code shows.
MediaPlayerElement mediaPlayerElement1 = new MediaPlayerElement();
mediaPlayerElement1.Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Media/video1.mp4"));
mediaPlayerElement1.AutoPlay = true;



So how to set the media source in code in C++? (the source is like this: "rtsp://198.145.2.56")
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

iOS 17 Force Screen Rotation not working on iPAD only

 Programing Coderfunda     November 02, 2023     No comments   

I have followed all the links on Google and StackOverFlow, unfortunately, I could not find any reliable solution Specifically for iPad devices.


I am using the sample code from Kodeco UISplitViewController. You can download the source code from here and add a UIButton.


I added a Button and added a code for WindowScene RequestGeometryUpdate function.


So, please I need help to Rotate iPad Screen when Pressed on Button. I have attached Error Console Message when pressed on a Button.


Your help will be greatly appreciated.
@IBAction func btnSelector(_ sender: Any) {
self.rotateToLandsScapeDevice()
}

func rotateToLandsScapeDevice(){

let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
if #available(iOS 16.0, *) {
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: .landscapeLeft), errorHandler: { error in
print("Error", error)
})
self.setNeedsUpdateOfSupportedInterfaceOrientations()
} else {
// Fallback on earlier versions
UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")
UIView.setAnimationsEnabled(true)
}

}



Error Console Message
Error Domain=UISceneErrorDomain Code=101 "The current windowing mode
does not allow for programmatic changes to interface orientation."
UserInfo={NSLocalizedDescription=The current windowing
mode does not allow for programmatic changes to interface orientation.}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

01 November, 2023

7 Tips for Adding a Second Server to your App

 Programing Coderfunda     November 01, 2023     No comments   

---



Adding a second server to your app can be a great way to improve your app's performance and/or increase its reliability. However, there are a couple of things you need to keep in mind when adding a second server.


In this article, we'll discuss the key things you need to consider when adding an additional server to your app. We’ll use a Laravel hosted in Laravel Forge as the example here, but the concepts can be applied to any kind of application, not even limited to the PHP language.


Current infrastructure




First, to make sure we are speaking the same language, this is the outline of the current infrastructure. This app is currently running on a server created by Laravel Forge and running on AWS.



* Lets Encrypt for the SSL certificate;

* Redis (installed on the machine) for sessions, caching and as the queue driver for storing and processing background jobs;

* MySQL (installed on the machine) as the database;

* Local folder for saving user uploaded content;

* Laravel Scheduler using server’s CRON every minute;

* Deployments are manually triggered by clicking Laravel Forge’s “Deploy now” button;






1. Load balancer




The first thing you will need is a load balancer. This will be the entrypoint of your application, meaning you will point your domain DNS to the load balancer instead of the server directly. The job of a load balancer is, as you guessed, to balance the incoming requests between all the healthy and registered servers.





From now on, every time we mention “App Server”, this will be referring to a single server running our Laravel application.


One of the nice features of a load balancer is the health checks, which serve the purpose of making sure that all connected servers are healthy. If one of the servers fails for some reason, some unscheduled maintenance for example, the load balancer will stop routing requests to that server until the server is up, running, and healthy again.


We recommend using the application load balancer, which gives more robust functionality down the road, if you need it. Application load balancers can route traffic to specific servers based on the requested URL and even route requests to multiple applications. For now, we will have it evenly balance traffic using the round robin method.


Since your domain will now be pointing to the load balancer, your SSL certificate should also be in the load balancer now, instead of in your servers.


2. Database (MySQL), cache & queue (Redis)




Currently, there is one server running our app, local instances of MySQL, and Redis. What happens when the second gets attached to our load balancer?


Having multiple sources of truth for our database and caching layers could generate all kinds of issues. With multiple databases, the user would be registered in one server but not the other. With one Redis instance per server, you could be logged in into App Server 1, but when the load balancer redirects you to App Server 2 you would have to sign in again, since your session is stored in the local Redis instance.


We could make App Server 2, or any future App Servers connected to our load balancer, connect to App Server’s 1 services, but what happens when App Server 1 has to go down for maintenance or it unexpectedly fails? One of the reasons to add a second server is to have more reliability and scalability, which does not solve our problem.


The ideal scenario, when we have multiple app servers, is to have external services like MySQL and Redis running in a separate environment. To achieve this, we can use managed services, like AWS RDS, for databases and AWS Elasticache for Redis or unmanaged services, meaning we are going to set up a separate server to run those services ourselves. Managed services are usually a better option if cost is not an issue since you don’t have to worry about OS and softwares upgrades, and they usually have a better security layer.


Let’s imagine we decided to go with managed services for our application. Our Laravel configuration would become similar as this:
-DB_HOST=localhost
+DB_HOST=app-database.a2rmat6p8bcx7.us-east-1.rds.amazonaws.com
-REDIS_HOST=localhost
+REDIS_HOST=app-redis.qexyfo.ng.0001.use2.cache.amazonaws.com



After everything is set up, our infrastructure would look like this when connecting our App Servers to our services.





3. User uploaded content




Our application allows users to upload a custom profile picture, which shows up when you are logged in. On our current infrastructure, images get saved in an internal folder in our application and also get served from there. Now that we have multiple App Servers, this would be an issue, since the images uploaded in the App Server 1 will not be present on the second server.


There are a few ways to solve this. One of them is to have a shared folder between your servers (Amazon EFS, for example). If we choose this option, we would have to configure a custom filesystem in Laravel which would point to this shared folder location on our App Servers. While a valid option, this requires some knowledge to set up the disk on the servers, and for every new server you set up, you would have to configure the shared folder again.


We usually prefer using a Cloud Object Storage service instead, like Amazon S3 or Digital Ocean Spaces. Laravel makes it really easy to work with these services, if you are using the File Storage options. In this case, you would only have to configure your filesystem disk to use S3, and upload all your previous user uploaded content to a bucket.
-FILESYSTEM_DISK=local
+FILESYSTEM_DISK=s3 

AWS_ACCESS_KEY_ID=your-key
AWS_SECRET_ACCESS_KEY=your-secret-access-key
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=your-bucket-name



All your user uploaded content will be stored in the same, centralized bucket. S3 has built in versioning, multiple layers of redundancy and any additional app servers we add to our load balancer can use the same bucket to store content.





If your application grows in the future, you can set up AWS Cloudfront, which acts as a CDN layer sitting on top of your S3 bucket, serving your bucket content faster to your users and often cheaper than S3.


4. Queue workers




In step 2, we set up a centralized Redis server, which is the technology we were using to manage our application queues. This will also work for our load balanced applications, but there are a few good options to explore.


If you continue to process your queues on your app servers leveraging the centralized Redis instance, no changes need to be made. The jobs will get picked up by the server that has a worker available to process a job.


Another option is to use a service like AWS SQS, which can relieve some pressure on your Redis instance as your application grows by offloading that workload to another service.


5. Scheduled commands




When running multiple servers behind a load balancer, scheduled commands would run on each server attached to your load balancer by default, which is not optimal. Not only would running the same command multiple times be a waste of processing power, but could also cause data integrity issues depending on what that command does


Laravel has a built-in way to handle this scenario so that your scheduled commands only run on a single server by chaining a onOneServer() method.
$schedule->command('report:generate')
->daily()
->onOneServer();



Using this method does require the use of a centralized caching server, so Step 2 is critical to making this work.


6. Deployment




When it comes to deploying your application, you now have so many options and things to consider.


We can still deploy our applications using our previous approach, but now we have to make sure we remember to click the deploy button on both servers. If we forget, we would have our servers running different versions of the application, which could cause huge issues.


With multiple servers, it’s probably time to level up the deployment strategy. There are some very good deployment tools and services out there, like Laravel Envoyer or PHP Deployer. These types of tools and services allow you to automate the deployment process across multiple servers, so you can remove human error from the equation.


If we want to go one level deeper in our deployment process, since we now have 2 app servers, one of the great benefits is that we can temporarily remove one of the servers from the load balancer, and that server will stop receiving requests. This allows us to have zero downtime deployment, where we remove the first server from the load balancer, deploy the new code, put it back into the load balancer, remove the second one and do the same process again. Once server 2 is finished, both servers will have the new code and will be attached to the load balancer. To achieve this, we would use tools like AWS CodeDeploy, but the setup is more complex than our previous options.


Deployment is a very important process of our applications, so if we can automate the deployment using Github Actions or any CI/CD services out there, we are greatly improving the process. Making the deployment process simple and where anyone can trigger a deployment really shows the maturity of the development team and the application.





7. Network & security




One additional benefit we have with the use of a load balancer is that our servers are not the entrypoint of our websites anymore. This means we can only have our servers be internally accessible and/or restricted by specific IPs (our IPs, Load Balancer IPs, etc). This greatly improves the security of our servers since they are not directly accessible. The same can (and should) be done for our database and cache clusters.


To achieve this, we are going to only allow traffic to port 22 from our own IPs (so we can SSH into the server) and we are going to only allow traffic to port 80 from the load balancer, so it can send requests to the server. The same rules apply for our database and cache clusters.


Final thoughts




There are a lot of things to consider when adding additional servers to your infrastructure. It adds more complexity to your infrastructure and workflows, but it also increases the reliability and scalability of your application as well as improves your overall security.


When considered from the beginning of the process, these recommendations are simple to implement and can have a large impact on improving your app.



The post 7 Tips for Adding a Second Server to your App 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...
  • Features CodeIgniter
    Features CodeIgniter There is a great demand for the CodeIgniter framework in PHP developers because of its features and multiple advan...
  • Laravel Breeze with PrimeVue v4
    This is an follow up to my previous post about a "starter kit" I created with Laravel and PrimeVue components. The project has b...
  • 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 ...

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