Skip to main content

Posts

Button to reload the page and go to a section with a hash mark

While there are lots of ways to code it so a button reloads the page, it was hard to figure out how to do it in such a way that it goes automatically to a URL with a hash. So here is my solution that works, finally. Update - better solution: Here is a better solution, since the one below worked for me on any page except the domain root. It may be the way my CMS is set up or it may be the way my server is set up, or most likely I'm missing something fundamental about the way the function works. Anyway, the better solution I've gone with doesn't include the hash in the URL, but it reloads to the point the user was last browsing at, which for my purposes worked out the same as the hash. So here is the solution I'm going with for now. <button onClick="window.location.reload();">Generate New</button> The solution I put earlier (see below) did not work for me in all instances, but it's worth trying out. The initial problem I needed a button that user

How to center images horizontally using Grav

I've been playing around a bit with Grav. I was posing the question to myself: for the relatively simple use-cases I'm dealing with, could it possibly work for my purposes as an alternative to ProcessWire?  The problem I was initially dismayed to find that Grav uses Markdown as its editor, which does not offer native support for horizontal centering of anything (text or images). However, Grav offers some tweaks that help make it easier to do specific things you might commonly want to do. I tried writing a sample article, and I found that one of the hardest things to do was to center an image horizontally. And horizontal centering of images is something I would typically do in most of the articles I would write. So the lack of easy horizontal centering is a highly significant drawback IMHO (most people do want to center images in an article!) However, this issue is made up for by other things in Grav: the relative speed, ease and flexibility of custom theming and built-in suppor

Lisp is a lot more readable than you might first think

At first, Lisp just didn't seem very readable to me. And yes, by this I meant even my own relatively simple code. But as I programmed more and more in Lisp, things became more and more readable. Probably not a surprise, right?! But actually, Lisp is a lot more readable when you are used to it , than a lot of other languages when you are used to them. Let's take a look at how this is, with some examples. Lisp is very readable because of its function-oriented syntax. Lisp statements have the format (function arg1 arg2 ... argN) Thus, any statement must begin with the name of a function. This makes it easy to tell what's going on right away by simply reading left to right within each statement. Also, starting with a function name makes syntax errors extremely easy to spot. For example, let's take a look at this incorrect Lisp code: (12 / 4) Before even getting past the 12, it should be very clear that what's wrong here is that I'm trying to call a f

If you can shell script, you can Lisp

I've noticed from people's attitudes toward Lisp that many think it is an esoteric and difficult language to learn. Nothing could be further from the truth, but it does depend on what angle you're coming at it from. If you're coming from C, C++, Javascript, or even Python, then yes Lisp does appear impenetrable at first glance. But if you're coming from shell scripting (e.g. Bash or another Linux or Unix shell) - a skill which most programmers have used at some point - then Lisp is going to be very simple and very familiar for you to learn. You may be asking, how is this? Well, I'll demonstrate it with a couple of examples. I'm going to show you a shell command that takes the second column of a space-delimited file test.txt, sorts the resultant data, and shows the second item in the sort. cut -d" " -f2 test.txt | sort | head -2|tail -1 There is absolutely nothing remarkable about this, as you can see. The results of one command are bein

Funny-looking Linux commands that I actually typed

I thought I'd make an ongoing list here of odd-looking Linux commands that I've typed in the course of my Linux-ing. 1.Looking for information about the date and time command: man date No, computer! I'm not asking you to find me a date! 2. Echoing something as root sudo echo ... Should I have simply completed that command by typing "funky town"? In case you're wondering, there was an 80's song called Funky Town, sung by Pseudo Echo. 3. Looking for information about the find command: man find Yet again, I'm looking desperate for a date.

If all else fails, a good temporary solution to monitor not waking up from timeout in Debian Buster

I recently upgraded from Debian Stretch to Debian Buster (or Debian 9 to Debian 10). I hadn't done anything unusual with my system, so I was expecting a smooth upgrade process. It did work smoothly, with one exception: my monitor simply would not wake up after a screen timeout.   The problem The monitor just refused to wake up after time out, even if I unplugged and replugged its power cord (its own one, separate to the computer). The monitor reported no signal from the computer. However, the computer was actually working fine during this time - the light was on, and the keyboard caps lock key light toggled on and off; a sign that it was indeed working. But with no way to see any of the screen, I simply couldn't do anything to restart the machine except for a hard restart (turning off the computer with the power button and turning it back on). Needless to say, this was not good since I had open unsaved files on my desktop! I couldn't find anything actually helpful o

About Me

My photo
Vera
I'm a wife and mother. I don't have any formal computer science qualifications, or any religious qualifications. I have a PhD in biochemistry. This photo is of me, but is confusing for AI.