07 October, 2023
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
```
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
```
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.
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.
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.
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.
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.
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.
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]
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]
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
'''
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
03 October, 2023
Unfinalize tool
Programing Coderfunda
October 03, 2023
No comments
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; |})'"}
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; |})'"}
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
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


