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

11 November, 2023

Access a Json inside a string?

 Programing Coderfunda     November 11, 2023     No comments   

Suppose I have a single dictionary/Json in Python which is inside a List:


Minimum Working Example:
response = [{ "UserStor": "id1","StoryTitle": "title1","StoryState": "state1", "UserStoryType": "type1","RawUpdates": "updates1","RawComments": "comments1"}]



If I need to access this dictionary, I can do:
print(response[0])

#output
{'UserStor': 'id1', 'StoryTitle': 'title1', 'StoryState': 'state1', 'UserStoryType': 'type1', 'RawUpdates': 'updates1', 'RawComments': 'comments1'}


---



Now, I have another dictionary but, it is inside a string
response = "{'UserStor': 'id1', 'StoryTitle': 'title1', 'StoryState': 'state1', 'UserStoryType': 'type1', 'RawUpdates': 'updates1', 'RawComments': 'comments1'}"



How, can I access this dictionary?


I know I can use ast.literal_eval().


Is there any other way to access this dictionary without using literal_eval()/eval() ?


I am here to learn, your comments and answers are welcome.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Add tag to another tag that matched condition

 Programing Coderfunda     November 11, 2023     No comments   

In this case, i just want to add just before , but i don't want to add that already has before . What to to add or edit from the below Regex?
$string = "One two three four five six seven";
Result i want : One two three four five six seven

$xx = preg_replace_callback(
'//',
function ($addtag) {
return "".$addtag[0];
},
$string
);

echo $xx;



Result i want : One two three four five six seven
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

No module named - Running script from Terminal/IronPython [duplicate]

 Programing Coderfunda     November 11, 2023     No comments   

When I try to open a scrpit using IronPython, I get an error: No module named 'config'


File structure for python project:



Root



ConfigGenerator



__config_generator.py







config.py




__config_generator.py:
import config

CONFIG = config.Config()

def __main():
# there are redundant to the question code

if __name__ == '__main__':
__main()



And now C# project:
using Microsoft.Scripting.Hosting;
using IronPython.Hosting;
using System;
using System.Windows.Forms;

namespace ProjectName
{
public partial class MainForm : Form
{
private ScriptEngine _engine;

public MainForm()
{
_engine = Python.CreateEngine();

InitializeComponent();
}

private void StartConfigGenerator_Click(object sender, EventArgs e)
{
RunScript(@"Q:\Project\Python\Bots\Root\ConfigGenerator\__config_generator.py");
}

private void RunScript(string path)
{
_engine.ExecuteFile(path);
}
}
}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Java SWT: Difference between redraw, reskin, update and requestLayout (and pack)

 Programing Coderfunda     November 11, 2023     No comments   

Can anybody please explain to me the difference of the methods Control.redraw(), Control.update(), Widget.reskin(), Control.requestLayout() and Control.pack()?
Unfortunately the API documentation does not tell so much about the differences.


I guess the following:


Control.requestLayout() means calculating the size and position of a control inside a Composite when its content (like a text in a label or text field) has changed and perhaps its displayed size/position is not anymore appropriate.
I think I understand Control.pack(): It is just a part of Control.requestLayout or rather Composite.layout() as only the size of controls will be changed but not the position.


Control.redraw() and Control.update(): It seems to me that both methods just paint the control again and you call them when the operating system does not show it correctly anymore. You call the methods if size and position have not changed. The difference between both methods is that update() repaints the control immediately whereas redraw() can do it after some time.


I don't understand when I need to call Widget.reskin(). It seems to me the same as Control.redraw().
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Optimization dots&line game

 Programing Coderfunda     November 11, 2023     No comments   

i just built dots and line game with minimax algorithm where user could play with AI, but unfortunately it is too slow even in just depth 4. so any optimization technique?


here My code,
class Maze {
constructor(gridX, gridY, sideSize) {
this.board = Array.from({ length: gridY }, (a) => a = Array.from({ length: gridX }, (b) => b = Array.from({ length: 4 }, c => c = 0)));
this.visited = [];
this.gap = Math.floor(sideSize / 8);
this.x = gridX;
this.y = gridY;
this.winPointX = 0;
this.winPointY = 0;
this.row = gridX * this.gap;
this.column = gridY * this.gap;
this.sideSize = sideSize;

};
drawGrid(ctx) {
console.log(this.row, this.column)
ctx.clearRect(0, 0, canv.width, canv.height);
for (let x = 0; x < this.row; x += this.x)
for (let y = 0; y < this.column; y += this.y) {

ctx.fillStyle = 'red';
ctx.fillRect(x * this.gap, y * this.gap, this.gap, this.gap);

}

};
ai(depth, alpha, beta, player, advantage, y, x, tile_Y, tile_X) {
if (y !== undefined && x !== undefined) {
let winPoint = this.boxForm(y, x)
if (tile_X > -1 && tile_X < 8 && tile_Y > -1 && tile_Y < 8) {
winPoint = winPoint || this.boxForm(tile_Y, tile_X)
}

if (winPoint && player == 'O') {
player = 'X';

advantage += 10

}
else if (winPoint && player == 'X') {
player = 'O';

advantage -= 10;

// console.log('Human bonus',y,x)
}
}

if (depth === 0) {

return { score: advantage }
}

var pieceArr = [];

for (var i = 0; i < this.board.length; i++) {
for (var j = 0; j < this.board[0].length; j++) {

for (let b = 0; b < 4; b++) {
if (this.board[i][j][b]) {
continue;
};
let tileX = j;
let tileY = i;
let best = {}
this.change(i, j, b)
best.bestmove = [i, j, b];
let neghdir;
if (b == 2) {
neghdir = 0;
tileX++
} else if (b == 0) {
neghdir = 2;
tileX--
} else if (b == 3) {
neghdir = 1;
tileY--
} else {
neghdir = 3;
tileY++
};
if (tileX > -1 && tileX < 8 && tileY > -1 && tileY < 8) {
this.change(tileY, tileX, neghdir);
}
var g = this.ai(depth - 1, alpha, beta, player == 'X' ? 'O' : 'X', advantage, i, j, tileY, tileX);

/* if (tileX>-1&&tileX-1&&tileY alpha) {
alpha = best.score;
}
} else {

if (best.score < beta) {
beta = best.score
}
};
if (tileX > -1 && tileX < 8 && tileY > -1 && tileY < 8) {
this.board[tileY][tileX][neghdir] = 0;
}
this.board[i][j][b] = 0;
pieceArr.push(best)

if (alpha >= beta) {
break;

}

}

}
};
pieceArr.sort((a,b)=>{
return Math.random()-0.5;
})
var bestMove;
if (player === 'X') {
var bestScore = -10000;
for (var i = 0; i < pieceArr.length; i++) {
if (pieceArr[i].score > bestScore) {
bestScore = pieceArr[i].score;
bestMove = i;
}
}
} else {
var bestScore = 10000;
for (var i = 0; i < pieceArr.length; i++) {
if (pieceArr[i].score < bestScore) {
bestScore = pieceArr[i].score;
bestMove = i;
}
}
}
return pieceArr[bestMove];
};
rmSide(side, dir, col) {
let vertex;
if (dir == 'w') {
vertex = [side[0] * this.x, this.y * side[1]];
} else if (dir == 'e') {
vertex = [(side[0] + 1) * this.x, this.y * side[1]];
}
else if (dir == 'n') {
vertex = [this.x * side[1], (side[0]) * this.y];

} else if (dir == 's') {
vertex = [this.x * (side[1] + 1), (side[0]) * this.y];
}
if (!vertex) {
return null
}

let x = vertex[0];

for (let y = vertex[1] + 1; y < vertex[1] + this.y; y++) {

ctx.fillStyle = col;
if (dir == 'n' || dir == 's') {
ctx.fillRect((y) * this.gap, (x) * this.gap, this.gap, this.gap);
} else {
ctx.fillRect((x) * this.gap, (y) * this.gap, this.gap, this.gap);
}

};

}
change(y, x, dir, player) {

this.board[y][x][dir] = 'X';

}
boxForm(y, x) {

for (let i = 0; i < 4; i++) {
if (!this.board[y][x][i]) {
return false
}

};

return true
}
};
//dots and line
const canv = document.getElementById('canv');
const ctx = canv.getContext('2d');
const size = Math.min(window.innerWidth, window.innerHeight) * 0.7;
canv.width = size;
canv.height = size
const sideSize = size / 8;
console.log(sideSize)
let turn = 'X'

const maze = new Maze(8, 8, sideSize);

maze.drawGrid(ctx);
function mve(tileX, tileY, dir, player) {

if (tileX < 8 && tileY > -1 && tileX > -1 && tileY < 8) {

turn = player == 'O' ? 'X' : 'O'

let n = null;
if (dir == 'n') {
n = 3
} else if (dir == 's') {
n = 1
} else if (dir === 'e') {
n = 2
} else {
n = 0
}

/*
let cordX = e.clientX;
let cordY = e.clientY;
let dirCor = {
'n':[65+tileX*(100+20),75+(tileY)*(100+20)],
's':[65+tileX*(100+20),195+(tileY)*(100+20)],
'w':[45+tileX*(100+20),90+(tileY)*(100+20)],
'e':[165+tileX*(100+20),90+(tileY)*(100+20)]

};
console.log(cordX,cordY,dirCor);

// console.log(dirCor['n'][0]&&(dirCor['n'][0]+100)&&dirCor['n'][1]&&(dirCor['n'][0]+15))
if (cordX>=dirCor['n'][0]&&cordX=dirCor['n'][1]&&cordY=dirCor['s'][0]&&cordX=dirCor['s'][1]&&cordY=dirCor['e'][0]&&cordX=dirCor['e'][1]&&cordY=dirCor['w'][0]&&cordX=dirCor['w'][1]&&cordY -1 && tileX < 8 && tileY > -1 && tileY < 8) {
maze.change(tileY, tileX, neghdir);
if (maze.boxForm(tileY, tileX)) {
turn = player;
}
};
if (turn == "O") {
console.log(maze.board)
playAI()
}

}

}
}

function playAI() {

let aimove = maze.ai(4, -Infinity, Infinity, 'X', 0);
let dir1 = undefined;
if (aimove.bestmove[2] == 0) {
dir1 = 'w'
} else if (aimove.bestmove[2] == 1) {
dir1 = 's'
} else if (aimove.bestmove[2] == 2) {
dir1 = 'e'
} else {
dir1 = 'n'
};
console.log(aimove)
mve(aimove.bestmove[1], aimove.bestmove[0], dir1, 'O')

}

canv.addEventListener('click', (e) => {
const rect = canv.getBoundingClientRect()
let tileX = Math.floor((e.clientX - rect.x) / sideSize);
let tileY = Math.floor((e.clientY - rect.y) / sideSize);
let dir = prompt('direction');

mve(tileX, tileY, dir, 'X');

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

10 November, 2023

npm install MaxListenersExceededWarning

 Programing Coderfunda     November 10, 2023     No comments   

During npm install I get several of the following warning message:


(node:5156) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxLis
teners() to increase limit
(node:5156) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxLis
teners() to increase limit
npm ERR! code ECONNRESET
npm ERR! syscall read
npm ERR! errno ECONNRESET
npm ERR! network request to
https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz failed, reason: read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'


npm ERR! A complete log of this run can be found in: C:\Users\xxxx\AppData\Local\npm-cache_logs\2023-11-10T15_52_29_865Z-debug-0.log


install npm and dependences
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Atomic locks in Laravel (demo & tutorial)

 Programing Coderfunda     November 10, 2023     No comments   

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

How to pass multiple values as sql array for a parameter? (Or how can I cirumvent limit of parameters of prepared statement?)

 Programing Coderfunda     November 10, 2023     No comments   

I'm trying to create a query using QueryDSL wich accepts more than 32767 parameters (32767 is the upper limit of parameters the postgresql driver accepts).


The query is currently created like this:
static final QInvoiceEntity invoiceEntity = ...

void queryInvoicesWithId(String... ids) {
JPAQuery query = ...
query.where(invoiceEntity.id.in(ids));
}



This works if no more than 32767 parameters are passed. If you pass more than that (e.g. 38000) the following exception is thrown:
Caused by: java.io.IOException: Tried to send an out-of-range integer as a 2-byte value: 38000
at org.postgresql.core.PGStream.sendInteger2(PGStream.java:275)



One solution according to 1 is to use ANY and pass the parameters as an array. I've tried the following but to no avail:
query.where(Expressions.booleanTemplate("{0} = ANY {1}", invoiceEntity.id, ids);



But this throws the following exception:
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ? near line 3, column 31 [select invoiceEntity
from InvoiceEntity invoiceEntity
where invoiceEntity.id = ANY (?1)



I've even tried to pass the parameters as a string and convert it back in the query:
query.where(Expressions.booleanTemplate("{0} = ANY string_to_array({1}, ',')", invoiceEntity.id, String.join(",", ids));



But this throws the following exception:
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 3, column 45 [select invoiceEntity
from InvoiceEntity invoiceEntity
where invoiceEntity.id = ANY string_to_array(?1, ',')
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to get the cell's output data from a azure databricks notebook to a file

 Programing Coderfunda     November 10, 2023     No comments   

Unable to get a single cell's output to a file in Azure databricks notebook


Tried many ways but unable to get the result.


Can someone help me on this if there is a way or there is no way please let me know.


Thanks and regards,
Prem
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Getting an image from the database using path images on the client side

 Programing Coderfunda     November 10, 2023     No comments   

I used multer to download the image and save the path of the image to the database, and then how can I get the image from the client and show it on the screen?
import multer from 'multer';

const storageConfig = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, './images')
},

filename: (req, file, cb) => {
cb(null, Date.now() + '-' + file.originalname)
}
})

const upload = multer({storage: storageConfig});

let path = '';

app.post('/upload',upload.single('image'), (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '
http://localhost:3000'); /> if(req.file) {
console.log(req.file);
path = req.file.path;
res.send('hi')
return;
}
res.send('bye')
})



after I received the file path I saved it in the database, but I don’t know how to use it later to show this picture on the screen
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

09 November, 2023

The Ultimate "git nah" Alias

 Programing Coderfunda     November 09, 2023     No comments   

---



Recently, developer Liam Hammett shared a fabulous git nah snippet on Twitter that is better than your existing git nah alias 🔥



I know lots of people use a "nah" alias to abort their current changes, but they usually limit it to "git reset --hard".


I like to do more by cleaning and aborting any potential rebase. If I use the "nah" command, I know I want a fresh start, so this helps



He shared two versions, including setting it up as a git alias:
# Git alias ⬇️
[alias]
nah = "!f(){ git reset --hard; git clean -df; if [ -d ".git/rebase-apply" ] || [ -d ".git/rebase-merge" ]; then git rebase --abort; fi; }; f"



If you prefer a bash function instead, here's that version that you would add to your .bashrc or .zshrch file:
# Bash function ⬇️
nah () {
git reset --hard
git clean -df
if [ -d ".git/rebase-apply" ] || [ -d ".git/rebase-merge" ]; then
git rebase --abort
fi
}



Depending on which snippet you prefer, here's how you'd run it:
# Alias
$ git nah

# Bash
$ nah



What are some of your favorite git aliases? Share them with us!



The post The Ultimate "git nah" Alias 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

Laravel Nova gets a fresh new website

 Programing Coderfunda     November 09, 2023     No comments   

---



Laravel Nova is a beautifully-designed administration panel for Laravel. Carefully crafted by the creators of Laravel, and they just launched a brand new website with a fresh design.



Nova allows you to create beautiful, easy-to-use, and complete application backends that handle all of your needs.


Gone are the days of cobbling together lackluster administration panels. Nova is designed and crafted by the Laravel team, so it integrates perfectly with the framework.


Nova is the easiest way to quickly manage your data, view your key application metrics, or handle any custom process your application requires.


To celebrate the new launch, all Nova licenses are discounted by ~30%. You can even renew your existing license early to lock in the 30% discount. Visit nova.laravel.com for all the details.



The post Laravel Nova gets a fresh new website appeared first on Laravel News.


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

How to prevent GitHub Actions from being run based on name of the branch merging into other branch

 Programing Coderfunda     November 09, 2023     No comments   

I have the following workflow:
on:
pull_request:
branches: [main]



I only want GitHub Actions to run when the branch I'm making the PR from does not start with "random/name*".


I found this in the docs:
on:
pull_request:
# Sequence of patterns matched against refs/heads
branches-ignore:
- 'mona/octocat'
- 'releases/**-alpha'



but it only excludes it when making a PR to that branch, I want it to ignore branches I'm making the PR from. Is this possible?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to prevent dialog from disappearing? Reactjs

 Programing Coderfunda     November 09, 2023     No comments   

In this code I am displaying popup that have buttons, when button responsible for cancelation is clicked confirmation dialog shows up. I want the popup to disappear when clicked outside of it so I handle it like so:
const popupRef = useRef(null);

const handleClickOutside = (event: MouseEvent) => {
if (
popupRef.current &&
!popupRef.current.contains(event.target as Node)
) {
onClose();
}
};

useEffect(() => {
document.addEventListener('mousedown', handleClickOutside);

return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, []);



onClose is callback that closes the popup. Now when button is clicked I create the dialog like so:
{showCancelConfirmationDialog &&
}

const handleCloseDialog = () => {
console.log("closing");
setShowCancelConfirmationDialog(false);
}

const handleCancelReservation = () => {
console.log("block")
block.isReserved = false;
block.reservedBy = "notMe";
onClose();
}



Dialog code:
interface DeleteConfirmationDialogProps {
onCancel: () => void;
onConfirm: () => void;
name: string;
}

const DeleteConfirmationDialog: React.FC = ({ onCancel, onConfirm, name }) => {
return (



Te jazdy sÄ… zarezerwowane przez: {name}


Czy na pewno chcesz je przesunąć i powiadomić o tym kursanta?
Usuń i powiadom
Anuluj

);
}

export default DeleteConfirmationDialog;



And now the problem is that wherever I click everything disappears because useEffect and handleClickOutside is triggered no matter what and I have no idea what it is happening. If I comment out this code it works fine. I tried adding another popupRef for the dialog but it didn't work. I also tried to control it via boolean when dialog is active but it also does not work.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Using route group in NextJS 13 stops tailwind from working

 Programing Coderfunda     November 09, 2023     No comments   

In my NextJS 13 app, Tailwind classes stop being applied when I move page.tsx/layout.tsx from the root of my app directory into a (main) directory (also in the root of my app directory). I imagine there is some config somewhere that is becoming invalidated when I use the route group, but I'm not sure what it is.


This is my tailwind.config file:
import type { Config } from 'tailwindcss'

const config: Config = {
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
'gradient-conic':
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
},
},
plugins: [],
}
export default config
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

08 November, 2023

Laravel Pail - The easiest way to tail your log files

 Programing Coderfunda     November 08, 2023     No comments   

---



Laravel Pail is a package that allows you to easily dive in and tail your application's log files. Pail is designed to work with any log driver, be super easy to remember, and provide a set of useful filters to help you quickly find what you're looking for.





Installing Laravel Pail




Installation is as easy as requiring the package from Composer:
composer require laravel/pail



Then start it to begin tailing your logs:
php artisan pail



Laravel Pail has some flags that allow you to filter log messages in useful ways:


Filter logs by exception type


php artisan pail --filter="QueryException"



Filter by message


php artisan pail --message="User created"



Filter by Log level


php artisan pail --level=error



You can use any of the levels: emergency, alert, critical, error, warning, notice, info, and debug.


Filter by User ID


php artisan pail --user=1



The source code is available on GitHub at laravel/pail, and you can view the full documentation on the Laravel site.



The post Laravel Pail - The easiest way to tail your log files 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

Laravel 10.31 Released

 Programing Coderfunda     November 08, 2023     No comments   

---



This week, the Laravel team released v10.31, the ability to place batches within job chains. You can run jobs sequentially, then parallelize a batch of jobs, and continue with the chain once that batch has been completed.


Allow placing a batch on a chain




Sebastien Armand added the ability to run batches of jobs within a job chain



This is a use case we encounter in a couple places at Square where we have a serial process of jobs that need to be handled and one or more of the steps either should be worked on in parallel or are of unknown length when initially triggering the workflow and will create additional jobs, but we need to know when this is finished to ensure we keep the chain going.



Here's an example from the updated Chains & Batches documentation, where you could first flush the cache, release a batch of podcasts, and then batch notifications of those podcasts:
use App\Jobs\FlushPodcastCache;
use App\Jobs\ReleasePodcast;
use App\Jobs\SendPodcastReleaseNotification;
use Illuminate\Support\Facades\Bus;
 
Bus::chain([
new FlushPodcastCache,
Bus::batch([
new ReleasePodcast(1),
new ReleasePodcast(2),
]),
Bus::batch([
new SendPodcastReleaseNotification(1),
new SendPodcastReleaseNotification(2),
]),
])->then(function () {
// ...
})->dispatch();




Sleep::until() handles string timestamps




James Hulse contributed the ability to pass a timestamp string to Sleep::until(), which will still ensure the value is numeric:
Sleep::until("1699411804");



Added support for Sec-Purpose header




@nanos contributed support for the Sec-Purpose header when relying on the $request->prefetch() method:



Whilst most User Agents set Purpose: prefetch in prefetch requests, Firefox uses Sec-Purpose: prefetch in the latest version, as described in the above MDN article. This means that calling the ->prefetch() method on the request will return false for requests sent via the Firefox browser, regardless of prefetch status.



Release notes




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


v10.31.0






* [10.x] Allow Sleep::until() to be passed a timestamp as a string by @jameshulse in
https://github.com/laravel/framework/pull/48883 />

* [10.x] Fix whereHasMorph() with nullable morphs by @MarkKremer in
https://github.com/laravel/framework/pull/48903 />

* [10.x] Handle class_parents returning false in class_uses_recursive by @RoflCopter24 in
https://github.com/laravel/framework/pull/48902 />

* [10.x] Enable default retrieval of all fragments in fragments() and fragmentsIf() methods by @tabuna in
https://github.com/laravel/framework/pull/48894 />

* [10.x] Allow placing a batch on a chain by @khepin in
https://github.com/laravel/framework/pull/48633 />

* [10.x] Dispatch 'connection failed' event in async http client request by @gdebrauwer in
https://github.com/laravel/framework/pull/48900 />

* authenticate method refactored to use null coalescing operator by @miladev95 in
https://github.com/laravel/framework/pull/48917 />

* [10.x] Add support for Sec-Purpose header by @nanos in
https://github.com/laravel/framework/pull/48925 />

* [10.x] Allow setting retain_visibility config option on Flysystem filesystems by @jnoordsij in
https://github.com/laravel/framework/pull/48935 />

* [10.x] Escape forward slashes when exploding wildcard rules by @matt-farrugia in
https://github.com/laravel/framework/pull/48936 />






The post Laravel 10.31 Released 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

SwiftUI / Xcode: ForEach closed range vs half open range - error with Text function. Why the difference?

 Programing Coderfunda     November 08, 2023     No comments   

I have an old pascal and C background, and recently started to learn Swift.
I have encountered an error beyond my common sense.


Following code works fine.


click to view
ForEach(0..
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

I do not understand why PostgreSQL indicates that a procedure does not exist

 Programing Coderfunda     November 08, 2023     No comments   

I have a strange problem with PostgreSQL. It indicates that a procedure does not exist while I think that I created it. I really do not understand. I tried to remove arguments only to see if I would have the same problem or another one but I still got the same problem...


Here is my code :
DROP TABLE IF EXISTS clients, accounts, transactions, failed_transactions CASCADE;

CREATE TABLE IF NOT EXISTS clients
(
id int PRIMARY KEY,
name varchar
);

CREATE TABLE IF NOT EXISTS accounts
(
id int PRIMARY KEY,
balance float,
client int,
FOREIGN KEY (client) REFERENCES clients(id),
CHECK (balance >= -500)
);

CREATE TABLE IF NOT EXISTS transactions
(
id serial PRIMARY KEY,
amount float
);

CREATE TABLE failed_transactions
(
id serial,
account_id integer,
attempted_amount float,
timestamp timestamp DEFAULT NOW()
);

CREATE OR REPLACE PROCEDURE log_failed_transaction(new_line record, old_line record)
LANGUAGE plpgsql
AS $$
BEGIN
IF new_line.balance
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

I can't get new data after apolo fetchMore

 Programing Coderfunda     November 08, 2023     No comments   

next.js,typescript,react,apollo.

I want to use fetchMore when handleLoadMore is called to get 10 data from the 11th one, but the data in console.log(data) is from 0 to 10, which is the first data I got.

I tried to open the DevTool network, but the network shows data from 11.
import {
Box,
Button,
} from '@chakra-ui/react'
import Image from 'next/image'
import { useRouter } from 'next/router'
import { useState } from 'react'

import { ChannelLayout } from '@/components/Layouts/ChannelLayout'
import { useFindMyMoviesQuery } from '@/generated/request'
import type { NextPageWithLayout } from '@/types/layout'

const Cannel: NextPageWithLayout = () => {
const router = useRouter()

const { data, loading, fetchMore } = useFindMyMoviesQuery({
variables: { skip: 0, take: 10 },
})

const [currentPage, setCurrentPage] = useState(1)
console.log(data)
if (loading) return loading...

const handleLoadMore = () => {
const pageSize = 10
fetchMore({
variables: {
skip: 11,
take: 10,
},
}).then((result) => {
setCurrentPage(page)
})
}
return (



)
}

Cannel.getLayout = ChannelLayout

export default Cannel



As noted above.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

07 November, 2023

forEach is not a function (for translation tool) [closed]

 Programing Coderfunda     November 07, 2023     No comments   

I always get the error:



Uncaught TypeError: country.languages.forEach is not a function



when trying this code:
var arrayLanguage = [];

country["languages"].forEach(function (element) {
arrayLanguage.push(element["name"]);
});

self.selectedLanguage = country["languages"].length > 0 ? arrayLanguage.join(", ") : "N/A";



I was trying to realise a searchbar input field where independent of the language used (e.g. Germany, Germania, Deutschland,...) through typing in a country's name into the searchbox input field the right country name will be found and shown - I'm using the restcountries api.


Any ideas how I could adapt the code?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

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
Newer Posts Older Posts Home

Meta

Popular Posts

  • Show page numbers as navigation in Laravel pagination
      Answer Sorted by:                                                Highest score (default)                                                  ...
  • How to monitor process status during process lifetime
    I need to track the process status ps axf during executable lifetime. Let's say I have executable main.exec and want to store into a fi...
  • Different ways of passing a variable by reference?
    I want to pass a variable to a function and have the function change the value. I know I can do this as an object but am wondering if the...
  • Use Flags For Countries & Languages in Laravel Blade Views
      Blade Flags   is a package to efficiently use   TwEmoji Countries & Languages Flags   in your Laravel Blade views. You can use it easi...
  • How to Run a Python File on a Specific Virtual Desktop Only?
    I want to run a Python script on a specific virtual desktop without affecting other desktops. Currently, when I execute my Python file us...

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 (69)
  • 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 (4)
  • 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