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

20 September, 2024

Failed to install 'cordova-plugin-firebase': CordovaError: Uh oh

 Programing Coderfunda     September 20, 2024     No comments   

I had follow these steps to install an configure firebase to my cordova project for cloud messaging.
https://medium.com/@felipepucinelli/how-to-add-push-notifications-in-your-cordova-application-using-firebase-69fac067e821 />


I have the google-services.json file and added into root path of my project. To install cordova-plugin-firebase, I tried to paste :






into config.xml and run cordova platform add android@6.4.0 .



Output :

Installing "cordova-plugin-firebase" for android
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-firebase': CordovaError: Uh oh!
"C:\Users\myAppName\application\platforms\android\google-services.json" already exists!




EDIT:
Tried step by step :

cordova platform rm android

cordova plugin rm cordova-plugin-firebase --save

cordova plugins
com.unarin.cordova.beacon 3.6.1 "Proximity Beacon Plugin"
cordova-open-native-settings 1.5.1 "Native settings"
cordova-plugin-badge 0.8.7 "Badge"
cordova-plugin-barcodescanner 0.7.4 "BarcodeScanner"
cordova-plugin-bluetoothle 4.4.3 "Bluetooth LE"
cordova-plugin-call-number 1.0.1 "Cordova Call Number Plugin"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-email 1.2.7 "EmailComposer"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-open-blank 0.0.2 "Open Blank"
cordova-plugin-splashscreen 5.0.3-dev "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.0 "SocialSharing"
cordova.plugins.diagnostic 4.0.6 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"

cordova platform add android@6.4.0

cordova plugin add cordova-plugin-firebase --save
Installing "cordova-plugin-firebase" for android
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-firebase': CordovaError: Uh oh!
"C:\Users\myProject\application\platforms\android\res\values\colors.xml" already exists!
at copyNewFile (C:\Users\myProject\application\platforms\android\cordova\lib\pluginHandlers.js:245:45)
at install (C:\Users\myProject\application\platforms\android\cordova\lib\pluginHandlers.js:43:17)
at ActionStack.process (C:\Users\myProject\application\platforms\android\cordova\node_modules\cordova-common\src\ActionStack.js:56:25)
at PluginManager.doOperation (C:\Users\myProject\application\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:114:20)
at PluginManager.addPlugin (C:\Users\myProject\application\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:144:17)
at C:\Users\myProject\application\platforms\android\cordova\Api.js:243:74
at _fulfilled (C:\Users\myProject\application\platforms\android\cordova\node_modules\q\q.js:854:54)
at self.promiseDispatch.done (C:\Users\myProject\application\platforms\android\cordova\node_modules\q\q.js:883:30)
at Promise.promise.promiseDispatch (C:\Users\myProject\application\platforms\android\cordova\node_modules\q\q.js:816:13)
at C:\Users\myProject\application\platforms\android\cordova\node_modules\q\q.js:570:49
Uh oh!
"C:\Users\myProject\application\platforms\android\res\values\colors.xml" already exists!




I don't understant what's wrong...
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

pyspark XPath Query Returns Lists Omitting Missing Values Instead of Including None

 Programing Coderfunda     September 20, 2024     No comments   

I have a PySpark DataFrame with a column containing XML strings, and I'm using XPath queries with absolute paths to extract data from these XML strings. However, I've noticed that the XPath queries return lists that omit values if they are not present, rather than including None in their place. I would like to keep the length of the lists consistent, filling in None where data is missing.


Here is the sample data and code I'm working with:
data = [
(1, """



Lion

Apple






Banana





Tiger

Cranberry




"""),
(2, """



Lion

Apple





Tiger

Banana





Zebra




""")

df = spark.createDataFrame(data, ["id", "xml_string"])



What the XPath queries return:


For data column:
(1, ["Apple","Banana","Cranberry"], ["Lion","Tiger"])
(2, ["Apple","Banana"], ["Lion","Tiger","Zebra"])
What I want:


For data column:
(1, ["Apple","Banana","Cranberry"], ["Lion", None, "Tiger"])
(2, ["Apple","Banana", None], ["Lion","Tiger","Zebra"])


How can I adjust my XPath queries?
root/level1/level2/level3/level4/data

root/level1/level2/level3/data2
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

SQL REPL from within Python/Sqlalchemy/Psychopg2

 Programing Coderfunda     September 20, 2024     No comments   

It's helpful to have a DB CLI available for writing quick raw SQL queries. Suppose that the 1 minute it takes to remind myself how to type the correct version of psql postgresql://username@localhost:5432 is simply too long.


Is there any convenience method like engine.interactive() that just drops you into a CLI in the current database, similar to breakpoint() dropping you into a PDB? One thing I considered was
subprocess.run(['psql', engine.url])



But that doesn't work since psql doesn't accept the +psycopg2: bit of the sqlalchemy connection string.
$ psql postgresql+psycopg2://postgres:dev@localhost:5432/
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "root" does not exist

$ psql postgresql://postgres:dev@localhost:5432/
psql (16.4 (Debian 16.4-1.pgdg120+1))
Type "help" for help.

postgres=#



I can slice it off myself and this works:
def enter_cli(engine):
url = engine.url.set(drivername=url.drivername.split("+")[0])
connection_string = url.render_as_string(hide_password=False)
subprocess.run(["psql", connection_string])



But that seems likely to be non-portable, as I'm hardcoding the CLI and the specific type of connection string. (e.g. it looks like pgcli wants postgres:// and doesn't accept postgresql://.) The other approach would be writing a python-based CLI, but with the naive approach you lose a lot of tab-completion and similar features. Is there a portable way to do this?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

MySql Explain with Tobias Petry

 Programing Coderfunda     September 20, 2024     No comments   

---




This week, we welcome Tobias Petry to the Laravel Creator Series show to discuss his journey into database optimization, the development of his MySQL Explain tool, and the acquisition of the domain mysqlexplain.com. Tobias also shares insights about his other projects, including Stack Bricks, a tool for managing different database versions, and his contributions to the Laravel Debug Bar.


➡️ Save 10% on his Indexing Beyond the Basics book and video package with the coupon code LARAVELNEWS


Show Links






*

https://x.com/tobias_petry />

*

https://tpetry.me />

*

https://mysqlexplain.com />

*

https://stackbricks.app />

*

https://sqlfordevs.com />

*

https://goodindexes.com />






The post MySql Explain with Tobias Petry 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 combine information from different devices into one common abstract virtual disk? [closed]

 Programing Coderfunda     September 20, 2024     No comments   

Is it possible to create a program that will connect hard drives of computers via the Internet and combine this data into one virtual disk? I don't know how to implement this in practice.


I need to create a program that can combine computers and their hard drives into one virtual disk. It should be a compiled executable (exe) application. Please give me at least some information about this.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

19 September, 2024

AdminJS not overriding default dashboard with custom React component

 Programing Coderfunda     September 19, 2024     No comments   

So, I just started with adminjs and have been trying to override the default dashboard with my own custom component. I read the documentation and I don't think I am doing anything wrong? yet it still wont load the component. I started with a basic component to see whether it works or not.
It's being initialized but its not overriding the default dashboard.
AdminJS initialized with dashboard: { component: 'Dashboard' }



Code is provided below
Dashboard.jsx:
import React from 'react';
import { Box } from '@adminjs/design-system';
import { useTranslation } from 'adminjs';

const Dashboard = () => {
const { translateMessage } = useTranslation();
console.log('dashboard component loading...')
return (



{translateMessage('helloMessage', 'Hello')}



);
};

export default Dashboard;




admin.js:
import AdminJS from 'adminjs';
import { Database, Resource } from '@adminjs/sequelize';
import Customers from './src/models/Customers.js';
import Product from './src/models/Product.js';
import People from './src/models/People.js';
import Companies from './src/models/Companies.js';
import Leads from './src/models/Leads.js';
import Offers from './src/models/Offers.js';
import { ComponentLoader } from 'adminjs';

const componentLoader = new ComponentLoader();

const Components = {
Dashboard: componentLoader.add('Dashboard', './src/components/Dashboard.jsx')
};

AdminJS.registerAdapter({ Database, Resource });

const adminOptions = {
dashboard: {
component: Components.Dashboard
},
componentLoader,
resources: [{
resource: Customers,
options: {
parent: null,
properties: {
id: {
isVisible: { list: false, edit: false, show: false },
},
type: {
position: 1,
availableValues: [
{ value: 'company', label: 'Company' },
{ value: 'person', label: 'Person' },
],
},
name: {
position: 2,
},
email: {
position: 3,
},
phone: {
position: 4,
},
country: {
position: 5,
},
},
},
},
{
resource: People,
options: {
parent: null,
},
},
{
resource: Companies,
options: {
parent: null,
},
},
{
resource: Leads,
options: {
parent: null,
properties: {
type: {
availableValues: [
{ value: 'company', label: 'Company' },
{ value: 'person', label: 'Person' },
],
},
},
},
},
{
resource: Offers,
options: {
parent: null,
},
},
{
resource: Product,
options: {
parent: null,
},
},
],
rootPath: '/admin',
};

export default adminOptions;



server.js:
import AdminJS from 'adminjs'
import AdminJSExpress from '@adminjs/express'
import express from 'express'
import dotenv from 'dotenv'
import sequelize from './src/config/db.js';
import { Database, Resource } from '@adminjs/sequelize';
import adminOptions from './admin.js';

dotenv.config();

const PORT = 3000;

const start = async () => {
const app = express()
AdminJS.registerAdapter({ Database, Resource });
const admin = new AdminJS(adminOptions);
console.log('AdminJS initialized with dashboard:', admin.options.dashboard);

const adminRouter = AdminJSExpress.buildRouter(admin)
app.use(admin.options.rootPath, adminRouter)

app.listen(PORT, async () => {
console.log(`AdminJS started on
http://localhost:${PORT}${admin.options.rootPath}`) />
try {
await sequelize.authenticate();
console.log("database connected successfully")

await sequelize.sync();
console.log("database models synchronized")
}
catch (err) {
console.log("error connecting to database", err)
}
})
}

start()



I tried logging any information regarding it but it seems like it's not loading the component at all?
Any help or suggestions would be appreciated. Thanks!
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Campfire Coders (The post-Laracon-'24 recap episode!)

 Programing Coderfunda     September 19, 2024     No comments   

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

Why ngModel doesn't works on the last version of Angular 17?

 Programing Coderfunda     September 19, 2024     No comments   

I am trying to make a form in my angular app, but when i want to implement ngModel on my form :



Connexion




Mot de passe oublie ?
Se Connecter




I have this error :


NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'. [plugin angular-compiler]


I can't import FormsModule in the app.module.ts because this file doesn't exists on Angular 17, i only have an app.config.ts file.


Can someone please explain me how to do?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Fetch PHP is a Lightweight HTTP Library Inspired by JavaScript's fetch()

 Programing Coderfunda     September 19, 2024     No comments   

---




Fetch PHP is a lightweight HTTP library inspired by JavaScript's fetch, bringing simplicity and flexibility to PHP HTTP requests. It uses the Guzzle client behind the scenes, offering synchronous and asynchronous requests with an easy-to-use API


I know that Guzzle is king, and I will use Laravel's HTTP client on most projects. However, the Fetch PHP package is just downright fun when you want a no-frills fetch() function:
$response = fetch('
https://jsonplaceholder.typicode.com/todos/1');">
https://jsonplaceholder.typicode.com/todos/1'); />
// Get the JSON response
$data = $response->json(assoc: true);
print_r($data);
/*
[
"userId" => 1,
"id" => 1,
"title" => "delectus aut autem",
"completed" => false
}
*/

// Get the status text (e.g., "OK")
echo $response->statusText();



Available Response Methods




*
json(bool $assoc = true): Decodes the response body as JSON. If $assoc is true, it returns an associative array. If false, it returns an object.

*
text(): Returns the response body as plain text.

*
blob(): Returns the response body as a PHP stream resource (like a "blob").

*
arrayBuffer(): Returns the response body as a binary string.

*
statusText(): Returns the HTTP status text (e.g., "OK" for 200).

*
ok(): Returns true if the status code is between 200-299.

*
isInformational(), isRedirection(), isClientError(), isServerError(): Helpers to check status ranges.





The asynchronous requests use the fetchAsync() function to can be used as follows:
//
// Asyc requests
//
$promise = fetchAsync('
https://jsonplaceholder.typicode.com/todos/1');">
https://jsonplaceholder.typicode.com/todos/1'); />
$promise->then(function ($response) {
$data = $response->json();
print_r($data);
});

// Wait for the promise to resolve
$promise->wait();

//
// Error handling
//
$promise = fetchAsync('
https://nonexistent-url.com'); />
$promise->then(function ($response) {
// handle success
}, function ($exception) {
// handle failure
echo "Request failed: " . $exception->getMessage();
});



You can also pass Guzzle options to the fetch() and fetchAsync() functions for any advanced Guzzle features you'll need. You can learn more about this package, get full installation instructions, and view the source code on GitHub.



The post Fetch PHP is a Lightweight HTTP Library Inspired by JavaScript's fetch() 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

Asking random PHP questions at Laracon

 Programing Coderfunda     September 19, 2024     No comments   

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

18 September, 2024

window.location.replace() is not working

 Programing Coderfunda     September 18, 2024     No comments   

just wanna ask why does window.location.replace is not working in my page. I've been working on it for weeks. It works fine on my other pages, although those pages have DevExpress components, but in this particular page where I am only using normal html and asp tags and components it is not working. It seems to be refreshing only and not redirecting. Here is my code for the button:






Thanks.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

My first Laravel package - Translation checker for Laravel

 Programing Coderfunda     September 18, 2024     No comments   

Hey everyone!

I have created my first Laravel package, Translation Checker! It's designed to simplify the process of managing translations in your lang folders, so you no longer need to manually add new translations whenever you add a new translation string.

I built this into a package because it solved a personal need, and gave me a chance to try parsing PHP, and now, I decided to open-source.
Check it out on GitHub: Translation Checker

If you're working with multi/bi-lingual applications, whether open-source or closed-source—let me know! I’m eager for it to be tested in more real-life cases and make it work with different workflows other than my own.

Any feedback is appreciated :) submitted by /u/cawex
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Windows 10 Intellij 2024.2.1 Spring boot WebFlux Unit test failed normally it's work fine. I have a exit code -1

 Programing Coderfunda     September 18, 2024     No comments   

@ExtendWith(MockitoExtension.class)
class XXXXXXXTest {
private YYYYRule rule;

@Mock
private ZZZZService zzzzService;

@BeforeEach
void setUp() {
rule = new YYYYRule(zzzzService);
}

@Test
void shouldWork() {
RuleEngineContext context = generateActionExecutionContext();

assertThat(rule.when(context)).isTrue();

MonoMock mockToCall = MonoMock.empty();
when(zzzzService.method(anyString(), anyString(), eq(context.getOrderData().getExistingCustomerOrder()))).thenReturn(mockToCall);

StepVerifier.create(rule.then(context))
.verifyComplete();

ExecutionAction executionAction = context.getOrderData().getExecutionActions().get(0);

verify(zzzzService).method(executionAction.getRequestId(), ENUM.templateType, context.getOrderData().getExistingCustomerOrder());
mockToCall.expectHasBeenSubscribed();

assertThat(executionAction.getAllImpactedLines().stream().allMatch(impactedLine -> impactedLine.isStepOfTypeIsAtStatus(TYPE, ImpactedLineStep.Status.COMPLETED))).isTrue();

assertThat(context.getOrderData().getExistingLineExecutions().stream().allMatch(line -> line.getSentMails().isEmpty())).isTrue();

assertThat(rule.when(context)).isFalse();
}



}


Result :


NFO: Received request to resolve method 'void package.XXXXTest.shouldWork()' as test but could not fulfill it


org.opentest4j.AssertionFailedError:


Expecting value to be true but was false


Expected :true


Actual :false

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)

at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)

at packages.XXXXXTest.shouldWork(XXXXTest.java:94)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:568)

at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)

at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)

at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)

at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)

at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)

at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)

at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)

at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)

at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)

at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)

at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)

at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)

at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)

at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)

at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)

at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)

at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)

at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)

at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)

at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)

at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)

at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)

at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)

at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)

at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)

at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)

at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)



Disconnected from the target VM, address: '127.0.0.1:55360', transport: 'socket'


Process finished with exit code -1


Normally this tests return successfull
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Validate Console Command Input With the Command Validator Package

 Programing Coderfunda     September 18, 2024     No comments   

---




The Command Validator package by Andrea Marco Sartori makes validating the input of console commands a cinch using Laravel's beloved Validator. All the Laravel Validator rules you know and love work with this package, along with any custom validation rules.


This package integrates with your application's console commands using the provided ValidatesInput trait, which includes an abstract rules() method. The command signature looks like the following:
namespace App\Console\Commands;

use Illuminate\Console\Command;
use Cerbero\CommandValidator\ValidatesInput;

class SampleCommand extends Command
{
use ValidatesInput;

protected $signature = 'app:sample {--start-date=}';

// ...

public function rules(): array
{
return ['start-date' => 'date_format:Y-m-d'];
}
}



I find it really neat that you can use a closure-based custom validation rule directly in your console command with command-specific business logic:

public function rules(): array
{
return [
'start-date' => [
'date_format:Y-m-d',
function (string $attribute, mixed $value, Closure $fail) {
$date = Carbon::parse($value);
$startOfYear = Carbon::now()->startOfYear();

if ($date->lessThan($startOfYear)) {
$fail("The {$attribute} must be a date from {$startOfYear->format('Y-m-d')} or later.");
}
}
],
];
}



When validation passes, you know you're working with valid input, and your handle() method can stay clean from manual validation checks.


Another neat use-case using the built-in validation rules is validating that an input exists in the database automatically with the exists rule:
public function rules(): array
{
return ['user-id' => 'exists:users,id'];
}



Sure, you could easily query a user and conditionally return an error, but I think it's neat that you can validate it using exists automatically and give back a default error message when a record doesn't exist.


You can use this package in your project by installing it via Composer:
composer require cerbero/command-validator



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



The post Validate Console Command Input With the Command Validator Package 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

using type parameters in generic constraints in TypeScript

 Programing Coderfunda     September 18, 2024     No comments   

I have the following ts code in many places:


(note here's a typescript playground with the example)
let filtered = items.filter(item =>
item.title.toLowerCase().includes(search.toLowerCase()) ||
item.name.toLowerCase().includes(search.toLowerCase()) ||
item.date.toLowerCase().includes(search.toLowerCase())
);



So I created this function
function filterByKey(items: T[], keys: K[], search: string) {
return items.filter((item) =>
keys.some((key) => item[key].toString().toLowerCase().includes(search.toLowerCase()))
);
}



to call it like this:
let filtered = filterByKey(items, ['title', 'name', 'date'], search));



But I'm getting this error:
Property 'toString' does not exist on type 'T[K]'



I tried like this, but it doesn't seem like a valid syntax
function filterByKey(items: T[], keys: K[], search: string)



how can I tell ts that the properties of items will support .toString()


or how would you handle such a case so taht typescript won't complain?

---



I checked this ts documentation:
https://www.typescriptlang.org/docs/handbook/2/generics.html#using-type-parameters-in-generic-constraints
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

17 September, 2024

FINDSTR' is not recognized as an internal or external command

 Programing Coderfunda     September 17, 2024     No comments   

Hello I trying to install jmeter
I type

cd C:\apache-jmeter-2.13\bin
C:\apache-jmeter-2.13\bin>jmeter.bat




And i receive this message

FINDSTR' is not recognized as an internal or external command
Not able to find Java executable or version. Please check your Java installation




.
I trying change PATH variable , fallow this topic
Findstr does not work with SET /P?
, but it didn't work.

My PATH user variable is C:\Windows\System32, C:\Program Files\apache-maven-3.3.3\src\bin and System variable is C:\Program Files\apache-maven-3.3.3\bin; C:\WINDOWS\system32, C:\Program Files\TortoiseSVN\bin



Please help i not find helpful information in google
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Can `postMessage` messages get lost/dropped e.g. if recipient's main thread is coincidentally blocked at the time it should have received it?

 Programing Coderfunda     September 17, 2024     No comments   

Context:




I'm tracking down a hard-to-replicate bug related to messages between frames. One thing I'm mildly suspicious of is that messages between the main frame and an iframe are sometimes not being sent successfully. I.e. messages are possibly being "dropped" in rare cases.


Question:




Is there any spec-level guarantee that a message sent with postMessage will be received by the target frames, assuming there's no bugs in my code?


For example, if the recipient frame happens to be unresponsive (e.g. due to a long computation which freezes the main thread) at the time that it would have received the message event, could that cause the message event to be lost? Or would is it guaranteed to be "queued" and eventually received by the window once the main thread is freed up.


Notes:





* I'd prefer answers which reference specifications, since this would allow me to file bug reports on browser engines if needed.

* I've noticed that if I have the debugger paused in the recipient frame, then all messages are lost. After unpausing, the messages are never received.

* If there are no spec-level guarantees in this area, I'm also interested in any info on browser-engine-specific behavior, if anyone has any info on that.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

I built a free and public presentation tool called Simple Slides using Laravel/Filament/Inertia/Vue, and I wanted to share it

 Programing Coderfunda     September 17, 2024     No comments   

Hey everyone, I know no-one likes self-promotion, and I genuinely am trying to not make it about that. We talk a lot about Filament and Inertia here, and I built a free-to-use (and open-source, since it's public on my GitHub) web application that uses these tools heavily - and I just wanted to share it. Whether you want to use the tool, or just want to see the code - it's all free (GitHub:
https://github.com/alkrauss48/simple-slides).

It's called Simple Slides, and the url is
https://simpleslides.dev. The front-page is an interactive experience explaining what Simple Slides is and how it works, but the tl;dr is that it's a platform for creating simple presentations that are mostly text-based and fully responsive (so it looks good on mobile, for example).

I've given a lot of talks in the past, and I found the way I present fits really well with the Takahashi method (only a few words on a slide so that it's easier for the audience to understand, mostly text content, and changing slides often to keep your audience engaged).

I have many more plans for what I want to add on, but no immediate plans for monetization (maybe one day I'll consider it to assist in covering hosting costs, but that day is not today). I just build things that I want to exist, and that I want to use myself. I would always love any feedback, even if it's a downvote!

Lastly, just for fun, here's a short (< 4 min.) YouTube video I gave about this tool at a local user group. submitted by /u/thecodeboss
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

TemPHPest PHP Extension for VSCode

 Programing Coderfunda     September 17, 2024     No comments   

---




TemPHPest is an extension for Visual Studio Code to improve writing PHP in VS Code. Created by Liam Hammett, this package adds rich PHP features that will enhance the experience tremendously while writing PHP:



TemPHPest is an extension for VSCode that I’ve been working on to bring nice little tweaks and features to improve working with PHP. Each feature could probably be a separate extension, but being bundled in one is easier for me to maintain and you to install.



TemPHPest Extension Features





* Stubs for file creation

* Auto Renaming

* Code Actions

* Auto Switch to PHP Language

* Auto Interpolate from single quotes to double quotes

* Surround with Snippets

* Explorer file nesting

* REPL as you write

* Date formatting lense

* Smart autocompletion

* Blade Heredoc/Nowdoc syntax highlighting

* And more...






Let's highlight a few features that launched with TemPHPest for VS Code:


Stubs




Creating a PHP file in VS Code gives you an empty file (without PHP tags) out of the box, but TemPHPest uses PSR naming conventions to fill out an empty class/interface/trait/etc, based on the file's name. For example, creating a PHP file in app/Enums will stub out an enum for you with the proper namespace:
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How does StackOverflow optimise the performance for the display of the questions?

 Programing Coderfunda     September 17, 2024     No comments   

I am trying to learn C#.net to program a web app.



And having learned that stackoverflow uses C#.net I am happy to discover it.



I noticed that at the home page or at the questions section, whenever I refresh the page. The page always returns me the latest information without fail and at acceptable speeds.



I am not sure how do you do it. Sorry for the long series of questions. I am trying to learn what is the best practices for data retrieval, paging, performance , etc



I know that the homepage only returns a limited number of questions and their stats but the questions section actually returns everything.



How do you optimise it?





*

For the homepage, do you always grab ALL the stats of the recent questions? so your query is something like "select * from questions order by datetime_created limit 20" ?



So the * contains ALL the info including question title, id, views, etc?



Do you use HttpContext.Current.Server.cache to help with that?

*

For the questions, this is even more intriguing.



How do you do the paging?



Do you always grab from the database only the results for the specific page?



Or do you grab all the results and store it into a dataset? Then you use some kind of datagrid control to help with the paging?






If it is the latter, how do you maintain the data to be updated?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

16 September, 2024

Laravel Ai Package

 Programing Coderfunda     September 16, 2024     No comments   

I’ve broken ground on a AI package for Laravel.


https://github.com/jordandalton/laravelai

Currently supports Anthropic/Claude message creation, even a AI validation rule.

Looking forward to your feedback. submitted by /u/jdcarnivore
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel needs an official openapi implementation

 Programing Coderfunda     September 16, 2024     No comments   

Hi, i just want to discuss the state of openapi documentation in laravel. As it stands many if not all of the big frameworks have openapi integration, and its pretty straighyfoward, without much hassle or just little api docs.

Still, laravel, being so popular has no such implementation and i think this needs to be a priority for the team.

There are plenty of community libraries like dedoc but they have a long way from full support or need alot of docblocks to make sense.

The laravel team has the opportunity to implement such a feature by integrating it with its classes, in the same way the router can give you a list of ruotes, their methods and the controller 'executing' the action.

I tried on my own to test the waters and i dont think i would be able to do much better than dedoc scramble is doing due to limitations, my thinking in the way mapping works.

Plenty of teams use api docs, heck even having an internal documentation is amazing, not to speak about public apis.

What do you think about this? I would go ahead and start doing it myself but my skillet is not up there, and even then i dont see myself doing anything other than static analysis, which kinda results in the current available setups

Edit: if i wasnt clear, the idea is that for public libraries to have a full-baked setup they have to first get the routes(using the route class), use reflection to get info about the request that validates the data + its validation methods, then using static analysis to detect responses (correct me if wrong, but this was my impression after trying it myself). As far as we appressiate what the community is doing, having laravel at least give a hand into it is more than welcome, not to mention an official setup submitted by /u/EmptyBrilliant6725
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Clear cache on each iteration - JMeter

 Programing Coderfunda     September 16, 2024     No comments   

Should we clear on each iteration in our load scenario in jmeter


Original time in browser : 5 seconds
When I check Clear cache each iteration: 5 seconds
When I uncheck Clear cache each iteration: 100 milliseconds


Please suggest what should I do while testing (should I clear or not), the stats I shared are for single load
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Building Multiplayer Minesweeper with Laravel, Livewire and Reverb

 Programing Coderfunda     September 16, 2024     No comments   

---




Writing PHP was my first venture into web programming some 20 years ago. WordPress, Joomla, Drupal, Zend, you name it I probably had shipped something in it.


I took a step away from all that professionally around a decade ago and ventured off into Ruby, JS, TypeScript and lately Rust land. However, the recent uptick in PHP being discussed piqued my interest. I wanted to see where things were. Reader, I was in for a treat. Even if it did take a few licks (of reading the docs and fighting with configs) to get to the center of the lollipop.


My strategy when learning something new is generally to pick a silly project and then do whatever it takes to make it work. I’ll have one or two hard requirements for things I want to see happen, and all the rest is malleable.


Here is the joyful little app I ended up building. A multiplayer minesweeper Laravel app, with Livewire, Reverb and hosted on Fly.io.





You can play it at
https://multiplayerminesweeper.lol/ if you want (open a couple tabs and share the link with yourself for a “multiplayer” experience).
My two non-negotiable hard requirements: One, I wanted to be able to play minesweeper with a couple friends on a sizable (at least 20x20) grid on the web easily. Two, I didn’t want to write any React / Vue / anything. A touch of javascript if necessary was fine, but I wanted to avoid it where I could.


I’m happy to say, mission accomplished. The playable grid works pretty well up to 40x40. Turns out that kind of takes a long time to solve, and 30x30 seems more to be a more reasonable game length. And more importantly, I wrote almost no frontend javascript code. I leaned entirely on the capabilities of the tools provided by Laravel.


How, you might ask, is this possible in a traditionally request / response bound language and server? I sketched a quick diagram that shows a slightly abbreviated flow.





It’s a deceptively simple concept. When using Livewire components, Laravel wires up some simple javascript that when you take an action submits a “POST” request, and this is used by the Livewire components server side to generate and return new HTML in the response which gets swapped into the page. There are bits of state managed for you so the Livewire component that gets passed back and forth, so for instance maintaining something like a counter feels a bit like magic.


However, this left me with a problem in that a singular client would only ever see the latest state of things if and when it submitted its own moves forcing the update function call and getting the newest state patched into their HTML.


This is where Laravel Echo, a websocket client, and Reverb, a first party websocket server, end up being the big winners. We can subscribe to the Reverb server from each of the frontend Clients, with a tiny bit of JS from the provided Laravel Echo to subscribe to the game channel. When any client makes a move on the board, the Laravel server broadcasts an “update” message to all subscribers via the Reverb server. Each client then goes and picks up the latest state to patch into their HTML. Below is an abbreviated flow from the perspective of a “Viewer” of a move and the “Player” of a move.





I did initially have some problems with large payload sizes across the wire during an update, and it was super easy to cheat. It turns out that Livewire happily sends along all the properties on the class unless you inform it otherwise. I had a board property that was generated at the beginning of each game with the locations of all the mines, and other information like if there were mines in range (aka: the number squares). I was inadvertently hydrating this board into the state of the component that went across the wire with every call. Simply making the prop protected solves that problem. Finally, implementing gzipping shrunk the payloads across the wire tremendously since it was mostly repetitive HTML for each cell, ~300Kb to ~12Kb.


That’s it. That’s all it took and I had what feels like a little single page app to play a 900 cell game of minesweeper with a couple friends without writing any Javascript. The great part is, I’m sure this could all be vastly improved. Laravel, specifically Livewire, has quite a few neat ways to make optimizations. Importantly though, my silly project still works even without needing to be an expert. Could it be better? Yes. But in mere hours I built something that satisfied my predefined hard requirements.


I threw everything up on fly.io and started testing with friends. It totally worked, but because the payloads could be a little bit sizable (especially before I gzipped things), a more distant friend, in the geographical sense, said it could be a bit laggy. I played around with putting instances of the app distributed to a few regions to get things closer to players since the Fly platform made that so easy. This worked, but I realize that this caused a problem given I was using SQLite for my database. The game would only ever exist and be accessible to a player if it was started on the server they were routed to.


I ended up using a neat Fly feature to resolve this, the fly-replay header. In the case where a game had been started on a different server it let me dynamically route requests from one server that doesn’t have that game state on it, to the one that does, without the user being any the wiser.





In the best case, geographically close players have a better experience since no replay / re-routing is required. In the worst case for games with highly distributed players, players far away from the game host incur some latency, as I haven’t yet figured out how to beat the physics of the speed of light. However, at least it is routing that traffic behind the Fly Proxy, and not a likely weaker client connection.


Side note: Fly.io was kind enough to sponsor this silly project, and gave me a link that gives anyone reading a $50 credit if they want to play with Fly.io themselves. Even if you aren’t using their platform right now, you can grab the credits and they won’t expire on you!


It wasn’t all rainbows and 200’s




I want to be very clear... The following all comes from a place of acknowledging that Laravel and the ecosystem have done so much well that the sharp edges are particularly noticeable. The process of growing a framework and ecosystem should appreciate the new developer experience as a cornerstone. This was my singular developer new-to-the-framework experience.


Coming in as a complete novice to the Laravel ecosystem is disorienting at best. The sheer amount of flexibility in the framework along with its depth of features and integrated products inflict an analysis paralysis on newcomers. I wasn’t quite sure which, or if I needed any 25 different things listed under the ecosystem tab (answer, yes).


Getting going had a couple false starts figuring out what approach to take. Eventually I ended up with a very spicy stew from a local and Sail based environment. It’s all still a bit broken, but like my hand-me-down Dodge Stratus in high school, it got the job done.


I think what demoralized and slowed me down the most, there was no definitive “do this to get started”. There are docs, yes, honestly probably too many versions of “getting started”. It was a choose your own adventure where paths diverge, converge at points, lead off a cliff on another path (several times I deleted whole folders, attempted to uninstall everything and get back to a fresh state), and at one point you end up in an alley where you are offered some salve (Laravel Herd) to soothe all your aches and pains for a couple silver coins.


Were I to do this all again, I’d have a better idea of where to go and what I’d want. But my experience here is highly contrasted by experiences like install node, run npx create-next-app@latest or install ruby, run gem install rails.


When it came to actual functionality, it took me quite a bit of scouring the docs to understand that Livewire and Echo were the things I needed to enable a pattern of inducing a Livewire update when another client updates. But Echo then mentions Redis is needed, and something else called Reverb is optional, but you can use Pusher channels if you want instead? What was Reverb, Pusher channels? We all know I got there in the end, I needed a websocket broker and Reverb is simply the first party one provided by Laravel.


While reading the docs is not something I’m not proclaiming as a negative, and it is a side-effect of the “not all batteries included, but they are available” that seems to be the strategy of Laravel, it is painful in a lot of cases to have so many options documented without clear indicators of preference. If I was diving into laravel professionally, I’d likely read the documentation religiously and this would all be less of a problem. But for a new developer trying to set things up, all these options add up to a layer of hidden complexities.


As an illustration of hidden complexity, in the sketch at the beginning of the article... you see a redis powered queue system. It took me quite a while to realize I needed to actually run queue workers somewhere in my local dev, it didn’t just happen with the normal starting up of a dev server. For probably a solid hour I just thought my code was wrong. In retrospect, duh, but without catching the small two-sentence blurb in the docs under a h4 header, I wouldn’t have realized it for much longer.


Finally, when it came to shipping everything on fly.io, while packaging up a container and shipping was easy... with Laravel itself there are lots of configurations for everything because of all the flexibility in how you can model an architecture. You are mostly left to your own devices and experience for figuring it out. Lacking the requisite Laravel specific experience, I mostly resorted to guessing and playing documentation telephone with AI.


I simply wanted to put Reverb on a /socket path on my main domain. As far as I could tell this had to be possible (it is). And while the incantation is fairly trivial at the end of the day, the docs all make various assumptions, for example that Reverb will be running on its own subdomain. Even the pre-populated .env configuration files account for wanting to have Laravel be able to hit Redis inside of a network while your clients will need a DNS resolution across a domain.


To reiterate the opening paragraph of this section. I only took the time to write this because I care. There is a saying we use a lot at my day job, “Reality has a surprising amount of detail” (John Salvatier). When I look at everything Laravel has done and can do, it is not surprising to me that getting started is a bit complicated. The reality is that Laravel grew and evolved to the needs of those depending on it to do real work, real work is complicated. Every last thing I raised here is solvable with skilled and guided hands pruning and tending the garden of the ecosystem.


I’m impressed, the hype is earned




Regardless of the pains expressed, I still came away having enjoyed the journey and the project as a whole. I get why Laravel is gaining steam, I understand why people love the ecosystem. I appreciate and value what the community is building.


I’m not going to drop all my toolsets and jump to Laravel tomorrow at the day job, but I’m also pretty sure my next silly build with PHP isn’t going to be another decade away..



The post Building Multiplayer Minesweeper with Laravel, Livewire and Reverb 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

Python httpx.get or requests.get much slower than cURL for this API - why?

 Programing Coderfunda     September 16, 2024     No comments   

For a home automation project I am trying to pull train delay data for our magestically unreliable commuter trains. An API wrapper exists, with cURL examples. These work fine, but both Python's requests.get and httpx.get are slow to pull data (up to a minute for requests and ca. 4 seconds httpx) but curl, or pasting a link in the browser, returns almost immediately. Why?


The internet suggested that some sites have anti-scraping protections and may throttle or block requests, as it uses HTTP1.0. On this API httpx does seem to be much faster, but nowhere near as fast as curl or the browser.


Some examples - this Python snippet takes ca. 4 seconds:
import httpx
client = httpx.Client(http2=True)
response = client.get('
https://v6.db.transport.rest/stations?query=berlin')
https://v6.db.transport.rest/stations?query=berlin') /> print(response.text)



This takes up to a minute:
import requests
response = requests.get('
https://v6.db.transport.rest/stations?query=berlin')
print(response.text)



This returns almost immediately:
import subprocess
command = 'curl \'
https://v6.db.transport.rest/stations?query=berlin\' -s'
result = subprocess.run(command, capture_output=True, shell=True, text=True)
print(result.stdout)
print(result.stderr)



What's the magic here? Thanks in advance for any hints.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

15 September, 2024

Different ways of passing a variable by reference?

 Programing Coderfunda     September 15, 2024     No comments   

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 there is some way to do this that I haven't thought of.


This is what I want to do, but it doesn't work the way I want of course:
function test1(vari) {
vari = 2;
}
var myvar1 = 1;
test1(myvar1);
console.log(myvar1);



This works, but I don't really want to make all the variables objects:
function test2(vari) {
vari.val = 2;
}
var myvar2 = { val: 1 };
test2(myvar2);
console.log(myvar2.val);



This also works, but not an acceptable solution:
function test3(vari) {
eval(vari + ' = 2;');
}
var myvar3 = 1;
test3('myvar3');
console.log(myvar3);



Is there a better option than these?


Updated


A better example of what I would like to do:
function test5(vari, onblur) {
document.querySelector('body').innerHTML += ``;
el = document.getElementById(`ctl_${vari}`);
el.addEventListener('blur', function(e) {
vari = e.target.value; //Doesn't update original variable
onblur(e);
});
return el;
}
var myvar5 = 'test';
var ele = test5(
myvar5,
function(e) {
//Could set myvar5 = e.target.value but not wanting to do this for every single field
console.log(myvar5);
}
);
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Weekly /r/Laravel Help Thread

 Programing Coderfunda     September 15, 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

Convert CSV to REST API

 Programing Coderfunda     September 15, 2024     No comments   

Convert your CSV to a fast, searchable, REST API with my new tool. Check it out and let me know what you think. submitted by /u/jdcarnivore
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to consider daylight savings time when using cron schedule in Airflow

 Programing Coderfunda     September 15, 2024     No comments   

In Airflow, I'd like a job to run at specific time each day in a non-UTC timezone. How can I go about scheduling this?



The problem is that once daylight savings time is triggered, my job will either be running an hour too soon or an hour too late. In the Airflow docs, it seems like this is a known issue:




In case you set a cron schedule, Airflow assumes you will always want
to run at the exact same time. It will then ignore day light savings
time. Thus, if you have a schedule that says run at end of interval
every day at 08:00 GMT+1 it will always run end of interval 08:00
GMT+1, regardless if day light savings time is in place.




Has anyone else run into this issue? Is there a work around? Surely the best practice cannot be to alter all the scheduled times after Daylight Savings Time occurs?



Thanks.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

I dug through Laravel's new `defer()` helper to find out what's powering them if not queues.

 Programing Coderfunda     September 15, 2024     No comments   

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

Meta

Popular Posts

  • Write API Integrations in Laravel and PHP Projects with Saloon
    Write API Integrations in Laravel and PHP Projects with Saloon Saloon  is a Laravel/PHP package that allows you to write your API integratio...
  • Credit card validation in laravel
      Validation rules for credit card using laravel-validation-rules/credit-card package in laravel Install package laravel-validation-rules/cr...
  • Fast Excel Package for Laravel
      Fast Excel is a Laravel package for importing and exporting spreadsheets. It provides an elegant wrapper around Spout —a PHP package to ...
  • iOS 17 Force Screen Rotation not working on iPAD only
    I have followed all the links on Google and StackOverFlow, unfortunately, I could not find any reliable solution Specifically for iPad devic...
  • Features CodeIgniter
    Features CodeIgniter There is a great demand for the CodeIgniter framework in PHP developers because of its features and multiple advan...

Categories

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

Social Media Links

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

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

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

Loading...

Laravel News

Loading...

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