Showing posts with label random. Show all posts
Showing posts with label random. Show all posts

Saturday, March 22, 2025

sometimes doing random things is ok

 

I went on a trip recently and I was of course making last minute updates to my DMS driving app.

By default I have 2 modes, normal daytime mode which is just a boring bootstrap table of black text, with alternating white and gray cell colors per row....very boring.

 Then I have a night mode it is entirely black background with a darkish green text, ....for night time...

I've been thinking for a while how can I make this work better on cell phones. I have a few problems if I have too many columns, then the text has to be tiny to see anything and we'll....if you're driving, trying to glance at something tiny in the car is not ideal. I asked ChatGPT to help me out.....it's far from done, but it's progress. I asked for it to make me a page that changes the font randomly (I don't even know what the default font is but who cares let's try other things), changes the background of the page to a random color and changes the font to a random color.... I didn't review the code too much because if it didn't work I haven't default modes, and its a display page so it's not modifying the underlying database or code, so low risk, potentially......some amount of reward.

Here is an example of the randomly generated page. (Oh I also had it add a save option so if I really liked it I can continue using it, the save option kinda works but that's a story for another day).


 

I know I know, the colors are appalling, but if I'm being honest, it's legible, somewhat, so I don't mind, plus I can just hit refresh page and it'll give me a new color scheme.

I'm planning on running with this, and fiddling with my display, I have 2 columns that are the most important, and other columns that would be 'nice'. I also have more content that I'd like to have, maybe some kind of what food is nearby that automatically pops up either within 10 miles of a place, or maybe if the time is of arrival of a city is within 11-1pm so we can easily see what's in the area. Maybe using LLMs as a semi family preference filter for kinds of food.

I'm just gonna say it, sometimes doing random things is a good thing, it inspires new ideas and things maybe you hadn't thought of before. Try to put a little more intentional randomness in your life.


(Funny side note, for a bit I would be working on multiple projects with roughly equivalent priority, so I would just take out a 50 cent piece, which is of course more fun than a quarter, dime, nickel, or penny, and flip it, heads I work on problem X tails I work on problem Y. Was a fun way to have a bit more randomness, and also reduced my decision making requirements).


Have a great day!


(I'm trying to get into the habit of blogging more again)


Sunday, June 14, 2009

Random Post: "Handbrake Perl Script"


I have Google Analytics setup on my blog and I can see the keywords that have actually brought people to my site.... I find this interesting and this inspires me...If it's obscure, why not try to "guess" what the person was searching for and then do a post on that subject, if it's pretty straight forward,why not solve it..
Today's keyword subject is : perl script handbrake windows

This one doesn't look too bad.

Per Handbrake.fr's site:
HandBrake is an open-sourced, GPL-Licensed,multiplatform, multithreaded, video transcoder, available for Mac OS X, Linux, and Windows
Looking at the documentation on handbrake's site, there is a command line interface, so we can use that to make any calls to the handbrake program.

The basic command we are going to use would be:
HandBrakeCLI -i source -o destination
So we can immediately start with a perl script like this:
$source = "sourcefile";
$destination = $source . "_converted";
print `HandBrakeCLI -i $source -o $destination`;

This will simply take whatever specified source file we have and output to the destination location.

But if that was all we wanted to do we wouldn't need a perl script would we?

How about if we have a list of files in a document (along with paths)?

We can open that document grab all the paths then simply do a mass conversion!

The final "guess" would simply grab all files of extension x and convert them and dump them in a folder. Again this isn't hard as well.

Lets start with this one, it shouldn't be too bad, of course we'll want to do some error checking, such as if we already have a converted filename of the same type then we definitely want to hold off on converting.
Regardless let's see what we can come up with real quick!
@file_list = <*.mpg *.avi *.vob>;
@converted_list = <*.mp4>;
$extension = ".mp4";
Here we are grabbing a list of all the files we might want to convert, note that you can update that list to contain whatever extensions you might have/like to use. We also grab the list of converted files in there just to do some error checking (in case you leave all your files in the same folder), also the output type should match the type of files you are trying to convert to. We also should define our extension for later use!

Now it's a matter of rolling through each item in the filelist, so we'll start a for loop:
foreach $file (@file_list)
{
@filename = split(/./, $file);
$exists = 0;
}
Something to note is that we want to do a search on the filename in the converted files so in order to do that we'll need to break up the filename from the extension.

Now inside this loop we'll want to do a quick check to see if the file we have a handle on is already listed
foreach $converted (@converted_files)
{
if ($converted =~ m/@filename[0]/i)
{
$exists = 1;
}
$baseName = @filename[0];
}
So now we've done a check and if we have a file that our converted files contains.

What we can now do is make an if/then that will basically skip the file altogether if we see that $exists contains a 1!
if ($exists == 1)
{
print "File already converted!!";
}
else
{
$source = "$file";
$destination = $baseName . "_converted" . $extension;
print `HandBrakeCLI -i $source -o $destination`;

}
Something to remember:
If you want to save to a separate folder I would recommend doing a check for whether that folder exists rather then grabbing a list of files in the current directory.
Entire Script (small text...just copy paste):
@file_list = <*.mpg *.avi *.vob *.AVI>;
@converted_list = <*.mp4>;
$extension = ".mp4";


foreach $file (@file_list)
{
@filename = split(/\./, $file);
$exists = 0;

foreach $converted (@converted_list)
{
if ($converted =~ m/@filename[0]/i)
{
$exists = 1;

}
$baseName = @filename[0];
print @filename[0] . "\n";
}

if ($exists == 1)
{
print "File already converted!!";
}
else
{
print "Converting";
$source = "$file";
$destination = $baseName . "_converted" . $extension;
print "Ready?\n";
$asdf = <>;
print `HandBrakeCLI -i $source -o $destination`;
}
}

The only difference between the above script and one that will open a document and pull all the filenames from it is that you would use the command:

open DATAFILE, "$inputfilename" or die "Missing $inputfilename file.\n"; open (DATAFILE, $inputfilename);
@file_list = ;
close (DATAFILE);
The above would replace the line:
@file_list = <*.mpg *.avi *.vob>;
That's really the only difference!

Well let me know what you think in the comments and if you happen to have found this site looking for just this random post please let me know!!!