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

17 September, 2023

Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting

 Programing Coderfunda     September 17, 2023     No comments   

unset($CFG); global $CFG; $CFG = new stdClass(); $CFG->dbtype = 'sqlsrv'; $CFG->dblibrary = 'native'; $CFG->dbhost = 'my remote db ip address'; $CFG->dbname = 'remote database name'; $CFG->dbuser = '****'; $CFG->dbpass = '**********'; $CFG->prefix = 'mdl_'; $CFG->dboptions = array ( 'dbpersist' => 0, 'dbport' => 1433, 'dbsocket' => '', ); $CFG->wwwroot = '
http://localhost/LMS'; $CFG->dataroot = 'C:\\inetpub\\LMSdata'; $CFG->admin = 'admin'; $CFG->directorypermissions = 0777; This is my configuration in config.php. I'm using moodle 3.2 in IIS with php 7. Remote SQL server version 2012.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Optional Dependency in VBA Module

 Programing Coderfunda     September 17, 2023     No comments   

Background I am developing a VBA module (call it "Greg") for VBA developers of Excel UDFs. The purpose of Greg is to enhance the experience for the end user, who uses those UDFs in Excel. The developer must simply copy a snippet into their own module (call it "Dev"). If Greg is loaded, the snippet enhances Dev's behavior. Otherwise, it has no impact on behavior, but it does prompt the Excel user to import Greg.bas. Approach Here is a simplified sketch of Greg.bas... Attribute VB_Name = "Greg" ' Keep these functions invisible to Excel users. Option Private Module ' Enhancement function. Public Function Enhancer(Optional x) ' ... End Function ' Assert the 'Greg' module is loaded. Public Function IsLoaded() As Boolean IsLoaded = True End Function ...and of Dev.bas: Attribute VB_Name = "Dev" ' Some UDF by the dev. Public Function DevRegular() ' ... End Function ' ############# ' ## Snippet ## ' ############# ' Use the enhancer, if available via the 'Greg' module. Public Function DevEnhanced(Optional x) If Enhance_IsSupported() Then DevEnhanced = Greg.Enhancer(x) Else DevEnhanced = DevRegular() ' Prompt the user to import the enhancer. MsgBox "Import the 'Greg' module to enhance your experience." End If End Function ' Check if enhancement is supported via the 'Greg' module. Private Function Enhance_IsSupported() As Boolean On Error GoTo Fail Enhance_IsSupported = Greg.IsLoaded() Exit Function Fail: Enhance_IsSupported = False End Function Problem While this has worked sporadically on Windows, it has often failed there and always on Mac. The crux seems to be Enhance_IsSupported() within Dev: Private Function Enhance_IsSupported() As Boolean On Error GoTo Fail Enhance_IsSupported = Greg.IsLoaded() Exit Function Fail: Enhance_IsSupported = False End Function I assumed that the line Greg.IsLoaded() would compile, even if there were no Greg module present...and it does! It only fails when a Greg module exists without a member called IsLoaded(). Unfortunately, it seems that VBA does not reliably refresh its "awareness" of a Greg module with an IsLoaded() function. When I import Greg.bas and Dev.bas together, everything works as intended: Enhance_IsSupported() returns True, and it updates to False if Greg is removed. But when I first import Dev.bas and run DevEnhanced(), and only afterwards import Greg.bas, then Enhance_IsSupported() apparently returns False despite the presence of Greg. Note This latter workflow is absolutely essential: an Excel user must first run DevEnhanced() and see the prompt, in order to know about Greg.bas in the first place! Failed Solutions Unfortunately, no experimentation has availed. In Greg itself, I have tried using a constant... Public Const IS_LOADED As Boolean = True ...and also a procedure: Public Function IsLoaded() As Boolean IsLoaded = True End Function In the snippet for Dev, I have implicitly tried Application.Evaluate()... Private Function Enhance_IsSupported() As Boolean On Error GoTo Fail Enhance_IsSupported = [Greg.IsLoaded()] ' ^^^^^^^^^^^^^^^^^ ' Application.Evaluate("Greg.IsLoaded()") Exit Function Fail: Enhance_IsSupported = False End Function ...but while this works for Enhance_IsSupported() itself, the same error simply crops up elsewhere — like whack-a-mole at other instances of Greg.* — and only a manual edit will "refresh" those procedures. I would also prefer to avoid unstable calls to any .Evaluate() method, even in the Worksheet scope. Questions * What is the simplest way to "refresh" the Dev module, such that its procedures now recognize the calls to Greg.*? * Is this possible without resetting cached or Static variables in Dev? * Can this be done with an IS_LOADED constant rather than an IsLoaded() procedure? Bonus * Can this refreshment be done by some Sub like Dev.Refresh(), called automatically at the start of Enhance_IsSupported()? * Can this refreshment be done by some Sub like Greg.Refresh(), as run manually by the user in the VBA editor? --- This project represents a great investment of my time and energy, and it is otherwise operational, so your help is greatly appreciated in conquering this final obstacle!
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

16 September, 2023

Git Delta is a Syntax Highlighting Pager for git, diff, and grep output

 Programing Coderfunda     September 16, 2023     No comments   

Delta is a syntax highlighting tool for git, diff, and grep, with a rich feature set. The post Git Delta is a Syntax Highlighting Pager for git, diff, and grep output 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

15 September, 2023

Tablar: A Laravel Dashboard Preset

 Programing Coderfunda     September 15, 2023     No comments   

The Laravel Tablar Admin Dashboard Package is a beautiful, feature-rich admin dashboard Template using Laravel, Tabler, and Vite. The post Tablar: A Laravel Dashboard Preset 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

14 September, 2023

Laravel Resource Reducer: optimizes your API endpoint responses by returning what consumers need, defer execution and no more BIG FAT JSON 🐱‍🏍

 Programing Coderfunda     September 14, 2023     No comments   

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

13 September, 2023

Laravel Ecommerce with Lunar PHP

 Programing Coderfunda     September 13, 2023     No comments   

Lunar PHP is a Laravel e-commerce package, with an administrative hub, and a soon-to-be-released API The post Laravel Ecommerce with Lunar PHP 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

12 September, 2023

Final release of Laracon AU 2023 tickets now on sale!

 Programing Coderfunda     September 12, 2023     No comments   

A surge of excitement for the return of Laracon AU saw the initial ticket allocation exhausted right after the conference schedule was announced. The post Final release of Laracon AU 2023 tickets now on sale! 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

11 September, 2023

What does gensym do in Lisp?

 Programing Coderfunda     September 11, 2023     No comments   

I heard some of my classmates talking about how they used the function gensym for that, I asked them what it did and even checked up online but I literally can't understand what this function does neither why or when is best to use it. In particular, I'm more interested in what it does in Lisp. Thank you all.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

10 September, 2023

eloquent model column auto-complete

 Programing Coderfunda     September 10, 2023     No comments   

I'm working on a project where some models columns are kinda messy. I tend to forget their names. Any way to get column autocompletion while doing queries from the controller? btw I'm using vs code and I haven't had any luck finding a plugin with this feature, or one that actually works submitted by /u/mrdingopingo [link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

09 September, 2023

search bar causing infinite loop in React

 Programing Coderfunda     September 09, 2023     No comments   

Here's parent component: const Page = () => { const { user } = useAuth(); const router = useRouter(); const [allUsers, setAllUsers] = useState([]); const [search, useSearch] = useState(""); useEffect( () => { if (user !== null && user.isAdmin) { const token = localStorage.getItem("token"); api .get("/users", { headers: { authorization: `Bearer ${token}`, }, }) .then((data) => { setAllUsers(data.data); }) .catch((error) => { if (error.message === "Request failed with status code 401") { const refresh_token = localStorage.getItem("refresh_token"); const refresh = api .post("/auth/refresh", { refresh_token, }) .then((req) => { if (refresh.data.token && refresh.data.refresh_token) { localStorage.setItem("token", refresh.data.token); localStorage.setItem( "refresh_token", refresh.data.refresh_token ); api .get("/users", { headers: { authorization: `Bearer ${refresh.data.token}`, }, }) .then((req) => { setAllUsers(req.data); }); } }) .catch((error) => { if (error.message === "Request failed with status code 400") { if (error.response.data.message === "Refresh Token não encontrado." ) { router.push("/"); } } }); } }); } else if (!user) { router.push("/404"); } else { router.push("/auth/login"); } }, [user, router] ); useEffect( () => { const filterSearch = () => { if (search === "") return allUsers; return allUsers.filter((user) => user._id.includes(search)); }; const filtered = filterSearch(search); setAllUsers(filtered); }, [search, allUsers], search ); const useConsultasPagination = (data, page, rowsPerPage) => { return useMemo(() => { return applyPagination(data, page, rowsPerPage); }, [data, page, rowsPerPage]); }; const [page, setPage] = useState(0); const [rowsPerPage, setRowsPerPage] = useState(5); const keys = useConsultasPagination(allUsers, page, rowsPerPage); const handlePageChange = useCallback((event, value) => { setPage(value); }, []); const handleRowsPerPageChange = useCallback((event) => { setRowsPerPage(event.target.value); }, []); if (user !== null && user.isAdmin) { return ( Search | API Users ); } else { router.push("/404"); } } And here's search bar's component: export const UsersSearch = (props) => { const { setAllUsers = () => {}, allUsers = [], search = "", useSearch = () => {} } = props; const { user } = useAuth(); const router = useRouter(); const SetSearch = (value) => { useSearch(value); }; const HandleInputChange = (event) => { console.log('a') event.preventDefault(); const target = event.target; const value = target.value; if (value === "") { SetSearch("") } else { SetSearch(value); } }; if (user.isAdmin) { return ( ); } else { router.push("/404"); } }; The problem I'm facing is that, everytime a change the text in the search I get an infinite loop, although the search feature works (and when I remove all the text from the bar it doesn't comes back to the initial allUsers value). Help me please :) Changed the useEffect from causing another loop
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

08 September, 2023

Some AWS lamba execution have more than 1 S3event key

 Programing Coderfunda     September 08, 2023     No comments   

I'm having an issue when passing events to the AWS lambda function. I have to sync 60k data in 1 json file to a remote server. My solution is to divide the file into many small files (2000 data/ file) since the function cannot process 60k data in 15 minutes. After breaking the files, I will upload them one by one to S3 (time interval is 10 seconds), when a new file is uploaded, it will send a S3Event notification to trigger the function, and that function execution will take the newest uploaded file to process. The speed is impressive, but when the number of data reaches 60k, it does not stop, it continues adding more 4k items (I don't know where it came from). When I check the newest CloudWatch log, it seems there are some executions that have more than 1 S3Events like below "Records": [ { "eventVersion": "2.1", "eventSource": "aws:s3", "awsRegion": "ap-southeast-1", "eventTime": "2023-09-08T06:26:38.873Z", "eventName": "ObjectCreated:Put", "userIdentity": { "principalId": "AWS:AIDA4EODLYGLIMIHEIAVB" }, "object": { "key": "test_4.json", "size": 846900, "eTag": "44768b0689b2acd120c7683d8f0ce236", "sequencer": "0064FABE9E323A01CD" } } } ] "Records": [ { "eventVersion": "2.1", "eventSource": "aws:s3", "awsRegion": "ap-southeast-1", "eventTime": "2023-09-08T06:28:06.642Z", "eventName": "ObjectCreated:Put", "userIdentity": { "principalId": "AWS:AIDA4EODLYGLIMIHEIAVB" }, "object": { "key": "test_12.json", "size": 845141, "eTag": "05008d0d12413f98c3aefa101bbbd5eb", "sequencer": "0064FABEF5B003C033" } } } ] This is so weird, This is the 1st time I have worked with AWS so can someone help me explain the reason? Also, Is it possible to make all execution run synchronously instead of asynchronously? I think if they are running in order, it will be easily to debug then.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

LINQ Query returning an empty result

 Programing Coderfunda     September 08, 2023     No comments   

I am fairly new to LINQ and am having problems with a query. var LoadDetentionTypes = _db.Settings_DetentionTypes .Where(f => SchoolAreaList.Any(s => f.SchoolArea.Equals(s))) .Select(i => new { i.DetailsforDetentionToShow, i.DetentionTypeDescription, i.DetentionTypeCode }); SchoolAreaList is an array and holds say for example two values: BMS and BSS f.SchoolArea is a column in the database and can hold values in the format ["BMS", "BSS"] I am trying to do a query that will check if any of the values in the array are in the database and if there is a match it selects the record. The problem is that this query continually returns an empty result. Before using Equals, I used Contains, but I received an error. Am I trying to do too much in a single line and should I break it up with a ForEach on the array and add to a list? Any help would be much appreciated. Regards, Darren
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

06 September, 2023

bash: How to check if variable exists when set -eu option is set

 Programing Coderfunda     September 06, 2023     No comments   

In one of my prod script set -eu is set. In this script I want to check if variable exists but -v and -z option is not working. #!/bin/bash set -eu set -o pipefail INTERNAL="sdkhf" if [ -v $IINTERNAL ] then echo "variable doesnt exists" else echo "variable exists" fi output ./script.sh: line 7: IINTERNAL: unbound variable Is there a way to check for variable if it doesnt exist, dont go inside if loop.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

05 September, 2023

How to make C# connect only to an encrypted Access file

 Programing Coderfunda     September 05, 2023     No comments   

The problem is that it connects to the encrypted file by password, but if you decrypt the Access file, it still connects I did so, but anyway, if the file "File.accdb" is not encrypted, it connects "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\File.accdb;Jet OLEDB:Encrypt Database = True;Jet OLEDB:Database Password=12345"
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Pest Driven Laravel Course is now on Laracasts

 Programing Coderfunda     September 05, 2023     No comments   

Christoph Rumpel's Pest Driven Laravel course is now live on Laracasts and available to subscribers immediately. Learn about resources that can help get you started with Pest. The post Pest Driven Laravel Course is now on Laracasts 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

04 September, 2023

How to "copy the Oracle JDBC driver into sonarqube_extensions/jdbc-driver/oracle"?

 Programing Coderfunda     September 04, 2023     No comments   

I’m setting up Sonarqube according to Install the server and there I see a very strange instruction: a. Start the SonarQube container with the embedded H2 database: $ docker run --rm \ -p 9000:9000 \ -v sonarqube_extensions:/opt/sonarqube/extensions \ b. Exit once SonarQube has started properly. c. Copy the Oracle JDBC driver into sonarqube_extensions/jdbc-driver/oracle.** Where can I get JDBC driver and how to put it in sonarqube_extensions/jdbc-driver/oracle? Nothing. I don't know where to get JDBC driver and how to put it in sonarqube_extensions/jdbc-driver/oracle.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Call component method when service's signal updates

 Programing Coderfunda     September 04, 2023     No comments   

Let me preface this question with the fact that I started learning Angular about a month ago. Basically, I have a searchbar component and several different itemcontainer components (each of them displays a different type of item). In an attempt to have access to the serchbar value on any component, I created a searchbarService like so: import { Injectable, signal, WritableSignal } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class SearchBarService { searchTextSignal: WritableSignal = signal(''); setSearch(text: string): void{ this.searchTextSignal.set(text); } } The searchbar component calls the setSearch method on input submit. So far so good. Now, the problem comes when trying to work with searchTextSignal on the itemcontainter components. I'm trying to use it like this: import { Component, signal} from '@angular/core'; import { Factura } from 'src/app/interfaces/factura'; import { FacturaService } from 'src/app/services/factura.service'; //gets items from a placeholder array. import { SearchBarService } from 'src/app/services/search-bar.service'; @Component({ selector: 'vista-facturas', templateUrl: './vista-facturas.component.html', styleUrls: ['./vista-facturas.component.css'] }) export class VistaFacturasComponent { facturasArray: Factura[] = []; // has all items filteredFacturasArray = signal([]); // has all filtered items, and is the value that I want to get updated when the signal changes. constructor(private facturaService: FacturaService, public searchBarService: SearchBarService) { } getFacturas(): void { //initializes the arrays. this.facturaService.getFacturas().subscribe(facturasReturned => this.facturasArray = facturasReturned); this.filteredFacturasArray.set(this.facturasArray); } filterFacturas(): void{ // this method is likely the problem let text = this.searchBarService.searchTextSignal(); if (!text) this.filteredFacturasArray.set(this.facturasArray); this.filteredFacturasArray.set(this.facturasArray.filter(factura => factura?.numero.toString().includes(text))); } ngOnInit(): void { this.getFacturas(); } } The templace uses ngFor like so: So, everything boils down to how to make VistaFacturasComponent call filterFacturas() when searchBarService.searchTextSignal() updates. Any ideas?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

03 September, 2023

originalError: ConnectionError: Login failed for user 'userName' when connecting Node.js to SQL Server

 Programing Coderfunda     September 03, 2023     No comments   

I am trying to connect Node.js to SQL Server for the first time. I would greatly appreciate some help. This function makes the connection: import config from './dbconfig.js'; import mssql from 'mssql'; export async function getUsers() { try { let pool = await mssql.connect(config); let users = await pool.request().query('SELECT * from users'); return users.recordsets; } catch (error) { console.log(error); } } The config I am importing looks like this: const config = { user: 'userName', password: 'password', server: 'localhost', database: 'learningProgress', options: { trustedconnecion: true, enableArithAbort: true, instancename: 'DESKTOP-564IAGD\SQLEXPRESS', encrypt: true, trustServerCertificate: true, } port:55829 }; export default config; In place of userName and password I used my Windows user name and password, is that correct? In place of instancename I used DESKTOP-564IAGD\SQLEXPRESS, is this correct? How do I know what my port number is? When my port number is part of the config I get this error: ConnectionError: Failed to connect to localhost:55829 - Could not connect (sequence) code: 'ESOCKET' I tried running this SQL command: SELECT DISTINCT local_net_address, local_tcp_port FROM sys.dm_exec_connections; but I got null. I will mention that my SQL Server browser is running, and TCP/IP is enabled, IP Addresses - TCP port is set to 1433 (all of them). If I do not have port in the config this is my error regard the userName: Promise { } ConnectionError: Login failed for user 'userName'. code: 'ELOGIN', isTransient: undefined } }
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

02 September, 2023

Entity Framework Core: A second operation started on this context before a previous operation completed

 Programing Coderfunda     September 02, 2023     No comments   

I'm working on a ASP.Net Core 2.0 project using Entity Framework Core And in one of my list methods I'm getting this error: InvalidOperationException: A second operation started on this context before a previous operation completed. Any instance members are not guaranteed to be thread safe. Microsoft.EntityFrameworkCore.Internal.ConcurrencyDetector.EnterCriticalSection() This is my method: [HttpGet("{currentPage}/{pageSize}/")] [HttpGet("{currentPage}/{pageSize}/{search}")] public ListResponseVM GetClients([FromRoute] int currentPage, int pageSize, string search) { var resp = new ListResponseVM(); var items = _context.Clients .Include(i => i.Contacts) .Include(i => i.Addresses) .Include("ClientObjectives.Objective") .Include(i => i.Urls) .Include(i => i.Users) .Where(p => string.IsNullOrEmpty(search) || p.CompanyName.Contains(search)) .OrderBy(p => p.CompanyName) .ToPagedList(pageSize, currentPage); resp.NumberOfPages = items.TotalPage; foreach (var item in items) { var client = _mapper.Map(item); client.Addresses = new List(); foreach (var addr in item.Addresses) { var address = _mapper.Map(addr); address.CountryCode = addr.CountryId; client.Addresses.Add(address); } client.Contacts = item.Contacts.Select(p => _mapper.Map(p)).ToList(); client.Urls = item.Urls.Select(p => _mapper.Map(p)).ToList(); client.Objectives = item.Objectives.Select(p => _mapper.Map(p)).ToList(); resp.Items.Add(client); } return resp; } I'm a bit lost especially because it works when I run it locally, but when I deploy to my staging server (IIS 8.5) it gets me this error and it was working normally. The error started to appear after I increase the max length of one of my models. I also updated the max length of the corresponding View Model. And there are many other list methods that are very similar and they are working. I had a Hangfire job running, but this job doesn't use the same entity. That's all I can think to be relevant. Any ideas of what could be causing this?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

01 September, 2023

MJML to HTML using PHP

 Programing Coderfunda     September 01, 2023     No comments   

MJML is a markup language designed to reduce the pain of writing responsive email templates. Using this package, you can convert MJML to HTML. The post MJML to HTML using PHP appeared first on Laravel News. Join the Laravel Newsletter to get Laravel articles like this directly in your inbox. ---
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

31 August, 2023

Taking mean of consequitive non NA values in data table in R

 Programing Coderfunda     August 31, 2023     No comments   

For the below data table library(data.table) test = data.table(date = c("2006-01-31", "2006-03-20", "2006-03-28", "2006-05-03", "2006-05-04", "2006-06-29", "2006-09-11"), value = c(NA, -0.028, NA, 0.0245, -0.008, NA, -0.009)) I need the mean of consequitive Non NA values as a separate column in the above data table. For eg, the resultant data table would look like this library(data.table) test = data.table(date = c("2006-01-31", "2006-03-20", "2006-03-28", "2006-05-03","2006-05-04", "2006-06-29", "2006-09-11"), value = c(NA, -0.028, NA, 0.0245, -0.008, NA, -0.009), value_new = c(NA, -0.028, NA,0.008, 0.008, NA, -0.009)) Tried doing this using rle and data table functions but not getting the correct output. Thanks in advance
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How to group json objects by using keys of sub value objects using jq

 Programing Coderfunda     August 31, 2023     No comments   

I have a json file in the format { "hello": [ { "name": "var1", "value": "1234" }, { "name": "var2", "value": "2356" }, { "name": "var3", "value": "2356" } ], "hi": [ { "name": "var1", "value": "3412" }, { "name": "var2", "value": "2563" }, { "name": "var3", "value": "4256" } ], "bye": [ { "name": "var1", "value": "1294" }, { "name": "var2", "value": "8356" }, { "name": "var3", "value": "5356" } ] } I want to convert this object into this format { "output": [ { "var1": { "hello": "1234", "hi": "3412", "bye": "1294" } }, { "var2": { "hello": "2356", "hi": "2563", "bye": "8356" } }, { "var3": { "hello": "2356", "hi": "4256", "bye": "5356" } } ] } so far i've tried multiple ways using to_entries and map functions in jq to create the contents inside the output variable jq 'to_entries | map(.value[]| . += {"key_v" : (.key)} )' input.json > output.json this is the closest i came to a solution * extracting keys and add to the key value pair of the object * use map(select()) to group by keys but i am getting errors in both the steps such as cannot index array with string name or string value.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

30 August, 2023

Generate Saloon SDKs from Postman or OpenAPI

 Programing Coderfunda     August 30, 2023     No comments   

The Saloon SDK generator package for Saloon will help you generate SDKs from Postman collections and OpenAPI specifications. The post Generate Saloon SDKs from Postman or OpenAPI 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

29 August, 2023

Laravel Ajax Cross-Origin Request Blocked ?

 Programing Coderfunda     August 29, 2023     Ajax, Laravel     No comments   

 

You can enable CORS in Laravel by adding the following code to the app/Http/Middleware/VerifyCsrfToken.php file:

protected $addHttpCookie = true;

protected $except = [

'/*'

];

This code tells Laravel to exclude all routes from CSRF protection, allowing cross-origin requests to be made without being blocked.

You can also use this Alternatively way.

Step 1: Install Compose Package

Alternatively, you can install the barryvdh/laravel-cors package using Composer to enable CORS in your Laravel application. This package provides a middleware that you can add to your Laravel application to allow cross-origin requests. Here are the steps to install and use the package:

Install the package using Composer:

composer require barryvdh/laravel-cors

Step 2: Add Middleware

Add the following code to the $middleware array in the app/Http/Kernel.php file:

\Barryvdh\Cors\HandleCors::class

Step 2: Configure CORS

Add the following code to the config/cors.php file to specify the domains that are allowed to make cross-origin requests:


'allowed_origins' => [

'*',

],

'allowed_methods' => [

'POST',

'GET',

'OPTIONS',

'PUT',

'PATCH',

'DELETE',

],

'allowed_headers' => [

'Content-Type',

'X-Requested-With',

'Authorization',

],

With these steps,

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

How to push a docker image to a local registry from job container?

 Programing Coderfunda     August 29, 2023     No comments   

I'm using docker executor with DinD in Gitlab CI, and I have a local registry container running in the host machine. I want to push an image that is being built in the job container to the local registry container running in the host machine. Normally what would you do if pushing from the host computer is pushing to the localhost at the port of the registry container. Like this: docker push localhost:5000/my-ubuntu but since I'm pushing from the job container I don't know how to do this. I tried with the host computer ip: docker push some_ip_address:5000/my-ubuntu but I got: The push refers to repository [some_ip_address:5000/my-ubuntu] Get "
https://some_ip_address:5000/v2/": http: server gave HTTP response to HTTPS client and the job failed...
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

28 August, 2023

Laravel Nova CSV Import v0.7 - Password Hashing, Random Strings and Combined Fields

 Programing Coderfunda     August 28, 2023     No comments   

I've been putting a load of effort into my Nova package lately and it's paying off with some cool new features that I released a few days ago. Here's a video running through the basics of each. Hope you find them useful! Password Hashing Being able to use password hashing algos on data as it's imported is something I don't see in a lot of CSV import tools and always something I thought would be really useful on rare occasions, so here it is in Nova CSV Import Random String Generation If using pre-existing is just not enough, now you can generate random strings on-the-fly! Great when combined with Password Hashing as it allows you to very securely create bundles of user records from a CSV import without any concerns over passwords being discovered Combined Fields The last thing you want to do with CSVs is be manually editing them before importing. I think every ETL process should have a way to merge data from multiple fields into one. CSV Import now lets you do this with ease and flexibility! submitted by /u/simonhamp [link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

27 August, 2023

Flutter Web: Loading data from URL fails

 Programing Coderfunda     August 27, 2023     No comments   

When trying to fetch image data inside a custom ImageProvider from an URL, I get an error: ClientException: XMLHttpRequest error., uri=
https:///api/v1/images//thumbnail-squared The host however has CORS enabled and returns a header "access-control-allow-origin" -> "*". The URL redirects a 302 to a signed google cloud storage file however. Might this be the issue?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

26 August, 2023

Fallback route vs Exception handler for handling otherwise undefined routes/pages

 Programing Coderfunda     August 26, 2023     No comments   

I have an existing application that I'm looking to incorporate Laravel Folio into. I've come across something of a conflict between Folio and the existing routes in my application that has led me to consider what is the "best" way to handle requests for pages without a specific route definition. My application already has a fallback route defined. In my application I use the fallback route to allow for links to promo/discount codes that are applied to purchases a user makes so that requests like
https://mysite.com/MySuperGreatDiscountCode will automatically apply the code to the user's cart. It is also used to allow admin users of the application to be able to create random pages in our headless CMS without having to specifically define routes to those pages. The way Folio seems to work is that it also defines a fallback route that kicks off its route resolution process. What I'm currently experiencing is that Folio's fallback route is never called, and my already existing one handles the requests. When I remove my existing fallback route, Folio starts working as expected, but, as you've guessed, I lose the ability to have requests that point to a code or a CMS page. In trying to get Folio to play nice with my application I've been looking at different ways for handling requests for discount codes or pages that only exist in the CMS. My first thought was to use a middleware that would look for a 404 status code on the response, and if one is found, it would execute the logic to see if the request was for a discount code or a CMS page and return the appropriate response. However I couldn't get this to work because it seems the Laravel Exception handler "short circuits" the middleware stack when an exception is thrown/rendered. My IsItA404Response middleware was never being called when a NotFoundHttpException was being thrown. This lead me to move the discount code/cms page resolution logic to the Exception Handler's render method. This is working, but it seems a bit "hacky" to me. I'm curious to know what everyone thinks of using the Exception Handler in this way or if you have a better idea of how to handle this. submitted by /u/adear11 [link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

25 August, 2023

My express react App keeps on giving me the error that It cannot find my api

 Programing Coderfunda     August 25, 2023     No comments   

I am building a React + express website which allows users to make webProjects. It displays these projects in a table. The user is able to add, and edit the web projects. I am adding a function which allows the user to delete an item by pressing the delete button next to the items. My function works in Postman but I cant get it to work when I press the button in the frontend TableData.js import React, {useState, useEffect} from 'react' export const TableData = ({ projectData, fillInput, setContent, selectedProject }) => { console.log(projectData) const [deleteID, setDeleteID] = useState(""); useEffect(() => { if (selectedProject) { setDeleteID(selectedProject.ID); console.log(selectedProject) } }, [selectedProject]) //This is a function which deals with deleting a webProject const deleteItem = (projectId) => { fetch("/api/delete", { method: "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id: projectId }) // ID to delete }) .then((response) => response.json()) .then((updatedProjects) => { console.log(updatedProjects); setContent({ projectData: updatedProjects }); // This Code for update the state }) } return ( My Projects ID Title Description URL {projectData.map((projectData, index) => ( {projectData.ID} {projectData.TITLE} {projectData.DESCRIPTION} {projectData.URL} fillInput(projectData)}>edit deleteItem(projectData.ID)}>Delete ))} ) } App.js import React, { useEffect, useState } from 'react' import { TableData } from './components/TableData' import FormData from './components/FormData' function App() { const [content, setContent] = useState({ webProjects: []}); const [selectedProject, setSelectedProject] = useState(null); useEffect(() => { fetch("/api", { method: "GET", headers: { "Content-type": "application/json", } }).then((response) => response.json() ).then((response) => {setContent(response)} ) }, []) const fillInput = (project) => { setSelectedProject(project) } const fillInputId = (project) => { setSelectedProject(project.ID) } return ( {/* The props are sent to provide the FormData component with information about the currently selected project which will be used when editing a project. */} ) } export default App server.js app.delete("/api/delete", (req, res) => { const projectId = parseInt(req.body.id); const projectIndex = webProjects.findIndex(project => project.ID === projectId); if (projectIndex === -1) { return res.status(404).send("Project not found"); } webProjects.splice(projectIndex,1); //res.send(`The item was successfully deleted`) res.send(webProjects); })
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

24 August, 2023

Laravel 10.20 Released

 Programing Coderfunda     August 24, 2023     No comments   

This week, the Laravel team released v10.20 with a createOrFirst() method, benchmark a single callable, a new response JSON assertion, and more: The post Laravel 10.20 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
Newer Posts Older Posts Home

Meta

Popular Posts

  • Write API Integrations in Laravel and PHP Projects with Saloon
    Write API Integrations in Laravel and PHP Projects with Saloon Saloon  is a Laravel/PHP package that allows you to write your API integratio...
  • Features CodeIgniter
    Features CodeIgniter There is a great demand for the CodeIgniter framework in PHP developers because of its features and multiple advan...
  • Laravel Breeze with PrimeVue v4
    This is an follow up to my previous post about a "starter kit" I created with Laravel and PrimeVue components. The project has b...
  • Credit card validation in laravel
      Validation rules for credit card using laravel-validation-rules/credit-card package in laravel Install package laravel-validation-rules/cr...
  • Fast Excel Package for Laravel
      Fast Excel is a Laravel package for importing and exporting spreadsheets. It provides an elegant wrapper around Spout —a PHP package to ...

Categories

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

Social Media Links

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

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

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

Loading...

Laravel News

Loading...

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