Garrett builds web sites

Professional PHP web dev since 2007. I don't follow accounts that post about politricks too much.
PHPを使っているウェブ開発者。

Garrett builds web sitesAlbright@phpc.social
2025-07-10

I recently found out about Nostr and Bitchat. They look like really fun and interesting projects and I'd love to play with them, but at this point in my life I feel like I don't have the luxury of being able to play with things which are unlikely to make me any money in the short-to-medium term.

In other news I still haven't won the lottery. That shit *has* to be rigged.

Garrett builds web sitesAlbright@phpc.social
2025-06-30

Not gonna lie - I've been pretty crunched for money the last… several years, so I'll throw this out there: If you might be in need of the services of someone who's been a professional web developer for almost two decades and cares more about code quality and user experience than using the flashy framework/language/database of the week, please reach out and let's talk. Check out my other posts for an idea of some of the stuff I've worked on over the years.

Garrett builds web sitesAlbright@phpc.social
2025-06-27

@ghostwriter So instead of doing `if ($profile === null) { return; }` or whatever you'd just go ahead and call methods on $profile and they'd just do nothing? That sounds like a bunch of potential confusion to me, and inefficient. But maybe I just don't get it.

Garrett builds web sitesAlbright@phpc.social
2025-06-26

@ghostwriter But why though? Spell it out for me.

Garrett builds web sitesAlbright@phpc.social
2025-06-26

Thank you to whatever idiot recently redid Authy's UI and somehow made it worse. Which one of these key icons and email address combinations hides the code I need right now? Tapping them doesn't show any clue as to what site they're associated with. Can I clean this up by deleting those, or will I be locking myself out of something down the road? *(shrug)*

Why is this "list" not a proper list on its own screen? Why not show at least as much info as the previous version. Is Authy dogfooding?

Garrett builds web sitesAlbright@phpc.social
2025-06-26

@andrewrk But you'll make the cartoon owl sad if you don't check in with him every day. :..(...

Garrett builds web sitesAlbright@phpc.social
2025-06-23

@jimw I feel like Matrix could be that if it simplified things. It made some poor choices when balancing security/encryption and user-friendliness in my opinion.

Garrett builds web sitesAlbright@phpc.social
2025-06-22

And to expand a bit on the foreign keys bit, note that that pragma change is *not* saved to the database for future connections - you really do have to run it on every connection. That means if someone "fixes" the database by manually connecting and doing manual SQL inserts/deletes without running that pragma line, your data may now be fff… er, in an unexpected state. Good thing SQLite makes backups easy and they made one before messing with things, right?

Garrett builds web sitesAlbright@phpc.social
2025-06-22

To expand a bit, on the "column type not respected" part, if adding STRICT isn't an option, you can use CHECK on column definitions to validate many things at INSERT time. For example, the CHECK constraint on the following columns will make them work as you'd otherwise expect:

`username varchar(31) NOT NULL CHECK (length(username) < 31)`
`verified unsigned bool NOT NULL CHECK (verified IN (0, 1))`

For datetimes, do `typeof(datetime(column_name)) = "text"`.

sqlite.org/lang_createtable.ht

Garrett builds web sitesAlbright@phpc.social
2025-06-22

With these changes in place, the stupidity is nearly eliminated and SQLite becomes absolutely as usable as MySQL or Postgres particularly in low-write and single-server situations, and with its own unique benefits - since all the data is in a single file, making backups or local copies is just a matter of using cp/scp/rsync rather than having to bother with dumping and importing.

Garrett builds web sitesAlbright@phpc.social
2025-06-22

The latter can be most reliably fixed by changing a compile-time flag, but if you can't/don't want to manage how SQLite is compiled on whatever systems your app will run on, you can run `PRAGMA foreign_keys = ON` after the SQLite "connection" is made, before any other commands expecting these constraints to work are run (if you're using some sort of DB connection manager or ORM, you might have to fight/hack it to make this happen).

sqlite.org/pragma.html#pragma_

Garrett builds web sitesAlbright@phpc.social
2025-06-22

SQLite is simultaneously the greatest and the stupidest database system in existence. The stupid parts: By default, neither column type nor foreign keys are respected.

To fix the former, put the STRICT keyword at the end of table definitions on creating them, like `CREATE TABLE foo (…) STRICT`. (Already have an existing database? You can't add STRICT with ALTER TABLE - gotta recreate the database tables, dump from the old ones, and import into the new.) sqlite.org/stricttables.html

Garrett builds web sitesAlbright@phpc.social
2025-06-18

Going to be adding several thousands of markers to a MapLibre map? It turns out you don't want to add markers; you want to add "symbols." Markers are for some reason done via DOM objects, so you'll run into the same performance issues which have probably driven you towards MapLibre in the first place. Unfortunately symbols are kinda sporadically-documented. Useful links: github.com/maplibre/maplibre-g maplibre.org/maplibre-gl-js/do maplibre.org/maplibre-gl-js/do

Garrett builds web sitesAlbright@phpc.social
2025-06-18

@alessandrolai @davesh The project in question isn't even using proper classes for some things, though - it's stuff like `new stdClass()` or `(object) […];` For example, database query result rows. (It's an "organically grown" CodeIgniter 3 project.) The client is aware of these issues, but of course keeping the existing project going and making money is higher priority than spending a bunch of time rewriting the guts of it for no immediate profit (understandable, though unfortunate).

Garrett builds web sitesAlbright@phpc.social
2025-06-18

@davesh That PHP 8.2 deprecates dynamic class properties means I think there’s going to be a lot of projects stuck on 8.1 for a long time. My biggest client’s site sure will be.

Garrett builds web sitesAlbright@phpc.social
2025-06-16

@derickr Thanks for this. I had found this page previously, but it got buried amongst other tabs and you linking it to me caused me to have another look at it, particularly the "find the tile for a point" algorithms which of course turned out to be more accurate than my own algos.

I've been hitting my head against this for a few days now but I had a big breakthrough today and that algo was part of it.

Garrett builds web sitesAlbright@phpc.social
2025-06-14

determine how many degrees of latitude a pixel covers, right?

Right? I don't know. I just know with what I've got right now, things are off vertically, and that's my best guess as to why currently. I'm going to dive in and try it. Thoughts and prayers are appreciated…

Garrett builds web sitesAlbright@phpc.social
2025-06-14

because the range of latitude is -90 degrees to 90 degrees, both of those "lines" representing a point at the north and south pole respectively - so that's 180 degrees. Except, wait, -90 degrees and 90 degrees are not the same line as they are with longitude, so that means… there are actually 181 degrees of latitude, because there's also 0, and like if you counted from -10 to 10, you would say 21 numbers even though the difference is 20, so we would divide 181 by the pixel height of the world to

Garrett builds web sitesAlbright@phpc.social
2025-06-14

tile, right? And at level 1, it's a 2x2 square, level 2 it's a 4x4 square, right? Okay, so at zoom level X the width and height are both are (2^X) * 256. So for latitude (north-south) lines, they run from -180 to 180 degrees, except the -180-degree line and the 180-degree line are the same line, but whatever, we can divide 360 by the world width in pixels to determine how many degrees latitude one pixel represents, right? Okay, we can do the same for latitude (west-east), right? Except no,

Garrett builds web sitesAlbright@phpc.social
2025-06-14

Don't think I can give details right now but I'm working on mapping stuff and specifically trying to place 2D images on a map that is trying to represent the world and wants me to give lat/lng coordinates for everything. So how would I center this image at 0,0 on the map? Get image width/height, divide by two, and, uh… calculate how many pixels represents how many degrees of lat/lng at the current zoom level, which can be done by… okay, so at zoom level 0 the whole world is one 256 pixel square

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst