This post has nothing to do with the purpose of this blog — it’s just easier to upload a bunch of pictures… and in theory I am the only one who uses this. ; – )
Exterior
Just out of the car wash! ; – )
Interior
Controls
Specifications
Views: 3
This post has nothing to do with the purpose of this blog — it’s just easier to upload a bunch of pictures… and in theory I am the only one who uses this. ; – )
Just out of the car wash! ; – )
Views: 3
Either there is a considerable art to prompting GPT to produce code, or it is a pretty haphazard process. By this time I have made probably a dozen attempts to coax GPT into writing code for a flipcard that randomly pulls a line of text from a file, parses it, and displays the first part on the front, and the second part on the back.
After a day of trying, I got that to work — except later realized it didn’t actually work under safari. I asked chatGPT and it told me about safari and webkit and how to change styles, but those things did not seem to do anything.
I decided I’d try starting over, and asking chatGPT to build up much simpler flashcards, and see if I could get something very very simple (e.g. not reading from a file) to work across platforms. But the short story is that, over several attempts, and in spite of having been successful previously, I was unable to get even simple static flashcards working on any platform.
After a couple of attempts, I’ve decided that there are better ways to pass time, especially as I did, in the whole process, iron out a couple of irksome quirks on my site.
I will also say that I believe that although chatGPT isn’t great at coding, I find it quite useful at alerting me to various problems (like caches and safari/webkit incompatibilites), even if it doesn’t always success in solving them.
I will mention that, as i think I summarized in the previous post, that developoing on the live set does require that I always
Views: 5
28 April 2024
When doing this development, remember the following:
When weird things happen
nocache
) to the URL in the fetch request to ensure the browser fetches a new response each time without caching the result.TO DO
Views: 2
It has been ages since I’ve done anything, but I’m back.
I’m trying to implement a new version of flashcards.
Something strange is happening — it is a huge struggle to get… Firefox? My web platform?… to actually run new files I am uploading. It is some kind of cache or memory problem. It may be complicated by caches acting differently for html, php, javascript, etc.???
I think I have finally determined that if I open the page that I’ve changed in Firefox, go into to Browser Tools and choose Web Developer Tools and then hit refresh, the new changes will take effect.
That appears to work, but is cumbersome.
There should be a way to turn off caching altogether. I tried doing that, but it didn’t appear to work — I’m not sure if it turns it off at all, or only for particular windows in the browser, or what.
I think I may just need to step back and do a tutorial on web development… either that or figure out how to do development on MAMP, which I I think I had figured out a couple of years ago, but have now forgotten.
Yuck.
Next day. To ensure I have the latest code actually running I must:
It is not always necessary to do both or even either of these.
Views: 6
Saturday 30 April 2022
What I would like to do today is to be able to enter text on a web page and have it entered into a server file. That is complicated by the need to validate the entry so a page can’t be hacked. Yesterday, or maybe it was the day before, I think I figure out in general what I needed to do, and even wrote/found code snippets to do it. Today I want to try it and see if it works.
First, I need to remember how to get MAMP running, so I can do the trial and error on my local machine. OK, that is just a matter of finding
1. MAMP (which is in my applications launch page), and
2. the MAMP htdocs directory (there’s a shortcut in my favorites panel)
OK, so I can launch index, and I can see it is running on local host (and I have a note on that instance of the index that says “MAMP” as a double check), so that is good, Clicking on subsidiary pages works fine, and they too run on local host.
BUT when I click on the .php link firefox wants to open the file with something else, rather than run the page.
…I thought this was working before.
OK, looks like I left workspace.php in a non-working form.
…but restoring the original doesn’t work. It still opens in BBEdit rather than running.
…I thought that I had this working.
Ug.
Views: 10
Wednesday 27 April 2022
When I last wrote I was focused on trying to create an exercise tracking list with checkboxes for my workspace page. Since then I’ve decided it is easier and more useful to just use a spreadsheet, and so I did that and got distracted entirely from web programming by my physical therapy, etc., regime.
Now I want to take up programming again. I would like to return to the file-handling material again, so that I can enter text into a file (e.g., like my quotations file) from a web page. I would like to be able to do the following
OK, I can get input like this:
<form action="/action_page.php">
<label for="TextInput">Quotation</label><br>
<input type="text" id="TextInput" name="TextInput"<br><br>
<input type="submit" value="Submit">
</form>
This passes an input “XXX” to “action_page.php” as TextInput=XXX.
That’s nice, but what I want to do is get that text into a file, presumably appended to a file.
OK, let’s try this again. Here’s code that gets the input
<html>
<body>
<form action="WriteToFile_get.php" method="get">
Quotation: <input type="text" name="EnteredQuotation"><br>
<input type="submit">
</form>
</body>
</html>
and then we have a WriteToFile_get.php file that is:
<html>
<body>
<?php echo $_GET["EnteredQuotation"]; ?><br>
</body>
</html>
I think, in the above two blocks, all instances of “get” could be changed to “post”
In either case, my working hypothesis is that $_GET[“<name value>”] will contain the entered data and should be able to be appended to a file.
So WritetoFile.php should be:
<html>
<body>
<?php echo $_GET["EnteredQuotation"]; ?><br>
<? php
$fh = fopen(“quotations.txt”, ‘a’) or die(“Failed to create text file.”);
fwrite($fh,$_GET["EnteredQuotation") or die(“Could not write to file.”);
fclose($fh);
echo “File ‘quotations.txt’ written successfully.”;
?>
</body>
</html>
OK, let’s modify this to (1) use PUT, (2) use validation. And once this is working, change the type from text to textarea (which apparently doesn’t require the “input” command, i.e.: <textarea name=”EnteredQuotation” rows=”5″ cols=”40″></textarea>
<html>
<body>
<form action="WriteToFile_get.php" method="post">
Quotation: <input type="text" name="EnteredQuotation"><br>
<input type="submit">
</form>
</body>
</html>
AND the WriteToFile.php page will be
<html>
<body>
<?php echo $_PUT["EnteredQuotation"]; ?><br>
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$EnteredQuotation = test_input($_POST["EnteredQuotation"]);
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$fh = fopen(“quotations.txt”, ‘a’) or die(“Failed to create text file.”);
fwrite($fh,$_GET["EnteredQuotation") or die(“Could not write to file.”);
fclose($fh);
echo “File ‘quotations.txt’ written successfully.”;
?>
</body>
</html>
?>
Views: 2
I would like to simply trackt my exercises, either on my pinned wordpress entry, or at least on my workspace.
https://www.sitepoint.com/quick-tip-persist-checkbox-checked-state-after-page-reload/
Views: 2
Tuesday `10 March 2022
The current goal is to be able to input something on the web page, save it to a file, and get it back.
…I looked into cookies, and it does not appear that they provide the functionality that I want; or, if they do, it seems like working with a regular txt file would provide more flexibility. In the long run, probably a database would be best, but I will save that for later.
So, more particularly, I want to
Open a file
Read one or more lines
One of the following
Display the contents of the file on the page & then alter it Add a line to the file
delete a line from the file
Write the resulting data to the file, replacing the altered material
I will begin by looking at the Robin Nixon book, p 147
<? php
$fh = fopen(“x_logfile.txt”, ‘w’) or die(“Failed to create text file.”);
$text = “This is one line of text…”;
//$text = <<<_END //programmatically add text to a file? Didn’t work.
// line 1
// line 2
// line 3
// _END;
fwrite($fh, $text) or die(“Could not write to file.”);
fclose($fh);
echo “File ‘x_logfile.txt’ written successfully.”;
?>
So far
Grrr.
VSC seems to offer the potential to validate php code, which might catch such errors, except that it wants me to tell it where the php executable is, and I don’t know that. There are all sorts of php files in the MAMP directory/subdirectories. Sigh.
OK, anyway, the php filehandling works. The next step is to figure out how to get input from the user via the web page. This will be complicated by the fact that to be secure we will want to validate that whatever is entered is not an attack…
$name = strtolower(preg_replace("[^A-Za-z0-9.]", "",$name));
I think what I need to look at next is forms. Forms seem to be the way of getting user input from a web page. That makes sense, as it would control the nature of the input so security is less of an issue, except when the user is allowed to enter a text field.
<form action="/script-that-processes-form-entries.php"> <label for="ID-of-the-input-field">First name:</label><br> <input type="type-of-the=input" id="ID-of-the-input-field" name="variable-with-content-passed-to-script" value="default-value"><br><br> <input type="submit" value="Submit"> </form>
note that the value of “for” in the label must match the ID of an input
form takes three arguments:
Kegel exercises (slow & fast): _ _ _ _ _ _ Walking (miles):_ Running (miles):_ Eccentric Heel Lifts: _ _ _ _ _ _
I should be able to find an example of getting input from a form, saving it, and then retrieving it to repopulat the form. Some pages to check out:
https://www.w3schools.com/php/php_form_complete.asp
https://www.ostraining.com/blog/coding/retrieve-html-form-data-with-php/
Views: 3
Wednesday 2 March 2022
Views: 6
Friday 25 February 2022
At the end of the day, I am
All in all a reasonable day’s work.
I’ve installed Visual Studio Code on my Mac. So far it is performing as promised — it makes css code more legible, and shows examples of colors referred to in the text. Hopefully it will work as well for php and html. Taking a quick peek at the html reminded me that there is still a lot of clean up to do. …Before I embark on that, I want to see if I can get git or github working locally; modern version control would certainly be preferrable to my modus operandi of just creating copies of folders and trying to name the appropriately.
I looked into Github and discovered that I have an account, with the username 2goldfinch, from 2017. This was created for some kind of IBM project, but I never used it other than making a couple of test repositories. Now I hope to explore it a bit more, and am encouraged that there is a desktop version that is oriented towards point and click folks like me. …Besides using it to maintain my website materials, I’ve read that people also use it to manage writing. I’m not entirely sure how that works — do I need to write plain text with markdown? We shall see.
So the basic markdown works for creating headings, but I don’t see how to re-use reusable blocks; applying custom css styles to each block seems way to cumbersome to be the way it ought to work.
Also, all of a sudden, I am now getting the spinning beachball cursor appearing forlongish amounts of time as I am writing here. That doesn’t seem good. Could it be related to special css files? …Or is it some weird interaction with githum desktop trying to sign into github.com. Not sure.
=> Not long after, github desktop complained it wasn’t in the app folder and that this might cause problems. So I moved it, and also moved VSC to the app folder. Hopefully that will help. ….That, and a reboot, seemed to help.
OK, now I can use markdown to easily create headers, and I’ve found out how to insert css to change the appearance of the header text — it appears necessary to include “!important” at the end of each css statement. I presume that overrules defaults set elsewhere.
h1 { color: #000066 !important; font: small-caps bold 20pt Arial, sans-serif !important; } h1.entry-title { color: black !important; font: bold 24pt Arial, sans-serif !important; } h2 { color: darkred !important; font: small-caps bold 16pt Arial, sans-serif !important; } h3 { color: cornflowerblue !important; font: bold 13pt Arial, sans-serif !important; }
Views: 4
Thursday, 24 February 2022
OK, it looks like this wordpress editor automatically interprets *Markdown*… at least I think it does. **Sometimes.** Well, maybe only for headings? Or things that are on their own lines?
back single quotes
` (NB. the backquotes behave oddly, but work)The next thing I want to do is to learn more about git and how it is used for version control. In particular, there are people who use git for non-coding tasks, such as writing, so I’d like to see if that makes sense
After that, Jeffrey recommended I look at Visual Studio from Microsoft which could prove very helpful in (1) detecting errors, and (2) suggesting what code to write. He gave me a demo where he wrote a comment about what the code was going to do, and the editor supplied the actual code (by doing matching from within github).
Views: 2
Wednesday 23 February 2022
A couple of weeks ago I installed MAMP. MAMP is a solution stack for web development and stands for Macintosh (OS), Apache , MySQL, PHP. It enables one to run a server based environment on a local machine, and simplifies development because new versions of a site that use php do not have to be uploaded to an external server.
I am now going back to MAMP for php development — that will help avoid the error I had yesterday where I uploaded my php file to the wrong directory and was unable to see any effect of changes I make. With MAMP, I can just edit the file directly.
The first thing I will do is figure out the code that makes the random quotations work. Here is the snippet:
<?php $textfile = 'quotations.txt'; # data file of text lines to display randomly (html ok) #### READ STRINGS FROM FILE (in same directory) INTO AN ARRAY AND RANDOMIZE THEM ini_set('auto_detect_line_endings', TRUE); #alters php settings to detect newlines $disp = file($textfile, FILE_IGNORE_NEW_LINES); #reads a file into an array $count = (count($disp)-1); #number of lines in array minus 1 $rand = array(); # declare that rand is an array for ($a=0;$a<=$count;$a++) {array_push($rand,$a);} # Puts sequence of $count indices into $rand shuffle($rand); # shuffles indices in $rand #####Create html formatting and embed choosen string in it echo '<table id="foo">'; $col_ent = array(); # declare that $col_ent is an array $i = 0; $key = $rand[$i]; #put the first element of $rand into $key array_push($col_ent,'1'); #put 1 into #col_ent echo "<tr><td class='foo-$i'>"; echo "<div class=\"quotationDiv\">"; /* style=\"margin: 10% 15%; text-align: center; font-size:18pt; font-weight:bold;\">"; */ echo "$disp[$key]"; /* the string*/ #display a random string using $key echo '</div></td></tr></table>'; #Once there was more code that created multiple random entries indexed with col_ent /* echo $post; */ ?>
Ok, I’ve commented the above, and can see that the original code that I copied from this had a lot of leftovers from when it tried to be a far more general function. I think I should be able to rewrite the above so I can just generate a random number and use it as an index to select a random line.
Like this
That works. The reduced code looks like this:
<?php $textfile = 'quotations.txt'; # data file of text lines to display randomly (html ok) #### READ STRINGS FROM FILE (in same directory) INTO AN ARRAY AND RANDOMIZE THEM ini_set('auto_detect_line_endings', TRUE); #alters php settings $quotes = file($textfile, FILE_IGNORE_NEW_LINES);#reads a file into an array $count = (count($quotes)-1); #count number of lines and sub 1 $key=rand(0,$count); #generate a random index #####Create html formatting and embed choosen string in it echo '<table id="foo">'; $i = 0; echo "<tr><td class='foo-$i'>"; echo "<div class=\"quotationDiv\">"; /* style=\"margin: 10% 15%; text-align: center; font-size:18pt; font-weight:bold;\">"; */ echo "$quotes[$key]"; /* the string*/ #display a random string using $key echo '</div></td></tr></table>'; #Once there was more code that created multiple random entries indexed with col_ent ?>
The other mystery is that I tried putting all the style code into the main css file and it broke stuff — could that be due to the missing semi-colon???
=> YES
==> ALSO, NEED TO BE CAREFUL TO FORCE A REFRESH OF THE UPLOADED FILES
Views: 4
Tuesday 22 February 2022
I am now modifying the php code to make it work for flip cards
At this point I’ve gotten stuck on #3. So I am going to go back to #2, simply the code as much as possible, and make sure I understand everything that it is doing. Then I will return to #3.
Views: 7
21 February 2022
Spent about an hour finding some css/html to make a flip card for a page. I still need to fully understand how it works. One that is done, I hope to be able to modify my php quote code so that I can pull the front and back of textual flipcards from a file and display a random card…
Views: 3
Views: 2
16 February 2022
But it doesn’t entirely work. …I didn’t think to test it until I’d gone through the tutorial and produced something that didn’t quite work.
Views: 5
15 February 2022
Design ideas
Views: 2
14 February 2022
What I’ve done so far
What I’ve learned
Thoughts / What’s Next
Views: 4
12 February 2022
I did not take notes.
I messed around with the formatting of the site, and made several minor changes
I would like to put up more content. Possibilities, all of which I want to pursue, are
Also I need to clean up the various blogs – I should have only two blogs on the site. One for personal work, and one for publication.
Views: 3
About a week ago, before I went to Mayos, I did 1-3 above, and it didn’t work. First, nothing happened, and then I realized I was having trouble with the cache. I cleared the cache on Chrome, and things worked better, but the top horizontal menu was broken.
I am trying a more cautious incremental approach. I have
1. Made sure that none of the top level pages (except index.html) have the same names as the original site
2. I have eliminated all references to .php files from this version
It worked!
There was something wrong with the way I had included the .css file – it worked when the browser was reading files from the disk, but failed on the server.
I will now go back and try putting in the version with the php work. Yes, that worked as well. The php file was not a problem.
Views: 4