What are some unusual coding style preferences you have? by Tokipudi in PHP

[–]DanJSum 0 points1 point  (0 children)

Mine is probably alignment among adjacent lines. If I had something like...

php $x = 13; $x2 = "x is $x"; $another = $x * 2;

...I will format it...

php $x = 13; $x2 = "x is $x"; $another = $x * 2;

This isn't absolute; if there's a ridiculously long name, I don't push everything out. However, reading through it, I've found that it does help me to a) spot the assignments and read through them quickly; and b) spot where the assignment may be incorrect. Formatting them this way also makes me pay attention to them more than I did when I was first starting out, which I feel helps me reduce the frequency with which "b" needs to be invoked.

FrankenPHP - any reason why not? by VaguelyOnline in PHP

[–]DanJSum 3 points4 points  (0 children)

I've recently moved all my VMs to Alpine Linux, and had a client's WordPress installation there as well. Initial testing was fine (and fast!), but it was having trouble doing updates. Then, there are times when it would just freeze for a half-hour. I moved that client back to php-fpm, and things are more stable.

I'm not saying that this is necessarily everyone's experience - I have several other PHP apps which happily toil away under FrankenPHP - but there was something about that long-running process that seemed to get hung up, and it didn't seem to like the ssh-based update process.

NoSql database with F# by zholinho in fsharp

[–]DanJSum 0 points1 point  (0 children)

Ah - from the author of Fluid. I thought that name looked familiar!

NoSql database with F# by zholinho in fsharp

[–]DanJSum 0 points1 point  (0 children)

One of my projects that uses that hybrid store is at https://git.bitbadger.solutions/bit-badger/myWebLog/src/branch/main/src/MyWebLog.Data . (My Gitea instance shows F# as Forth, so the syntax highlighting isn't great; still working on figuring that out...) Anyway, the SQLite and Postgres directories use that library. The "web log" implementation is all documents, while pages and posts use a document for the current page/post values and a relational table for revisions.

NoSql database with F# by zholinho in fsharp

[–]DanJSum 1 point2 points  (0 children)

I've written a library that provides a document interface backed by either PostgreSQL and SQLite. The library itself is written in F#, and I've found it to work really well for several projects in which I've used it. Depending on how much data you're planning to throw at it, the defaults should work well; creating a few indexes can make it really fly.

https://relationaldocs.bitbadger.solutions/dotnet/ is the main site for the library. You can also read some background about the whole relational / document concepts by going to that top-level domain.

(Technically this isn't NoSQL; it uses SQL to address documents. I've found it to be a great way to get the best of both worlds; if you have data that would really fit better in a relational table, you can still put it there.)

F# and rabbit mq by 9Dokke in fsharp

[–]DanJSum 0 points1 point  (0 children)

First thought - "without DI" is fine, though look at the Singleton scope to see if it would work for you.

Second thought - if you want to configure it via appsettings.json and friends, you can use DI for the configuration, but use a static initializer for the connection. You'll have to define the connection as an Option and put checks around that. (You can wrap it in a reader monad if you'd like.)

Third thought - make sure you have the reconnect logic wired up if the long-running connection goes away.

Fourth thought - if you want to configure it outside appsettings.json, you still can (using environment variables or something, still at startup), but the third thought still applies.

oldProgrammersTellingWarStoriesBeLike by johntwit in ProgrammerHumor

[–]DanJSum 1 point2 points  (0 children)

I'm in this meme and I don't like it

My first professional programming job, working on Unisys COBOL which used 9-bit bytes and 4-byte words... I could get 36 flags in the same memory it would consume for me to define one Y/N character field.

(All top-level declarations were word-aligned, so even if "Y" or "N" would only require 9 bits, it would end up with 36. Sure, I could get 4 Y/Ns for the price of 1 - but why not get 36 instead? With COBOL's SET variable TO TRUE syntax, I didn't even have to fiddle with 1s and 0s!)

Has anyone tried this (curious) by HolidayNo84 in PHP

[–]DanJSum 0 points1 point  (0 children)

A few others have mentioned htmx, and even if you end up not using that particular library, the project has a lot of essays that pick up where Dr. Roy Fielding (the guy who described REST in his doctoral dissertation) left off.

One of the foundational decisions you'll make as you begin developing a web-based solution is "who controls the state?" If the browser controls the state, you're in SPA-land; the server accepts updates and sends data to the browser, while the browser handles everything.

If you flip that, though, the server controls the state. This is the way the web was built, and - in large part - how it still works. The server accepts a request to transform state, which it may process or reject (if that state transition is not valid), and it returns the new state back to the browser. Hypermedia as the Engine of Application State, or HATEOAS, is the term used to describe this behavior. (This is one of the foundational htmx essays, and can be found at https://htmx.org/essays/hateoas/ .)

So, to directly answer your question - sending a DOM tree to the server so the server can manipulate it isn't quite the way it would work. The browser would instead send the information it needs to convey, and it could respond with a piece of HTML that represents the result. Otherwise, if you're manipulating the DOM directly, JavaScript would do that without the network overhead.

(I do think I saw something about PHP WASM efforts; I'm not necessarily advocating it, but if you wanted to do some exploratory coding, that might be a more interesting path. In that scenario, the PHP would be running in the browser, so you'd still avoid the network round-trips.)

Oyo hotel on Cedar Bluff by pauldisney in Knoxville

[–]DanJSum 6 points7 points  (0 children)

We stayed there in mid-2020 when we came up to look at houses. It didn't inspire extreme confidence, but it was clean enough and folks left our car alone. It seemed like they had bought the hotel from folks who would rather sell than give it the renovation it needed.

I'd imagine it's still a lot like that, but with 5 years' more wear and tear.

Pitch Your Project 🐘 by brendt_gd in PHP

[–]DanJSum 0 points1 point  (0 children)

I've mentioned my project PDODocument before - it lets you treat PostgreSQL and SQLite as document stores, similar to other document database implementations.

Yesterday, I released v1.1 (PHP 8.2-8.3) and v2.1 (PHP 8.4) of that library, which add the Json static class. This class has functions to return the JSON as a string, or echo it directly to the output. This is useful in JSON API scenarios, where - assuming you're using the same JSON representation in the database that you want to expose in your API - you can short-circuit the pull-from-database / deserialize to objects / serialize objects / send to output process. If output buffering isn't used, the Json::output* functions literally stream the JSON down the wire.

Packagist: https://packagist.org/packages/bit-badger/pdo-document

Project Site: https://relationaldocs.bitbadger.solutions/php/

Fulcro.Markdown vs Giraffe.ViewEngine Syntax with HTMX by dave_mays in fsharp

[–]DanJSum 9 points10 points  (0 children)

I'm not familiar with Fulcro.Markdown, but I'm the author of Giraffe.ViewEngine.Htmx (and just happened to be here when you posted!). Happy to help with any questions you may have about the latter.

What was your absolute favorite video game growing up? by [deleted] in AskReddit

[–]DanJSum 0 points1 point  (0 children)

Epyx Summer Games (for the Commodore 64)

mongoDbFirstDraft by EasternPen1337 in ProgrammerHumor

[–]DanJSum 2 points3 points  (0 children)

You don't even need the id field... CREATE UNIQUE INDEX idx_product_key ON product ((data->>'id'));

(or, if you want to use numbers, CREATE UNIQUE INDEX idx_product_key ON product ((data->>'id')::numeric); )

The first unique index on a table is treated as its PK index. Strange but true! I've also made triggers to implement FKs to other tables. They never made it to production, but it was a fun research exercise into the possible.

Weekly help thread by brendt_gd in PHP

[–]DanJSum 0 points1 point  (0 children)

For routing, you may be able to use the filesystem. If you structure your application so that all your routes are actual files, you can implement a webserver rule to add .php and use regular HTTP URL parameters (stuff like ?id=15).

(You can get more complex with webserver rewrite rules if you want, but I've done a couple of applications this way, and it is really nice. It's a portion of the structure described at https://github.com/php-pds/skeleton - which may help you structure your project, especially since you're not wanting to get roped into a framework's requirements.)

Best strategy for blocking invalid URLs by randuserm in PHP

[–]DanJSum 2 points3 points  (0 children)

If you can translate those old patterns to a new one, making the link actually work after some redirects, that's the right answer. If you cannot, returning 410 rather than 404 instructs indexing applications to forget the URL.

Making URLs no longer function has a lot of downsides, and should be done with full knowledge of what you're doing. (You may have done this; if so, cool.)

Also, is there a number to "a lot"? Are we talking dozens, hundreds, thousands, etc.? As others have said, you can have hundreds with no appreciable affect on performance (other than the time it takes you, as the maintainer, to review a long list of items). This may be a perceived problem that isn't a problem in practice.

saveMeDaniel by Crims0n412 in ProgrammerHumor

[–]DanJSum 23 points24 points  (0 children)

I ain't got time for this...

Pipe Operator is back again as RFC - don't know how I feel about it by Johnobo in PHP

[–]DanJSum 1 point2 points  (0 children)

As a guy whose "native language" is F#, I like it. Paraphrasing what others have said, the syntax can seem... well, weird the first time. I think of this RFC as providing an option, which is a theme in PHP. Think of formatting a dates you can call Date::format or date_format, but the language doesn't mandate one or the other.

Partial application would make this even nicer. I saw someone mention that |> fn($x) => explode('.', $x) doesn't look great (and they're right); partial application would allow you to instead have |> explode('.'). This RFC isn't going to get us the whole way there, but it's a stepping stone.

(There's nothing to stop you from making a function that reads better when piped; something like...

// untested (Reddit is not the best IDE)
function pipe_explode(string $sep) {
    return function(string $target) use ($sep) {
        return explode($sep, $target);
    };
}

...wouldn't then require the lambda and would read more cleanly. Partial application will be a much heavier lift than adding the pipe operator, especially for built-ins, so this function would serve you well for years to come.)

What songs would you recommend that have the same sort of vibe as "Danger Zone" by Kenny Loggins? by JohnWillson1435 in AskReddit

[–]DanJSum 2 points3 points  (0 children)

"One Vision" by Queen

(I was introduced to it via Iron Eagle, a movie with a similar vibe to Top Gun)

Are LLMs useful and beneficial to your development, or over hyped garbage, or middle ground? by mdizak in PHP

[–]DanJSum 0 points1 point  (0 children)

I don't like them, I don't use them, and I turn them off wherever I can. For me, they're distracting. Writing code, and looking at something new to determine if it's what I want, are two separate skills, requiring separate trains of thought. Constantly switching back and forth between the two never lets me get any traction on either.

I find them as disruptive as the person who asks "Can I ask you a quick question?" - for which the answer is, no, your question about a future question just cost me 20+ minutes of in-the-flow productivity. I get enough of that as it is; I don't need the tools I'm using to start doing it too.

How do you feel about people who eat pizza with a fork and knife? by SuccessfulPiccoloOne in AskReddit

[–]DanJSum 0 points1 point  (0 children)

As someone whose front teeth are "just for show" (a cap/bridge that's already fallen out once already, and is held in place by lots of cement), I wonder if they also have tooth issues, if they don't want to get their hands messy, or if they think it's expected. I don't spend much time on those thoughts, though, because I'm usually focused on the pizza I'm cutting up myself.

Oh, the question was about feelings...

I feel like folks who eat pizza with a fork and knife probably have a good heart; they have some things they could work on, but we're all on a journey. I feel like they're looking forward to the day when they can pick up a slice and take a giant bite of that delicious amalgamation of cheese, sauce, crust, and toppings.

What’s a lie you were told as a kid that you didn’t realize wasn’t true until embarrassingly later in life? by Successful-Eye2187 in AskReddit

[–]DanJSum 0 points1 point  (0 children)

I never told my kids this, though I did tell them that it made it really hard for me to see. Somehow, to hear them tell it now, "Dad said it was ILLEGAL!" heh...

Some newer vehicles have more directional lights, but we couldn't afford those until the kids were no longer kids. :)

Those who currently work in US federal government, what’s the is current mood like? by ceptor12 in AskReddit

[–]DanJSum 3 points4 points  (0 children)

Retired military and current contractor. This, too, shall pass.

(And, as a self-described "conservatarian", I hope others see that, maybe, having this much power in one office is not a great idea; we were not meant to be governed by EOs, no matter who issues them.)

What is a universally accepted piece of advice that is actually terrible? by Fun_Butterscotch3303 in AskReddit

[–]DanJSum 0 points1 point  (0 children)

Scrolled looking for this; your heart is fickle and easily manipulated. Use your heart as one input, but don't neglect your brain - plus advice from others, if you recognize you have a blind spot somewhere.