Rants and Raves

Welcome to Rants and Raves! I kept hearing that I needed to write, so here is the blog that I ended up starting. It is mostly an accounting of my progression through creating a web site, nuances with code, and tips about what I did to make things work. In there you will find sprinkled about some gems of life, and letting loose fun. Enjoy!

Cake Or Pie?
2023-02-13
I know cake is the standard for birthdays, but I really like banana cream pie instead. Cakes tend to be dry, and frosting usually ends up being too sweet. Cream pies have good moisture, a balanced sweets profile, and is definitely an excuse to eat whipped cream. So I do think cream pies are superior to cake as the birthday treat.
Happy Birthday To Me!
2023-02-12
BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA BOOOOM CHA BADOOM BOOM CHA
Successfully Redirected Microsoft Azure Site Again
2023-02-11
Alright, I did find an old project that Azure did seem to want to work with, but when I added the Route::permanentRedirect() method that had worked previously it kept failing. I was able to confirm that I could use the a return redirect() instead of the return view() in my route to the home page just fine, as well as the Route::redirect() on the route to the home page. But Azure kept giving my a 404 error when I would try the wildcard method I had used earlier. After looking up the original wildcard post and reading through the Wikipedia article on regex I thought I figured out what my issue was. The wildcard post uses + quantifier in the regex, but I went with * instead. Because I was not adding a / at the end of my web address the route had 0 characters to match against, which resulted in an error when using the + quantifier because it needs to match at least 1 character. https://joshanthony.info/2017/12/28/wildcards-in-laravel-routes/ https://en.wikipedia.org/wiki/Regular_expression So I went from the original redirect of: Route::permanentRedirect('{whatever}', 'http://jaredgarrison.com/')->where('whatever', '.+'); Which could handle website.com/ but not website.com, to: Route::permanentRedirect("{whatever}", 'http://jaredgarrison.com/')->where("whatever", '.*'); Which can now handle website.com as well. On a note of Azure, I did find that you can manipulate the files directly on their server. In portal.azure.com navigate into the web app, select advanced tools in the tree on the left, and click go. This will bring up Kuda environment. Here you can go to either the CMD or PowerShell debug consoles, navigate the tree above the console window to site\wwwroot, and similarly navigate to the file you want to tweak, then click on the little pencil icon to edit a file. This worked a lot faster to tweak and test my changes, and then edit the local file to match once I was done.
New Tattoo Gun
2023-02-10
McKendra got a tattoo gun, and she tried it out today. It started out a bit rough, but there was some pretty quick improvement. Luckily the kit came with some fake skin to practice on, it actually seems like a pretty solid little setup. She is pretty excited about it.
Good Reminder That Azure CLI Is A Major Test In Patience
2023-02-09
I thought that I might try and rectify the issue with my last Azure upload, that my components require a PHP version that isn't included in that site. So I thought I would just tweak the values in the file to something that the site should be able to fulfill, since the redirect that I want Azure to do shouldn't be affected by that. At this point I'm not sure that the site has any PHP grandfathering in it. But I am being reminded of one of the downsides to using CLI to upload, namely that I end up waiting for 20-30 minutes for the upload to complete just to see if a tweak worked, if it completes. It also doesn't like that my internet keeps jumping to different towers, being a mobile hotspot while travelling. On top of that my phone seemed to be having its own issues, with great reception, a solid hotspot, and no internet on the laptop... Luckily a restart of the phone seemed to fix that one. Even though I tried to identify the spots that list the higher PHP level as a requirement, but it didn't seem to help. My last ditch attempt to see if I can bypass the PHP issue is to copy over some old files for a moment that should not have those listed. To be continued...
Manipulating Collection Data
2023-02-08
If you want to run a query where the filter could have multiple values there is an easy way to do it instead of using several ->orWhere() functions, its the ->whereIn() function: $woodwinds = User::whereIn('section',['clarinet', 'saxophone', 'oboe', 'flute', 'bassoon'])->get(); https://laravel.com/docs/9.x/queries#additional-where-clauses https://stackoverflow.com/questions/60906018/laravel-eloquent-where-with-array Similarly, if you you need to run a similar query but on a relation instead, you will need to likely use whereIn() inside of an advanced where clause that is part of whereHas() or whereRelation() as a better option: $woodwinds = User::whereRelation('sections', function($q) { $q = whereIn('section_id',[ 1, 2, 4, 6, 8 ]) })->get(); https://laravel.com/docs/9.x/queries#advanced-where-clauses https://stackoverflow.com/questions/28992261/wherein-and-relationships Reminder that if you want to only get the bulk data once and then work with the resulting collection you can use ->forget() to prune the collection: $userSubset->forget($key); https://laravel.com/docs/9.x/collections#method-forget After you get the new collection that you want, you can also rearrange the elements so that the collection keys don't have gaps by using values(): $resetKeys = $collection->values(); https://laravel.com/docs/9.x/collections#method-values You can also grab the collection key that is being used for the element that you want $collectionKey = $userSubset->where('name', 'John')->keys()->first(); $john = $userSubset[$collectionKey]; https://laravel.com/docs/9.x/collections#method-keys And if you want to see the value of something without stopping the program like dd() does, you can use dump() instead: dump($john); https://laravel.com/docs/9.x/helpers#method-dump And one last reminder about the while loop, handy to keep running while a condition is met: $prev = NULL; $condition = TRUE; while ($condition) { $rand = rand(1,100); if($rand == $prev){ $condition = FALSE; } $prev = $rand; } You can accomplish a similar thing without using a condition variable, but using break instead: $prev = NULL; while () { $rand = rand(1,100); if($rand == $prev){ break; } $prev = $rand; } https://laravel.com/docs/9.x/blade#loops
More Strings And Goodies
2023-02-07
Mentioned earlier was generating a random string, now to generate a random number. If you are not too concerned with security issues then simply use the rand(lower limit, upper limit) function: $random = rand(10,50); https://stackoverflow.com/questions/24884174/generate-random-number-in-laravel If you would like to know how many items are in your query or collection use the ->count() function: $num1 = $collection->count(); $num2 = count($array); https://laravel.com/docs/9.x/queries#aggregates https://laracasts.com/discuss/channels/laravel/how-to-get-array-count Reminder to use ->whereRelation() to filter based on a different model/tables values. $models = Model::whereRelation('relationship', 'key', value)->get(); https://laravel.com/docs/9.x/eloquent-relationships#inline-relationship-existence-queries Back on the subject of playing with strings, there are some more that I used to do some checks to determine if a user was part of my test users. Because of the way I formatted the emails the admin does not have a number, but the users do. I thought I could isolate the existence of the number by using the Str::between() modifier. Once the number was isolated I was able to use the Str::length() function to count the number of characters of the number in the email. The idea being that the demo admin user would have a zero length on the nonexistent number. This worked on all the demo emails, but if the function doesn't find the values specified it will return the supplied string. Meaning it will spit back any other email that isn't a demo email for me, which was confirmed when I got a result of 24 instead of 0, 1, or 2. To make sure we are working with only the demo emails I used the Str::contains() function to make sure of that. All in all I ended up with something like this: foreach ($users as $user){ if(Str::contains($user->email,'@user.test')){ if(Str::length(Str::between($user->email, 'demo', '@user.test')) != 0){ $userEmail[]=$user->email; } } } https://laravel.com/docs/9.x/helpers#method-str-between https://laravel.com/docs/9.x/helpers#method-str-length https://laravel.com/docs/9.x/helpers#method-str-contains
FFXI Registration Pains
2023-02-06
I went and subscribed to Final Fantasy XI, and it was kind of a pain. Apparently they have done some merging of account systems, kind of. They are now managing accounts via Square Enix, and not with Play Online, although you still need a Play Online ID and password. Now the launcher does point you in the right direction, but know that the login for this Square Enix site is not the same as square-enix-games.com. So even if you do have an account there, you will still need to make one for this site. Once signed in though you can continue with the registration for a Play Online ID for FFXI, if you have an activation key for the game itself. If you don't have one you can buy one, but not here. You have to go to square-enix-games.com and purchase the activation keys for the game, hope you have an account for that site too. Oh, and at some point you might as well link your new Square Enix account to your Square Enix Store account for... reasons, not sure when you are allowed to do that for sure. Well, once you finished registering for your FFXI Play Online account you will get a confirmation and email with your Play Online ID, password, and a Play Online email and password. Now you can finally close all the windows that popped up during the process, and log in, update, log in some more and play. I did end up changing one of the config settings from borderless to full screen to try and stop the app from crashing from some screen error. But I guess from there you can start playing.
Soft Deletes And Truncation
2023-02-05
If you have implemented soft deletes in Laravel then using the ->delete() function keeps them in the DB and just marks up a deleted_at field in the DB. https://laravel.com/docs/9.x/eloquent#soft-deleting It does come in handy to access those "deleted" entries sometimes, and it's easy to do so with ->onlyTrashed() or ->withTrashed() added to your Eloquent query. https://laravel.com/docs/9.x/eloquent#querying-soft-deleted-models Another function that can be really handy, or really dangerous, if you are trying to reset a DB back to a fresh clean state is the truncate() function. Model::truncate(); https://laravel.com/docs/9.x/eloquent#querying-soft-deleted-models WARNING: If you run this against one of your models it will completely wipe out and reset the DB entries associated with it. This is good for a demo like I am trying to make, where people can mess with that DB and it would be good to wipe it out and start again fresh. Possibly okay if you are trying to reset a DB to remove gaps in the data, but could easily wipe everything out if the data isn't backed up already.
RAAAAAAAAAAVE!!!!!!!
2023-02-04
WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB WWWUB WWWUB WWWUB WUBWUBWUB
Id Title Body Post At