6 ms·
I remember how magical and mysterious a view counter used to feel when I was a kid. How did the website know when someone visited it? Where was the count stored
by sillysaurusx 4y ago
I remember how magical and mysterious a view counter used to feel when I was a kid. How did the website know when someone visited it? Where was the count stored? And how on earth could a website update its own HTML to show the new count?
Geocities days were magical. I wonder if kids today have similar thoughts about Twitter profiles and such. It’s probably much easier to pick up the knowledge — back then, it was balkanized across IRC and whatever we used before Google.
I also started writing a FF7 walkthrough all on a single page, because I didn’t know how to link from one page to another. I made the different chapters different font colors, reasoning that it was good enough to change the color when you’re trying to figure out which section to get to. Good times…
EDIT: Whoa. The view count is real time. You can see how quickly HN is hammering the page by refreshing it. The guestbook works too. I wonder what the tech stack looks like.
Doing this in modern times would be so complicated. You’ll need a database, then software to talk to the database, and maybe webpack.
- zitterbewegung 4y agoGeocities got reincarnated as https://glitch.com/ https://glitch.com/ and it has many more features and you can clone others sites or starter packs.
- seba_dos1 4y ago> Doing this in modern times would be so complicated. No, it wouldn't. All you need to store this kind of data is a simple file. Most people would probably use PHP for something like that due to its ubiquity, but it could even be a few lines of bash, or Python, or Go, or whatever...
- ElectricalUnion 4y ago> All you need to store this kind of data is a simple file. You mostly likely need a WAL Mode SQLite database. Most of the time, it's way simpler that handling state handling in concurrent situations yourself. (also, bindings are often available - if not outright bundled by default - under most common languages) The "easy" way is all fun and games until your file is accessed in a concurrent fashion, and then your options are: a) flat out die when concurrent things happens (file locks; default sqlite3 behaviour); b) just write blindly to file and pretend concurrecy doesn't exist, but randomly lose data - (write to files directly like a crazy person; sqlite3 PRAGMA schema.synchronous = OFF) c) allow reading at anytime, but serialize writing somehow (file locks + write + move atomic file operations; append writing and a journal; sqlite3 PRAGMA journal_mode=WAL)
- Supermancho 4y ago> You mostly likely need a WAL Mode SQLite database Or redis.
- doublerabbit 4y ago> You mostly likely need a WAL Mode SQLite database. Overkill, If you are writing to the text file only to increment a number of visitors, none of what you mentioned above is even required. Create a "counter-hit" file for each visitor, count the number of files in the resources directory. Populate the master file with the file count and delete all the temporary files. Configure it on a crontab for say every three seconds. Online now was even easier. IFrame refresh within the homepage. Upon refresh, populate the file with something like "online=true". Read the file every X, if the file modifcation hasn't been refreshed within 30 seconds, nerf the text file and mark that user as offline. psuedo-dynamic, but times were different then. I coded these in perl back in the day for my RTCW clan and how I miss it much. Being a webmaster was art, an art that's now lost..
- artificial 4y ago64 Player Depot. I always had a fondness for Tram. Played CAL Main. Good times. v43
- EvanAnderson 4y ago(I'm probably getting some details wrong here because this was all nearly 30 years ago, but anyway...) The realtime hit counter and fascination therewith brought up a memory. Back in '95 the regional dial-up ISP I used offered personal website hosting on one of their boxes (the standard http://www.isp.com/~username http://www.isp.com/~username gig). I was very excited to put up a personal website. That was fun for awhile but soon I wanted to do more with it. I liked the look of hit counters, guest books, etc. I became annoyed because this "CGI" thing I'd read about didn't work. I could FTP up Perl scripts named with ".cgi" filenames, however accessing them only resulted in seeing the Perl code. I setup a webserver (NCSA httpd) on my Slackware box and started experimenting. I learned about .htaccess files and, more importantly, learned I could override the server's main httpd.conf with directives in my directory's .htaccess file. A little experimenting with my ISP's web server turned up that, sure enough, they had not configured "AllowOverride None". Lo and behold I could enable server-side includes[0] in my directory-- including executing CGIs via SSIs! Once I figured out how to chmod +x my scripts thru the FTP server I was in business. I had a hit counter! I had a script to check the referer (sic) and add a link in the footer back to the "main page" if you didn't "come from" there. I wrote out my own log files (because I didn't have access to the server's main log file) so I could see the IPs, user agent strings, and referers of visitors. (I also learned about file locking and parallel execution of the script by multiple requests occurring simultaneously. Fun!) (The ISP didn't offer shell access but I figured out, pretty quickly, that I could write a rudimentary web shell with my SSI-based CGIs. I didn't do too much with that because I didn't want to get caught and I'd mostly gotten the desire to do "unauthorized pro-bono remote system administration" out of my system by that time...) This little "site" my friend and I ran got listed on Yahoo (we submitted it... >smile<). I remember seeing a bunch of clients with reverse-lookups of the form "xxx.yahoo.com" that day. Wired had recently done an article on Yahoo[1]. I saw a client named "srinija.yahoo.com" and remembered the article talked about a "Srinija Srinivasan" being an employee there (working on ontology). It was really exciting to see somebody named in a Wired article accessing my silly little site. (The most memorable client name from Yahoo was "ratbastard.yahoo.com", BTW. I'd love to know the backstory. Guess I already wrote about this once...[2]) [0] https://www.oreilly.com/openbook/cgi/ch05_01.html https://www.oreilly.com/openbook/cgi/ch05_01.html [1] https://www.wired.com/1996/05/indexweb/ https://www.wired.com/1996/05/indexweb/ [2] https://news.ycombinator.com/item?id=16741431 https://news.ycombinator.com/item?id=16741431
- xwdv 4y agoYoung kids today do not have any kind of thoughts about the workings of apps they use any more than they have thoughts about how their favorite shows or movies are made, or how their house was built, or how a car works.
- bee_rider 4y agoIf by young kids, you mean college students, hahaha.
- 2b3a51 4y agoRound here some of the teenagers show promise as tinkerers. Reverse engineering the e-scooters so you don't have to pay is popular. Old cars everywhere being rebuilt and modified. One guy has added a small engine to his pushbike using some kind of gear wheel coupling. They are making their own short films and fashion shoots now the Sun is out. Lets face it a smartphone is all you basically need to create (some kind of) media now.
- sgt 4y agoDIY is huge in 2023. Just look at YouTube.
- wellanyway 4y agoYelling at sky much?
- deleted 4y ago[deleted]
- lostlogin 4y agoThis is a very HN take on ‘kids these day’ complaints which seem to go back as far as human records do. https://www.reddit.com/r/history/comments/7btv14/the_more_things_change_the_more_they_stay_the/ https://www.reddit.com/r/history/comments/7btv14/the_more_th...
- johnbellone 4y agoI feel like you could do this without a database using the Linux kernel inotify API. Every time a file is accessed trigger an increment. It’s too beautiful of a day outside to try this right now but an interesting brain teaser!
- LorenDB 4y ago> It’s too beautiful of a day outside to try this right now That's what laptops are for!
- stronglikedan 4y agoIf you're just sitting outside, you may as well be inside.
- hammyhavoc 4y agoMy mood says otherwise.
- prmoustache 4y agoOnly if your laptop has some e-ink/e-paper tech screen really.
- hammyhavoc 4y agoSitting in the shade works for me, but yes, e-ink or STN works well (decades-old tech).
- SoftTalker 4y agoPretty sure Linux didn't have inotify then. Probably a CGI script updates a counter in a file.
- smashed 4y agoCan confirm, that's how it was done. A simple text file.
- bennyp101 4y agoPretty sure the first guestbook/counter I wrote were in perl and wrote to a text file :D
- washadjeffmad 4y agoThere are (still) dozens of us!
- warner25 4y ago> I wonder if kids today have similar thoughts I'm sure that some do, and most don't. Most kids 30 years ago didn't have similar thoughts either. Few people are meant to be programmers, engineers, etc. Were you not shunned as a nerd for having an interest in how computers worked?
- SoftTalker 4y ago> Were you not shunned as a nerd for having an interest in how computers worked? I remember those days. There was one table in the lunch room where the 10 or so kids who were into computers sat. I found out later talking to some other classmates that nobody else wanted to talk to us because they thought they weren't smart enough.
- hammyhavoc 4y agoChrist, that there were other kids with an interest in computers is amazing. I sat on my own lmao.
- warner25 4y agoI had a friend to sit with at lunch and talk to excitedly about computers, PC gaming, robots, military hardware, etc. This was in the 90s.
- hobo_in_library 4y agoyou guys had friends?
- doublepg23 4y ago> Were you not shunned as a nerd for having an interest in how computers worked? I certainly wasn’t in the 10s. Usually people would come to me and my nerd buddies for PC building advice, smartphone advice, and of course the occasional “can you pirate this for me” request ;)
- Gasp0de 4y agoWhy would it be more complicated today than back then? Just use Python, write the view counter into a text file and use javascript with polling (or websockets) for the realtime refresh.
- Eumenes 4y agoyou could do this on an ftp server, no need for webpack and databases
- math-ias 4y ago[dead]
- geenat 4y agoSimilar to how the upcoming WAL2 works in SQLite, could do it atomically or "concurrent safe" like: - Main count file. - 2 "Append" files. ====== - Append 'a' to append file 1. - After some time, swap append file 1 with 2. - Count up 'a' in non-active append file 1, add it to main count. Then just repeat, swapping append files.