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

13 October, 2023

How do you handle small actions?

 Programing Coderfunda     October 13, 2023     No comments   

If you have a pretty basic web app, you will probably have only CRUD. However, as things start to get bigger, you might have a lot of components and each component might have a lot of actions.

For exemple, a blog post might have a "Publish" button. But you might want to "Unpublish". And then you might want to just update the publication date.

I feel like it starts to get cumbersome if you have to create a route for each small action. In Livewire, this isn't an issue because of the way components work. But in Inertia, I have close to 100 controllers, most being small actions like publishing and unpublishing.

What is the best way to organize these small actions? submitted by /u/AsteroidSnowsuit
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Since when did Laravel fill ONLY database fields into a Model?

 Programing Coderfunda     October 13, 2023     No comments   

I recently upgraded a Laravel application and came across some strange bugs. It turns out, the fill() method on models doesn't fill all fields anymore!

Yes, I'm aware of the $fillable and $guarded properties. In my model I don't have fillable set and have guarded set to ['id', 'created_at', 'updated_at']. So it should fill any properties except those three. In the past this worked fine, but now it only fills the fields that explicitly exist in the database. Laravel even runs a separate query to get those fields.

In my case, I had a "location" field with a dropdown and an "other" option to write in freetext. So the form would come with location=other and location_other=customtext. The DB would store "customtext" in the location field. But I can't fill the model and then copy "location_other" over, because the latter doesn't get filled.

When did this change? I never saw this listed anywhere in the documentation. submitted by /u/Disgruntled__Goat
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

12 October, 2023

Compiler Not Recognized (GCC for Visual Studio Code)

 Programing Coderfunda     October 12, 2023     No comments   

Despite installing the compiler and adding the path to my user environment variable path, the compiler isn't recognized when I test it by checking the version through terminal on VS or command prompt.








For some reason, the path changes from C:/msys64/ucrt64/bin/ to C:/msys64/mingw64/bin/ after I reopen it.


File location on computer (path that was added to environment variable)





Compiler not recognized


Edit: Everything above has been resolved, the commands now all work when I put them into the MSYS2 terminal. However, I'm still having issues when I type g++ or any other commands into the VS terminal. I've attached another screenshot below.


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

11 October, 2023

Laravel Breeze with Volt Functional API

 Programing Coderfunda     October 11, 2023     No comments   

---



The Laravel team released the Livewire + Volt functional stack for Breeze. This increases the Breeze offering to six stack variations, offering a tremendous amount of freedom to stacks that are emerging in the Laravel ecosystem:



* Laravel Blade

* Livewire with Volt Class API

* Livewire with Volt Functional API

* Inertia (React)

* Inertia (Vue)

* API-only






Getting Started with a New Project




If you want to install the Breeze + Volt functional API while creating a new Laravel project, all in one go, you can run the following:
laravel new --pest --breeze --git --dark \
--stack=livewire-functional \
breeze-functional-demo



Note: at the time of writing, the installer doesn't support livewire-functional unless you require dev-master. Likely, you can wait for the installer to get a release, or you can run
# Normal update once the release is created
composer global update laravel/installer -W

# For the impatient
composer global require laravel/installer:dev-master -W



If you prefer to install after-the-fact, you can run the following:
laravel new example-project
cd example-project
composer require laravel/breeze
php artisan breeze:install



Then you can follow the prompts to select the stack, include dark mode support, and pick the test suite (Pest or PHPUnit):





Learn More




If you'd like to get started with Laravel Volt, Jason Beggs wrote a tutorial on Laravel News to Learn Livewire 3, Volt, and Folio by building a podcast player. Also, check out the Volt Livewire documentation for more details.



The post Laravel Breeze with Volt Functional API 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

10 October, 2023

R - In a for loop iterating through columns df[[i]] if a data frame, how do I print the name of column df[[i]] for each loop?

 Programing Coderfunda     October 10, 2023     No comments   

I'm trying to use a for-loop to iterate through the columns of a data frame, and for each loop print out the name of the column on each loop before the operation is performed (namely checking if there are missing values for that column).


I have tried all I can think of, but haven't had any luck so far.


This was my best guess, but it just returns NULL for the column name (I'm guessing because once I've extracted the data of the column it's already a nameless vector?).
for (i in seq_along(df)) {
# Print column name
print(colnames(df[[i]]))
# Print sum of missing values for each column
print(sum(is.na(df[[i]])))
# Print NA value rows
}



Output is as follows:
NULL
[1] 70
NULL
[1] 0
NULL
[1] 0
NULL
[1] 0
NULL



What can I do to print the column name for each pass?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

09 October, 2023

AWS Glue Python Shell Upgrade Boto3 Library without Internet Access

 Programing Coderfunda     October 09, 2023     No comments   

I need to use a newer boto3 package for an AWS Glue Python3 shell job (Glue Version: 1.0).


The default version is very old and hence all the API's does not work


For eg pause_cluster() and resume_cluster() does not work in AWS Glue Python Shell due to this older version



https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/redshift.html />

Similarly for many other product features.


Additionally, we don't have to Glue internet access by security and hence need a solution based on s3 storage libraries


Which is the best way to upgrade the Python Shell as it seems the lightest weight part of our architecture


Basically, we are using python glue shell as our core workflow engine to asynchronously deisgn our pipeline through boto3 apis
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

08 October, 2023

compact(): Undefined variable $pesanan_details

 Programing Coderfunda     October 08, 2023     No comments   

My error


compact(): Undefined variable $pesanan_details


Line 138 experienced an error and a red notification on that line
return view('checkout.check_out', compact('pesanan','pesanan_details'));



Controller controller/PesananController

@foreach ($pesanan_details as $pesanan_detail )


{{ $no++ }}

{{ $pesanan_detail->post->title }}

{{ $pesanan_detail->jumlah }} Style

Rp. {{ number_format($pesanan_detail->post->harga) }}

Rp. {{ $pesanan_detail->jumlah_harga }}



@csrf
{{ method_field('DELETE') }}





@endforeach


Total Harga :

Rp. {{ number_format($pesanan->jumlah_harga) }}



Check Out








@endif



{{-- Kembali --}}
Kembali






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

How to create a customized Error using TypeScript and node.js?

 Programing Coderfunda     October 08, 2023     No comments   

I am new to TypeScript and now working on a personal project, developing an API using TypeScript + node.js + Express.
What I want to do is to create a customized Error that contains some extra properties over the built-in Error. For instance, to handle an inexsitent url/endpoint, I implemented the middleware as
const app = express();
//... skip some imports and basic middlewares
app.use("/api/v1/events", eventRouter);
app.use("/api/v1/users", userRouter);

interface IError extends Error {
status: string;
statusCode: number;
}

app.all("*", (req: Request, res: Response, next: NextFunction) => {
const err = new Error(`Can't find ${req.originalUrl}.`);
(err as any).status = "fail";
(err as any).statusCode = 404;
next(err);
});

app.use((err: IError, req: Request, res: Response, next: NextFunction) => {
err.statusCode = err.statusCode || 500;
err.name;
err.status = err.status || "error";
res.status(err.statusCode).json({
status: err.status,
message: err.message,
});
});



I had to cast err to type any because it would raise an error when I added the properties status and statusCode to err since type Error doesn't include these two properties. I am not sure if this is a good practice because I know it is not recommanded to declare or cast a variable to any, which actually is against the purpose of TypeScipt.
Are there any better solutions to it?


I had to cast err to type any because it would raise an error when I added the properties status and statusCode to err since type Error doesn't include these two properties. I am not sure if this is a good practice because I know it is not recommanded to declare or cast a variable to any, which actually is against the purpose of TypeScipt.
Are there any better solutions to it?
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

07 October, 2023

Manage a User's Browser Sessions in Laravel

 Programing Coderfunda     October 07, 2023     No comments   

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

06 October, 2023

Reshape data from wide to long (Creating Panel Data)

 Programing Coderfunda     October 06, 2023     No comments   

I downloaded data from data stream Refinitiv. The data is in wide format which resulted in too many variables (761). I only want to form 8 variables.


How can I do that in Stata?


enter image description here


I wrote this syntax
reshape long Date variable, i(date) j(UVBKP, PCHUVBKP1D, UVBKPA, UVBKPB, UVBKTNA, UVBKNAV, UVBKPH, UVBKPL)



but I don't know why it says
variable date not found
```
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Configure and Display a Schedule of Opening Hours in PHP

 Programing Coderfunda     October 06, 2023     No comments   

---



Opening Hours is a PHP package by Spatie to query and format a set of business operating hours. You can use it to present the times per day and include exceptions for things like holidays and other days off on a given year-specific date or recurring (happening each year). The project's readme file has this example to illustrate how you can configure hours:
$openingHours = OpeningHours::create([
'monday' => ['09:00-12:00', '13:00-18:00'],
'tuesday' => ['09:00-12:00', '13:00-18:00'],
'wednesday' => ['09:00-12:00'],
'thursday' => ['09:00-12:00', '13:00-18:00'],
'friday' => ['09:00-12:00', '13:00-20:00'],
'saturday' => ['09:00-12:00', '13:00-16:00'],
'sunday' => [],
'exceptions' => [
'2016-11-11' => ['09:00-12:00'],
'2016-12-25' => [],
'01-01' => [], // Recurring on each 1st of January
'12-25' => ['09:00-12:00'], // Recurring on each 25th of December
],
]);

// This will allow you to display things like:

$now = new DateTime('now');
$range = $openingHours->currentOpenRange($now);

if ($range) {
echo "It's open since ".$range->start()."\n";
echo "It will close at ".$range->end()."\n";
} else {
echo "It's closed since ".$openingHours->previousClose($now)->format('l H:i')."\n";
echo "It will re-open at ".$openingHours->nextOpen($now)->format('l H:i')."\n";
}




This package has tons of configuration options and can be used on any PHP project without any dependencies. While this package isn't a brand-new Spatie package, we've never covered it and think you should check it out! You can get setup instructions and see more API examples on GitHub at spatie/opening-hours.


If you'd like to learn more background information on why this package as created, Freek Van der Herten originally wrote about it on his blog: Managing opening hours with PHP.



The post Configure and Display a Schedule of Opening Hours in 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

05 October, 2023

searching a list in a list model in flutter

 Programing Coderfunda     October 05, 2023     No comments   

I have been working on a LLM-like very simple project in Flutter. I need to find a string list, for example "what is my lecture score" in a list data. But the order doesn't matter.
If my search finds the "what", "is", "my", "lecture", "score" in one of the sentence list in any order, the result will be true, otherwise false.


Here is my sentence list as a List:
class vaModel {
final int id;
final List stringData;
final String response;

vaModel({
required this.id,
required this.stringData,
required this.response,
});
}



and here is the data of this model:
import "package:flut2deneme/pages/vaModel.dart";

List vaData = [
vaModel(id: 1, stringData: ["what", "my", "score", "lecture"], response: "load1"),
vaModel(id: 2, stringData: ["total", "lectures", "hours", "week"], response: "load2"),
vaModel(id: 3, stringData: ["how", "much", "cost"], response: "load3"),
//other
];



for example, if the user enters "what my score is for this lecture", it will return "load1" in id:1 in the vaData list. Because however the order is different and it has more other words, the desired words (what, my, score, lecture) are found in the data list. As seen, there are other words in the received sentence and the words are not in given order, the result is true, since all required words exist in item 1 (id:1)


It may also be explained in searching a list in a list of List.


Thank you for any support.
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel 10.26 Released

 Programing Coderfunda     October 05, 2023     No comments   

---



This week, the Laravel team released v10.26 with a search feature for the Artisan vendor:publish command, array cache expiry updates, more.


This week was a smaller release, but we get an excellent vendor:publish update that makes finding providers and tags a breeze! Laravel also saw some fixes and a few reverts leading us to Laravel 10.26.2. Thanks again for all the contributions from the Laravel team and the community!


Allow Searching on the vendor:publish prompt




Jess Archer contributed filtering the vendor:publish command to quickly search for providers and tags that you would like to publish. You can also select all providers and tags from the dropdown:





Ensure array cache considers milliseconds




In Laravel 10.25, Tim MacDonald contributed an update to ensure that array cache driver values expire at the expiry time; however, there were some testing issues around this update (which was reverted) and now in larval 10.26, those issues are all sorted. We would encourage you to update to the latest Laravel 10.26 version if you noticed any array cache driver flakiness, and thank you to Tim MacDonald for sorting it all out!


See Pull Request #48573 if you're interested in the updates made around that driver to ensure it honors expiry time.


Release notes




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


v10.26.2






* Revert "Hint query builder closures (#48562)" by @taylorotwell in
https://github.com/laravel/framework/pull/48620 />





v10.26.1






* [10.x] Fix selection of vendor files after searching by @jessarcher in
https://github.com/laravel/framework/pull/48619 />





v10.26.0






* [10.x] Convert Expression to string for from in having subqueries by @ikari7789 in
https://github.com/laravel/framework/pull/48525 />

* [10.x] Allow searching on vendor:publish prompt by @jessarcher in
https://github.com/laravel/framework/pull/48586 />

* [10.x] Enhance Test Coverage for Macroable Trait by @salehhashemi1992 in
https://github.com/laravel/framework/pull/48583 />

* [10.x] Add new SQL error messages by @magnusvin in
https://github.com/laravel/framework/pull/48601 />

* [10.x] Ensure array cache considers milliseconds by @timacdonald in
https://github.com/laravel/framework/pull/48573 />

* [10.x] Prevent session:table command from creating duplicates by @jessarcher in
https://github.com/laravel/framework/pull/48602 />

* [10.x] Handle expiration in seconds by @timacdonald in
https://github.com/laravel/framework/pull/48600 />

* [10.x] Avoid duplicate code for create table commands by extending new Illuminate\Console\MigrationGeneratorCommand by @crynobone in
https://github.com/laravel/framework/pull/48603 />

* [10.x] Add Closure Type Hinting for Query Builders by @AJenbo in
https://github.com/laravel/framework/pull/48562 />






The post Laravel 10.26 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

Why I choose Inertia over Livewire

 Programing Coderfunda     October 05, 2023     No comments   

Hi, back when Livewire was first announced I gave it a try. I was excited, but I felt like the way it's hydrated doesn't fulfill my needs. Then I found Inertia and got excited again. Even tho it doesn't allow me to use Laravel's helpers I feel like I have full control and that's what I need.

Now that Livewire v3 came about, it looks much better and I had to try it again, to see if I could use it for my future projects. Wire:navigate is so amazing, but I just tested the very thing that made me leave the first time.

If it's a skill issue on my part, well, I'm a fool, will eat my critique and be happy that I was using Livewire wrong and can start using it properly now.

Let me demonstrate:

Model: class File extends Model { protected $appends = ['rand']; protected $fillable = ['name']; public function getRandAttribute() { return rand(1, 100); } }

Livewire Component: class Test extends Component { public $count = 1; // public $files = []; public function mount() { // $this->files = File::all(); } public function do() { $this->count++; } public function render() { return view('livewire.test')->with([ 'files' => File::all(), ]); } }

Livewire Blade: {{ $count }} @foreach ($files as $file) {{ $file->name }} {{ $file->rand }} @endforeach

I tested both commented and `with()` options, but both had same result. On every click, which only increases the count, the `rand` value changed.

Now you might see what's my problem. If the rand attribute was s3 file getter, I'm paying for every rerender.


https://i.redd.it/46gzkg08t5sb1.gif

So, is this doable in Livewire with different approach, or does it have to be like this? submitted by /u/narrei
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

04 October, 2023

I want to have the Fibonacci sequence returned with commas between the numbers

 Programing Coderfunda     October 04, 2023     No comments   

def get_fibonacci_sequence(num: int) -> str:
'''
Function to return string with fibonacci sequence

>>> get_fibonacci_sequence(0)
''
>>> get_fibonacci_sequence(1)
'0'
>>> get_fibonacci_sequence(9)
'0,1,1,2,3,5,8,13,21'
'''

first_term = 0
second_term = 1
nth_term = 0
result = ''

for sequence in range(num):
result += str(first_term)
nth_term = first_term + second_term
first_term = second_term
second_term = nth_term
return(result)



I tried adding (+ ',') in the loop where I convert the numbers to a string and it works but not the way I want it to.


'0,1,1,2,3,5,8,13,21,'


I want to get rid of the comma after 21
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

03 October, 2023

Unfinalize tool

 Programing Coderfunda     October 03, 2023     No comments   


https://laravel-news.com/unfinalize

​

I think this tool is useful either for poorly designed libraries or for users who aren't fully aware of the library's capabilities.

What are your thoughts? submitted by /u/leoshina
[link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

02 October, 2023

Error when calling a function having a record with float fields as an arg using `function:call` method

 Programing Coderfunda     October 02, 2023     No comments   

isolated function mockFunction(record {|string operation; float operand1; float operand2;|} input) returns string{
return "mockFunction scuccessful";
}

public function main() returns error? {
string input = "{\"operation\":\"ADDITION\",\"operand1\":23.0,\"operand2\":43.0}";
map & readonly inputJson = check input.fromJsonStringWithType();
any|error observation = function:call(mockFunction, inputJson);
io:println(observation);
}



I got the following error when I tried the above.
error: {ballerina/lang.function}IncompatibleArguments {"message":"arguments of incompatible types: argument list '(map & readonly)' cannot be passed to function expecting parameter list '(ai.agent:record {| string operation; float operand1; float operand2; |})'"}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

01 October, 2023

MariaDB Encryption at rest - provide key from app

 Programing Coderfunda     October 01, 2023     No comments   

In the past, I use Sybase anywhere db as my db server. I can encrypt the whole db with password, and from my application, i provide password inside connection string to gain access to server.


I want to use the same / similar scenario with mariaDB.


Suppose i have mariadb with encryption at rest.


1- can i provide key from my application directly?


or build wcf service that mariadb call to get the key it needs when starting


2- can i prevent resetting admin password on encrypted db?


3- Is there any other dbs that support this scenario ?


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

30 September, 2023

HTTP Error 500.0 - ASP.NET Core IIS hosting failure

 Programing Coderfunda     September 30, 2023     No comments   

I got this error while testing my new website Locally on IIS Express on .NET5


I have checked that i have the required dotnet version , adding the dotnet paths to the system environment variables and Restarted the visual studio
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

29 September, 2023

Already has more than 'max_user_connections' active connections cpanel in Laravel - PHP

 Programing Coderfunda     September 29, 2023     No comments   

 This is Root Cpanel

1 


 After Hit Button Enter then Show This page



 

Change  the max connection value according you like 50 or 100 or 5000 


 

 


2

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

Form Request Tester Package for Laravel

 Programing Coderfunda     September 29, 2023     No comments   

The Laravel Form Request Tester package is a collection of helpers that help test form requests.


The post Form Request Tester Package for Laravel 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

28 September, 2023

Livewire v3: Modelable, Events, and Data Sharing

 Programing Coderfunda     September 28, 2023     No comments   

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

27 September, 2023

Solved max_user_connections in laravel

 Programing Coderfunda     September 27, 2023     Laravel     No comments   

 

max_user_connections and other problems!!

Go the Config folder then open database then change only options after your problem will be solved

/abc/config/database.php

abc = is a folder name where you install the laravel 
'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            //'strict' => true,
            'strict' => false,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                // PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
                PDO::ATTR_PERSISTENT => false
            ]) : [],
        ],

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

How do I create a lexical dispersion plot in pyspark with seaborn?

 Programing Coderfunda     September 27, 2023     No comments   

I'm trying to make a lexical dispersion plot that maps out when words in a certain 'top ten' list are used over time through a column of strings in a Pysparks data frame (another column has their relevant dates).


I've got my dataframe at the moment with the texts, their dates, and the words used in each.


my dataframe


As it is, my plot has a row for each individual text with a list of the words in it, when what I'm after is a row for each key word, mapping the instances in which it appears in texts over time...


This is the kind of thing I'm after, vs what I'm getting...


the type of thing I'm after


how my plot is coming out


Here's a function which I use to return words from my list which are present in a given description:
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
from pyspark.sql.functions import split, udf

top_ten = [row['word'] for row in top_ten_words]

punctuation = ',?!./\#@"[]'

@udf
def top_ten_list(description):
'''
function to return the key words which are present in a certain description string
'''
list_of_words = description.split(" ")
out_data = []

for word in list_of_words:
word = word.lower()
if word.strip(punctuation) in top_ten:
out_data.append(word)
else:
pass

return str(out_data)




I then run that function on my column with the following:
descriptions_with_top10 = descriptions_by_date.withColumn('top_tenners', top_ten_list(descriptions_by_date.description))



Here's my code so far to make my plot. I know I need something different in the y-axis but I'm just not sure how to word it so as to get what I'm after...
# make df into pandas df to plot with seaborn
top_ten_words_in_descriptions_df = descriptions_with_top10.toPandas()

# plot dispersion plot
top_ten_plot = sns.stripplot(data = top_ten_words_in_descriptions_df, x = "published_date", y = "top_tenners", orient='h', marker='X', color='navy', size=3)

# rotate x tick labels
plt.xticks(rotation=15)

# remove borders of plot
plt.tight_layout()

plt.show()




I want it to have each word just once in the y-axis, as in this image: enter image description here, with each keyword just once, with all its occurrences marked, rather than the list of keywords for each description string.


I hope that makes some sense to someone; any help would be very welcome :)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

26 September, 2023

Laravel Bootcamp now has a Livewire track

 Programing Coderfunda     September 26, 2023     No comments   

Laravel Bootcamp, the choose your adventure, style learning site, added support for Laravel Livewire.


The post Laravel Bootcamp now has a Livewire track 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

25 September, 2023

oracle developer_ importing different forms of date in one column

 Programing Coderfunda     September 25, 2023     No comments   

I am trying to import the date columns with different types of date format. table name: fD column name: TRANS_DATE_TRANS_TIME this column has two forms of the date like below. date type1: 'MM/DD/YYYY HH24:MI' date type2: 'YYYY-MM-DD HH24:MI:SS' not surprisingly, SQL developer(oracle) cannot import this column as a DATE type. I aim to unify these forms as 'MM/DD/YYYY HH24:MI.' What I did was I import it as a VARCHAR2 type and try to write very complicate and difficult(?) query... and then I read someone wrote here that do not import date type data as a VARCHAR2 because of this. Then, is there any idea that I can import this column successfully? or I need to import it as a VARCHAR2 type and write down complicate query? (and I do not know this query either.. haha) this is what I did when I imported it as a VARCHAR2. ''' with DT as( select TRANS_DATE_TRANS_TIME from fD ) select TRANS_DATE_TRANS_TIME, replace(to_char(to_date(TRANS_DATE_TRANS_TIME, case when regexp_like(TRANS_DATE_TRANS_TIME,'[0-9]{1}/[0-9]{1}/[0-9]{4} [0-9]{1}:[0-9]{2}') then 'MM/DD/YYYY HH24:MI' when regexp_like(TRANS_DATE_TRANS_TIME,'[0-9]{2}/[0-9]{1}/[0-9]{4} [0-9]{1}:[0-9]{2}') then 'MM/DD/YYYY HH24:MI' when regexp_like(TRANS_DATE_TRANS_TIME,'[0-9]{1}/[0-9]{2}/[0-9]{4} [0-9]{1}:[0-9]{2}') then 'MM/DD/YYYY HH24:MI' when regexp_like(TRANS_DATE_TRANS_TIME,'[0-9]{1}/[0-9]{1}/[0-9]{4} [0-9]{2}:[0-9]{2}') then 'MM/DD/YYYY HH24:MI' when regexp_like(TRANS_DATE_TRANS_TIME,'[0-9]{2}/[0-9]{2}/[0-9]{4} [0-9]{1}:[0-9]{2}') then 'MM/DD/YYYY HH24:MI' when regexp_like(TRANS_DATE_TRANS_TIME,'[0-9]{1}/[0-9]{2}/[0-9]{4} [0-9]{2}:[0-9]{2}') then 'MM/DD/YYYY HH24:MI' when regexp_like(TRANS_DATE_TRANS_TIME,'[0-9]{2}/[0-9]{1}/[0-9]{4} [0-9]{2}:[0-9]{2}') then 'MM/DD/YYYY HH24:MI' when regexp_like(TRANS_DATE_TRANS_TIME,'[0-9]{2}/[0-9]{2}/[0-9]{4} [0-9]{2}:[0-9]{2}') then 'MM/DD/YYYY HH24:MI' when regexp_like(TRANS_DATE_TRANS_TIME,'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}') then 'MM/DD/yyyy HH24:MI' end), 'MM/DD/yyyy HH24:MI'),'') as newT from DT; '''
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

24 September, 2023

Inner funtion gives error in Django Rest Framework

 Programing Coderfunda     September 24, 2023     No comments   

I have inner functions inside the main function with an IF statement but when the if condition is applied it gives this error (AssertionError: The request argument must be an instance of django.http.HttpRequest, not rest_framework.request.Request.) How can I solve this issue? Any help, please? views.py from .api_option23 import api_option23 from .api_option23 import api_option45 @api_view(["GET", "POST"]) def apiscanning(request, qrcode, action, curr_user): if request.method == "GET" or request.method == "POST": if action ==1: #do something elif action ==2: api_option23(request, parameters) elif action ==3: api_option45(request, parameters)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

23 September, 2023

Livewire (+Filament) & debugging

 Programing Coderfunda     September 23, 2023     No comments   

I've worked with different frameworks quite a bit, recently mostly Laravel. There are many things I love about Laravel and quite a few pet peeves. Recently adopted Filament and I love the power, hate the lack of documentation (especially lacking source code documentation almost entirely). Filament is speeding up many things while radically slowing other things, especially when learning it. I've used Livewire in the past and love it. With Filament, everything is built on top of Livewire which has its benefits and at least one downside: debugging has become increasingly difficult. Your stack trace has 100 lines and it's very hard to understand what's going wrong. How are you approaching this aspect of debugging / development with Livewire? submitted by /u/lionmeetsviking [link] [comments]
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

22 September, 2023

Pail is an experimental package to tail logs

 Programing Coderfunda     September 22, 2023     No comments   

Pail is an experimental Artisan package to provide an effortless way to tail logs in your Laravel applications. The post Pail is an experimental package to tail logs 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

21 September, 2023

How to rebuild a graph on an html page based on the result of selecting data in the wtform form in a flash application?

 Programing Coderfunda     September 21, 2023     No comments   

I am developing a web application in flash. The application has a database. When the user visits the page, he should see a graph with default data for the first device. Then there are filters in which the user selects the desired device, data type and time period. After clicking on the "Apply" button, the graph should be rebuilt according to the user's choice. Filters are made in wtform. The graph builds a canvas script in html. Problem: The graph is not rebuilt, it remains the original default all the time Flask code: @app.route('/chart', methods=['GET', 'POST']) def chart_view(): """Chart Page""" form = LogChartForm() if form.validate_on_submit(): source_id = form.source_id.data type_id = form.type_id.data time_start = form.time_start.data time_end = form.time_end.data source_get = EvSource.query.filter_by(description=source_id).first() source = source_get.id_ev_source if type_id != 'All': typ_get = EvType.query.filter_by(description=type_id).first() typ = typ_get.id_ev_type items = Log.query.filter_by(id_ev_source=source, id_ev_type=typ).order_by(Log.timestamp).all() else: items = Log.query.filter_by(id_ev_source=source).order_by(Log.timestamp).all() # start = calendar.timegm(datetime.datetime(time_start.year, time_start.month, time_start.day, 0, 0, 0).timetuple()) # end = calendar.timegm(datetime.datetime(time_end.year, time_end.month, time_end.day, 0, 0, 0).timetuple()) labels = [strftime('%Y-%m-%d %H:%M:%S', localtime(item.timestamp)) for item in items] datas = [item.value for item in items] text = form.source_id.data dict_data = {'labels': labels, 'datas': datas, 'texts': text} return render_template('chart.html', form=form, **dict_data) else: source_id = form.source_id.data type_id = form.type_id.data source_get = EvSource.query.filter_by(description=source_id).first() source = source_get.id_ev_source items = Log.query.filter_by(id_ev_source=source).order_by(Log.timestamp).all() labels = [strftime('%Y-%m-%d %H:%M:%S', localtime(item.timestamp)) for item in items] datas = [item.value for item in items] text = form.source_id.data dict_data = {'labels': labels, 'datas': datas, 'texts': text} return render_template('chart.html', form=form, **dict_data) class LogChartForm(FlaskForm): """Graph Form: Filter""" source_list = [source.description for source in EvSource.query.all()] type_list = [typ.description for typ in EvType.query.all()] type_list.append('All') source_id = SelectField( default=source_list[0], choices=source_list ) type_id = SelectField( default=type_list[-1], choices=type_list ) time_start = DateField(default=None, format='%Y-%m-%d', validators=[Optional()]) time_end = DateField(default=None, format='%Y-%m-%d', validators=[Optional()]) submit = SubmitField('Apply') Html code: {% extends "base.html" %} {% block content %} Current system status: Graph const labels = {{ labels | tojson }}; const texts = {{ texts | tojson }}; const data = { labels: labels, datasets: [{ label: texts, backgroundColor: '#E22545', borderColor: '#E22545', data: {{ datas | tojson }}, }] }; const config = { type: 'line', data: data, options: { maintainAspectRatio: false } }; const myChart = new Chart( document.getElementById('myChart'), config ); {{ form.csrf_token }} Filters {{ form.submit(style="height: 30px; width: 140px; font-size: 16px; color: #fbfbfb; background-color: #272d3d; border: none; font-weight: 700;") }} Signal source {{ form.source_id(style="height: 25px; width: 100%; text-align: right; font-size: 16px; font-weight: bolder;") }} Signal type {{ form.type_id(style="height: 25px; width: 100%; text-align: right; font-size: 16px; font-weight: bolder;") }} Period {{ form.time_start(class= "datepicker", style="text-align: right; font-size: 16px; font-weight: bolder;") }} {{ form.time_end(class= "datepicker", style="text-align: right; font-size: 16px; font-weight: bolder;") }} {% endblock %}
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...
  • 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...
  • iOS 17 Force Screen Rotation not working on iPAD only
    I have followed all the links on Google and StackOverFlow, unfortunately, I could not find any reliable solution Specifically for iPad devic...
  • C++ in Hindi Introduction
    C ++ का परिचय C ++ एक ऑब्जेक्ट ओरिएंटेड प्रोग्रामिंग लैंग्वेज है। C ++ को Bjarne Stroustrup द्वारा विकसित किया गया था। C ++ में आने से पह...
  • Python AttributeError: 'str' has no attribute glob
    I am trying to look for a folder in a directory but I am getting the error.AttributeError: 'str' has no attribute glob Here's ...

Categories

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

Social Media Links

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

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

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

Loading...

Laravel News

Loading...

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