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!

More Database Goodies
2023-01-24
Updating DB via MySQL, still a bit rough. Just wanted to update the verified time tag on a test user. Still not too hard once it gets figured out. Once you are in the correct database with: USE <database>; you can update with something like: UPDATE <table> SET <field> = NOW() WHERE id = #; https://stackoverflow.com/questions/6503824/update-a-column-in-mysql https://www.mysqltutorial.org/mysql-now/ https://www.w3schools.com/mysql/mysql_sql.asp Earlier I used something like: if (! DB::connection('mysql2')->getPdo() ){ //make DB } Turns out it didn't work. Instead what ended up working to check if a DB connection can be made, and theoretically if the DB exists, is this: try { DB::connection('mysql2')->getPdo(); } catch (\Exception $e) { echo "Stuff"; } https://stackoverflow.com/questions/33432752/laravel-5-1-checking-a-database-connection https://laracasts.com/discuss/channels/laravel/easy-way-to-check-if-laravel-app-has-connection-with-existing-mysql-db
Form Within A Form? Default Un-Selectable Option Bypasses Requirement
2023-01-23
Did a quick double check, and you are not allowed to put an HTML form inside of another HTML form. There are ways to get around this, but it seemed a bit too much for what I was going for. Instead I opted for a link in the form to another form. This works for me because the two forms were not really going to be active at the same point anyway. Also, this way I can make use of a different, more appropriate controller. https://stackoverflow.com/questions/555928/is-it-valid-to-have-a-html-form-inside-another-html-form When requiring a list of options to select, and you have a hidden default selection, be sure to give that option a blank value or else it bypasses the requirement check. <option value="">None</option> vs <option>None</option> https://www.w3schools.com/tags/att_select_required.asp
Rant...
2023-01-22
I'm supposed to write because I'm in a bad mood and need to get stuff out of my head. I am in a bad mood. I've been in a bad mood for some time. The particular thing that brought up the option to write was because of my upcoming birthday. I 've never really liked them, and this time it put me in a bit of a depression. After talking with McKendra about it for a little while I did feel better, which also made it hard to start writing. But it seems that I am still in a bad mood. I got frustrated because I was trying to look up information about the upcoming flights that we are going to take to MA, and the site was being a bitch because the reception was being shitty because we were driving through the mountains. Why does the curser in this damn program stop flashing? If I pause for more than 5 seconds the curser could disappear. I guess it's not really an issue, there are ways to determine where it's at, but it's a waste of time and energy to have to double check where exactly got left off because I can't find the curser because it's no longer flashing. What's the point in having a curser while your typing and then it disappears when you're not typing. If anything it should be the opposite. You know, I wouldn't be surprised if it didn't have something to do with this machine. It's been doing stupid stuff like since I got it, like not actually going to sleep, a function that's worked for as long as I've known it to be an option, but not here now. Now in order to make sure the processor actually stops running I need to shut everything down. I guess it's just lucky that so many programs will pick up where you left them last. ... I went off on a tangent, but it's so easy to do when it seems like nothing seems to do what it's supposed to do. Nothing works as advertised. Nothing is worth what it costs. Everything is just a loosing game. I miss music. Not listening to it, I'm tired of hearing things. I miss playing. I miss fucking around with my fellow percussionists. I miss performing. I miss playing in musicals. I miss feeling like I might be able to one day write my own medley. I know at this point I won't, and that's part of the problem. I am realizing how little I have accomplished, and how much I was kidding myself for thinking I could be anything great. I'm mediocre at best. Everything is such a catch 22. This was supposed to help me feel better, but I don't. I feel more down. I feel like a parasite. Depending on others to survive. Not wanting to stay in this world. Not caring for this world anymore. The human condition is the worst. I don't like playing anymore. I don't want to be a part of their systems. "Civilization" is overrated. Just a bunch of greedy, pompous, self important assholes... but not all... There are actually a lot trying to help those like themselves get just a fractional amount better. Trying to prevent them from hitting rock bottom, or helping pick them up from rock bottom. It's not an easy thing to do though. Trying to spread the little that they have to the others that have even less. There are so many that have so little, yet we live in one of the most abundant periods ever. Why is it that there is such a small amount of people that have so much that it's unfathomable to us mere mortals, and yet the rest of us seem to have such long periods of lacking. Those greedy ones are the real parasites. .
HasColumn(), Forget(), Echo <br>
2023-01-21
Pretty sure I mentioned this already, but you can check for the existence of database columns in your migrations with: Schema::hasColumn('table', 'column') Handy if you have multiple sites trying to run migrations on the same DB using the same migrations. In Laravel's documentation it is a part of the table section, not the column section. https://laravel.com/docs/9.x/migrations#checking-for-table-column-existence https://stackoverflow.com/questions/54176290/check-if-a-column-exists-in-laravel-migration-file If you pull a collection from a database, but don't actually want all of the elements you can remove them. You do need to loop through the collection with a specified key variable so you can use that with the ->forget() command: $collections = Model::get(); foreach ($collections as $key => $collection){ if( $collection->value == test ) ){ $collection->forget($key); } } https://laravel.com/docs/9.x/collections#method-forget https://stackoverflow.com/questions/37588515/how-to-unset-remove-a-collection-element-after-fetching-it On occasion I find myself wanting to output some informational text using echo. I know DD() is very useful, and I use it all the time, but sometimes I just want a visual of what a loop and/or if statement is doing. The problem I ran into recently was wanting to have each echo statement have it's own line. There are a lot of potential options, but since my application is displaying in a web browser I found that the addition of <br> in the echo worked well for me: echo "Statement.<br>"; Note the use of the double quotes. While it seems they are unnecessary for this particular application because the browser still appropriately interprets the <br>, they are handy when you want to display the value of a variable or escape other things. echo "Displays value of $var. Adds newline in browser.<br>"; echo 'Displays $var as written here. Still adds newline in browser.<br>';
Chillin' Wit' My Homie
2023-01-20
Took some time to have some fun while in Portland Oregon. We visited the Oregon Museum of Science and Industry, lovingly referred to as OMSI. The interactive section is definitely a fun place to mess with some science things, as a nerd the Marvel exhibit was rather engrossing, and even the natural history section has some captivating stuff. We didn't do everything they offered, but what we did do we enjoyed. After the museum we ate at Nama Ramen that had an unusual flavor drink, mango basil lemonade, and Mexican music playing in the kitchen. It was pretty good, definitely hit the spot. Especially once you got used to the basil flavor in the drink. We also hit up The Raven's Wing Magical Co. to check out and get some crystals and rocks. They had a decent selection, but not the elusive Sunstone. Still, got some anyway, along with a book about the Sabbats, or holidays. Finished up with a Boba tea, and walk around the little downtown area we were in. All in all, a good day hanging out.
RRRAAAAAVVVEEEE!!!
2023-01-19
BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTS AND CATS AND BOOTSSSSS
FF2 Teaching Life Lessons
2023-01-18
In Final Fantasy 2, the Soul of Rebirth extra playthrough, it's pretty straight forward so far. The thing that I would do a bit differently now that I know the 4th characters that join the group, and then at some point die, is give them a better run. Normally, knowing they wouldn't be staying as permanent characters, I wouldn't worry too much about beefing them up or outfitting them well. Unfortunately that made for a very rough introduction to the SOR, worrying far more often about a party wipe than normal. Luckily there is a safe haven a few floors in with the normal provisions, including an inn. So as long as you can get there, you'll be able to beef everyone up to where they need to be to keep going. The lesson here though is to treat the other characters as well as your main ones.
Breakdowns On The Road
2023-01-17
The truck broke down today, it was at a rest stop. We parked, went to the bathroom, then as we were trying to leave the air from the brakes didn't stop flowing. Did some looking around and one of the brake chambers has sprung a huge leak. One call to breakdown, 6 hours later we were able to get back on the road. What a day. On the bright side, pretty good walk for the puppers, and we got to play some video games together.
Trucks Amplify Road Defects
2023-01-16
Roads feel very different in a truck than a car. All of the bumps, quick turns, pot holes, and rough patches are rather amplified. It is impressive how much rocking will happen on a relatively smooth road that is built with those sections that have just a little bit of a dip in them. What to a car feels like a little bit more vibration while driving becomes exercise trying to prevent becoming a bobble head. Instead the whole torso acts as a gimble in order to keep the head jostled as little as possible. Honestly, (I'm sure I will say similar things often when talking on this subject) the people involved in making/maintaining the roads/construction equipment need to spend some time in a truck so that they can feel the effects of the quality of their work. There are some states/sections that are rather nice, and you don't notice hardly at all. There are some places though... feels like you are stuck in a paint shaker, and test out how well you have your house strapped together. Overpass/bridge transitions are often bad, even by car standards, but they can give you an idea of what it feels like for trucks on smoother roads. There are definitely a lot of places working on improving their roads, but laying new pavement doesn't do very well if the quality still lacks. At least it provides some hope for smoother roads.
Working Gates And Arrays
2023-01-15
Gates by default take the session user for your use, but you can add additional parameters to your gates. https://laravel.com/docs/9.x/authorization#gates-supplying-additional-context You can also give them a default value in case you need that. I ended up with something like this: Gate::define('gateName', function($user, $var = NULL) {} ); Some good discussion on making arrays: https://stackoverflow.com/questions/49398942/creating-array-of-data-in-laravel-controller In case you don't often try to leave a loop before it fully goes through, remember that "break" is your friend: https://stackoverflow.com/questions/45189524/how-to-break-a-foreach-loop-in-laravel-blade-view Also some refreshers on writing ternary operators, and discussion between that and Null Coalescing operator: https://stackoverflow.com/questions/58910273/how-to-use-ternary-operator-or-null-coalescing-operator-to-write-if-else https://www.geeksforgeeks.org/ternary-operator-vs-null-coalescing-operator-in-php/ If you decide that you only need to first or last element in an array you can use the head() and last() functions: https://laravel.com/docs/8.x/helpers#method-head
Id Title Body Post At