here is a shell script i wrote for automating filenames for markdown files (blog posts):
::: spoiler code
#!/bin/sh
set -e
datecmd="date +%Y-%m-%d"
if [ -z "$1" ]; then
printf "Post title: " >&2
read -r title
else
title="$1"
fi
file="$($datecmd)_$title.md"
if [ -f "$file" ]; then
printf "Error: post '$file' already exists.\n" >&2
exit 1
fi
${EDITOR:-nano} "$file"
im not sure why i made it since i could just look at what date it is and write it down manually in the file name, but i felt like doing that as a quick hack
:::
Only thing I can recommend (as well as for literally any script) is using set -u. Only because it's awful to debug unset variables and there's never a use case for using unset variables.
If your element has an id, you can just reference it from the window scope. The const page = is useless. Also the body has its own reference under document: document.body replaces document.querySelector('body')
If your element has an id, you can just reference it from the window scope
This is brittle, as defining a global variable with the same name (or the browser adding a API with the same name) will override it. This functionality was only kept for backwards compatibility with sites designed for Internet Explorer. The spec says to use getElementById instead.
It drives me bonkers! The browser already has a way to display loading and it’s even respectful of back buttons.
I get that in a select few cases, for real time content, it makes sense to handle the loading inside the page. But if all you’re doing is displaying an article, I don’t need you to load a framework page that then loads the content. Just load the content.
They mean the browsers page loading status. They're saying if your content is static, it should be static or loaded in the page document through a CMS, not through an asynchronous call to an api after the page and js framework and load.
Ah sorry I responded which you then responded to but in the meantime I had deleted my comment as I couldn’t figure out if you were being sarcastic or not 😜
Don’t just override opacity with null , it will override whatever the original style was. Before setting to 30% you need to store the original value and restore that in the timeout.
Nice. Remember that everything is super complicated so don't get too ambitious too quickly. If you run out of ideas for simple things to make i can recommend
and make it more complex as you go + you get very quick visual feedback as you can see the browser making your project come to life. A great online resource for learning web technologies is https://www.w3schools.com/
3/4 of a second is quite noticeable. Most UI animations are only 100-200ms, and if you disable them, things feel faster but less "polished". Try it out yourself on your phone UI if you've got an Android.
44 Comments
joyjoy@lemmy.zip · 42 pts · 208d
Why are you using
Node.removeChildfor? Are you trying to support a 13 year old browser? Switch toElement.removebestelbus22@lemmy.world · 73 pts · 208d
Lack of knowledge I guess. Which is why I like posting code on the internet. Thanks for the tip!
allywilson@lemmy.ml · 17 pts · 208d
OMG, this is the internet don't be posting self-flaws. Jeez. ^kthxlvubai^
callyral@pawb.social · 10 pts · 207d
perhaps i too will post code on the internet
here is a shell script i wrote for automating filenames for markdown files (blog posts):
::: spoiler code
im not sure why i made it since i could just look at what date it is and write it down manually in the file name, but i felt like doing that as a quick hack :::
joyjoy@lemmy.zip · 9 pts · 207d
Scripts aren't just for complex tasks. They're also for consistency.
timsjel@piefed.world · 2 pts · 207d
Here is my most recent script, not gonna lie, pretty proud of this bad boy. /s
shjava per/med/xwpp01 A001 conv.txt
echo 'yo'
shjava per/med/xwpp01 A002 conv.txt
echo 'yo'
shjava per/med/xwpp01 A003 conv.txt
echo 'yo'
shjava per/med/xwpp01 A004 conv.txt
echo 'yo'
shjava per/med/xwpp01 A005 conv.txt
echo 'yo'
shjava per/med/xwpp01 A006 conv.txt
echo 'yo'
shjava per/med/xwpp01 A007 conv.txt
echo 'yo'
shjava per/med/xwpp01 A008 conv.txt
echo 'yo'
bestelbus22@lemmy.world · 1 pts · 207d
Love this kind of stuff. I have a whole reposity of fish functions that do stuff because I'm too lazy :)
yetAnotherUser@discuss.tchncs.de · 1 pts · 207d
Only thing I can recommend (as well as for literally any script) is using set -u. Only because it's awful to debug unset variables and there's never a use case for using unset variables.
bleistift2@sopuli.xyz · 12 pts · 208d
TIL. I grew up with ‘suicide is bad, filicide is ok’. I guess the times are a-changin’
MonkderVierte@lemmy.zip · 4 pts · 207d
"Make it a webapp, so it runs everywhere" my ass.
mack@lemmy.sdf.org · 37 pts · 207d
I swear 95% of my government websites have this function integrated on every step when renewing my IDs or booking appointments
bleistift2@sopuli.xyz · 22 pts · 208d
If your element has an id, you can just reference it from the window scope. The
const page =is useless. Also the body has its own reference under document:document.bodyreplacesdocument.querySelector('body')dan@upvote.au · 39 pts · 208d
This is brittle, as defining a global variable with the same name (or the browser adding a API with the same name) will override it. This functionality was only kept for backwards compatibility with sites designed for Internet Explorer. The spec says to use
getElementByIdinstead.bleistift2@sopuli.xyz · 15 pts · 208d
Aww man. I only found out about this recently :(
bestelbus22@lemmy.world · 7 pts · 208d
I knew about this feature yeah but it seemed too janky to me (which says something, you should see the rest of my project :P)
sunbeam60@feddit.uk · 18 pts · 207d
It drives me bonkers! The browser already has a way to display loading and it’s even respectful of back buttons.
I get that in a select few cases, for real time content, it makes sense to handle the loading inside the page. But if all you’re doing is displaying an article, I don’t need you to load a framework page that then loads the content. Just load the content.
bestelbus22@lemmy.world · 4 pts · 207d
You mean like when an HTP request is not completely fulfilled? Is there an API for this "native" loading display of the browser?
AnUnusualRelic@lemmy.world · 11 pts · 207d
You can tell by the shooting stars behind the big "N".
3abas@lemmy.world · 5 pts · 207d
They mean the browsers page loading status. They're saying if your content is static, it should be static or loaded in the page document through a CMS, not through an asynchronous call to an api after the page and js framework and load.
sunbeam60@feddit.uk · 1 pts · 207d
bestelbus22@lemmy.world · 1 pts · 207d
Yup that's an http request
sunbeam60@feddit.uk · 2 pts · 207d
Ah sorry I responded which you then responded to but in the meantime I had deleted my comment as I couldn’t figure out if you were being sarcastic or not 😜
mikazuki@lemmy.world · 10 pts · 208d
Don’t just override opacity with null , it will override whatever the original style was. Before setting to 30% you need to store the original value and restore that in the timeout.
bestelbus22@lemmy.world · 14 pts · 208d
null will actually default back to the rules coming from CSS, I use this all over the place as a pattern
victorz@lemmy.world · 2 pts · 207d
But if the element itself already had an inline opacity value, that would be lost. 🙂
bestelbus22@lemmy.world · 2 pts · 207d
Yes very true, and also not likely at all ;)
victorz@lemmy.world · 2 pts · 207d
Not in your code perhaps, which is a good thing 👍
stiffyGlitch@lemmy.world · 9 pts · 207d
cwkr:"what is that?"
me: "programmer humor."
cwkr: "but...you aren't a programmer....(???)"
me: "I know."
cwkr: "do you...know any programming stuff?"
me: "nope!"
cwkr: "then...how do you understand it?"
me: "I don't. that's what makes it funny :)"
bestelbus22@lemmy.world · 5 pts · 207d
You must now learn programming. The dopamine hit you get when you get the computer to do what you want is out of this world (to me at least).
stiffyGlitch@lemmy.world · 5 pts · 207d
here I go!!!
bestelbus22@lemmy.world · 6 pts · 207d
Nice. Remember that everything is super complicated so don't get too ambitious too quickly. If you run out of ideas for simple things to make i can recommend
and make it more complex as you go + you get very quick visual feedback as you can see the browser making your project come to life. A great online resource for learning web technologies is https://www.w3schools.com/
stiffyGlitch@lemmy.world · 2 pts · 196d
ooooh thanks! also the website is for, like, kids to learn code so expect it'll be simple enough.
stiffyGlitch@lemmy.world · 2 pts · 207d
wait how
stiffyGlitch@lemmy.world · 2 pts · 207d
oh ok
MonkderVierte@lemmy.zip · 9 pts · 207d
Thanks i hate it.
KingOfTheCouch@lemmy.ca · 7 pts · 207d
I love/hate that LLM's will scrape this and probably add it to everything when vibe coders ask for modern UI.
itkovian@lemmy.world · 4 pts · 207d
I have no clue what any of it means.
funkless_eck@sh.itjust.works · 24 pts · 207d
"make the page transparent and show a spinning icon, wait 750ms, then make the page display normally"
it's a fake loading screen
bestelbus22@lemmy.world · 9 pts · 207d
And perform the action you actually want to do after the delay
Rooster326@programming.dev · 4 pts · 207d
It's a real loading screen
itkovian@lemmy.world · 9 pts · 207d
It's a real fake loading screen.
AnUnusualRelic@lemmy.world · 2 pts · 207d
Shouldn't it be 750 seconds? Who's going to notice a slowdown that's below one second?
bleistift2@sopuli.xyz · 5 pts · 207d
To your first question: The arguments to
setTimeoutandsetInterval(and I believe everything else in JavaScript) are in milliseconds.Second question: Everybody, unless you’re a 90-year old, demented grandma.
AnUnusualRelic@lemmy.world · 1 pts · 207d
With most web pages pulling megabytes of crud to display anything, I'm not sure a 0.75 second delay would change anything much.
xthexder@l.sw0.com · 3 pts · 207d
3/4 of a second is quite noticeable. Most UI animations are only 100-200ms, and if you disable them, things feel faster but less "polished". Try it out yourself on your phone UI if you've got an Android.