After a brief dormancy (3 years?!), my two iOS apps have been updated.Returning to SwiftUI has been pleasurable, but yet more hoops to jump through when publishing on the AppStore. Luckily, this post by Inderjeetsandhu details the Privacy declaration for use of UserDefaults.standard
.
Skip to write cross platform native apps
Skip looks a really interesting piece of technology. If it works well, would be well-worth the price of the small business license ($29 per month).
Platform-specific API use (e.g. GPS data and accelerometer) could be extracted into separate Swift methods, with a transpiler directive to gate by platform:
#if os(Android)
print("Android")
#else
print("iOS")
#endif
Wow, reading about this report on cruise ships and their environmental impact in yesterday’s The Guardian “First Edition” email. This quote blew my mind:
…compared to flights more generally, cruises produce considerably more carbon emissions per passenger-kilometre: twice as much as the equivalent flights plus hotel stays for the same period.
Reading about Apple’s reluctance to open up PWA to 3rd party browsers in the EU has thrown up two ideas new to me regarding bullshit: https://en.wikipedia.org/wiki/Brandolini%27s_law and https://en.wikipedia.org/wiki/Hitchens%27s_razor. Thank you infrequently.org/2024/02/h…
A list of best sci-fi. Nice touch to place the Hitchhikers Guide at #42!
Plenty of these are dropping into my reading list. 75 Best Sci-Fi Books of All Time - What Is The Best Science Fiction Book Ever Written?
I generally agree with John Gruber on how the Digital Markets Act is hard to comply with, but it’s interesting that Apple is now on the receiving end of the know-it-when-I-see-it rules that iOS devs have had to work under for 15 years.
I don’t fancy going through teething again as an adult, it looks like hell as a baby. But tooth regrowth could be just six years away for general public use. World-first tooth-regrowing drug will be given to humans in September
I know little about design, past keeping it simple with few colours and two fonts. This looks like a great guide to work by: Visual design rules you can safely follow every time
Years late, I’ve been watching Homeland on Netflix and later on Disney+. After eight seasons, I couldn’t work out how they would end Carrie’s story. But they hit the perfect note, a great conclusion.
I love PostgreSQL. It’s the most amazing piece of software. It can do so much, with so few wobbles, crashes and bugs. So why do text UIs refuse to do what you so clearly want?
reporting=> /q
reporting-> exit
Use \q to quit.
reporting-> \q
📸 Windy
Installing h3-pg extension for https://postgresapp.com
Repeat whenever postgres.app is updated.
(Setup the paths)[https://postgresapp.com/documentation/cli-tools.html]
Build from source and install:
gh repo clone zachasme/h3-pg
cd h3-pg
make
make install
Hat tip to https://github.com/PostgresApp/PostgresApp/issues/683#issuecomment-1274754377
I had a vague memory that some flies were like Matryoshka dolls. So here we go, more than you wanted to know about aphids: www.youtube.com/watch
I wonder why https://guides.rubyonrails.org/active_record_postgresql.html does not seem to be linked from the guides index?
Using a binary string returned from ActiveRecord
When a DB query returns a binary string, this needs unescaping before use. The case that brought this to light for me was a relatively complex PostGIS query which generates a MapBox vector tile lines geometry imported from OpenStreeMap data:
WITH bounds AS (
SELECT ST_TileEnvelope(#{@zoom}, #{@x}, #{@y}) AS envelope
),
tile_geom AS (
SELECT ST_AsMVTGeom(ST_Transform(l.geom, 3857), bounds.envelope)
FROM planet_osm_line
)
SELECT ST_AsMVT(*) FROM tile_geom;
While all my carreer has dealt with integer, string or even JSON data in the DB, this binary response was new to me. Outputting the result from a Rails controller for consumption by a MapBox GL instance was frustrating, as the tile data was received, but not displayed.
The output from ST_AsMVT()
is a protobuf, so not easy to confirm correctness, but pasting the response body into a tool like protobuf-decoder can help verify if the data is a valid protobuf.
The solution was to return the respone unescaped by unescape_bytea()
:
ActiveRecord::Base.connection.unescape_bytea(response.rows.first&.first)
Well, I’ve been coding in Rails for around 15 years, and I’m still learning…
I just finished reading: Slaughterhouse 5 by Kurt Vonnegut 📚 It occurs to me that we are all time travellers, just most of us are stuck at 1x in a forward direction, with no random access.
News & Podcasts
2024 has lots of potential, but I’ve stopped opening news apps or scrolling for my mood and state of mind.
The subset of things I can influence are much smaller than the set of inputs. So now I get a daily news summary email, and that’s it. I don’t follow links from those articles.
I’m still listening to political podcasts though, which give a deeper understanding of what’s going on and why. I can recommend pod save the UK and The Rest Is Politics for a UK perspective.
Reading this left me both upbeat and sad that there is no Manhattan Project effort that all political leanings can get behind.We Can Already Stop Climate Change If We Want To
However, the articles did lead me to make sunsets which looks to be an excellent start. For $9 you can sponsor the launch of 1g of sulphur dioxide into the upper atmosphere to reflect incoming sunlight to negate the equivalent heating effect of one ton of carbon dioxide.
For someone with an estimated personal carbon footprint of 7 tons, this is doable.
They also have a monthly subscription!
I love this take on Pac-Man. I expect copies to be all over the AppStore within days though 🤬 PAKU PAKU
Having grown up on Sinclair spectrum and then MS-DOS and Windows, I was a late comer to the Apple ecosystem ( a MacBook Core 2 Duo being my first device ). I now know why the Apple logo has a bite (byte?) out of it.
Cory Doctorow’s new book might just leap to the front of my “to read” list.
This is a great summary of rules for generating APIs, including many points I have not considered before. github.com/stickfigu…
Migrating a Dokku application to a new server
Assuming a few things:
- the original server is still running, and that the new server cannot be bootstrapped from an image or backup of the old server (for example, they are with different hosts)
- Dokku has been installed on the new server and is accessible using the dokku user (See https://dokku.com)
- We have an SSH config entry for both old and new servers in ~/.ssh/config:
host new_server RequestTTY yes Hostname 55.190.140.231 User dokku IdentityFile ~/.ssh/id_rsa Host old_server RequestTTY yes Hostname 55.78.183.109 User dokku IdentityFile ~/.ssh/id_rsa
Create new app
ssh new_server apps:create icepop_app
Fetch env vars for original
ssh old_server config:show icepop_app
Set important keys (not DOKKU_*)
ssh new_server config:set icepop_app RAILS_MASTER_KEY=VALUE EMAIL_API_KEY=VALUE MAP_API_KEY=VALUE
Add new git remote repo based on the current one
git remote -v
git remote add new_server dokku@new_server:icepop_app
Create new DB
ssh new_server postgres:create icepop_app_production
Link DB to the new app
ssh new_server postgres:link icepop_app_production icepop_app
Dump the data from the old DB You might want to do this at a slow time to minimise lost updates, or introduce the maintenance page.
ssh old_server postgres:export icepop_app-production > ~/Downloads/sql/icepop_app_production.dump
Import the dump
ssh new_server postgres:import icepop_app_production < ~/Downloads/sql/icepop_app_production.dump
Deploy the project
git push new_server deploy:main
Add domains to the app
ssh new_server domains:add icepop_app www.icepop_app.com icepop_app.com
Configure SSL certificate(s) via letsencrypt
ssh new_server letsencrypt:set icepop_app email james@icepop_app.com
Check where the DNS is configured and move the A records to point to the new server using the registrar’s UI whois will give you a clue which registrar you used if you’re anything like me and have three in use.
whois icepop_app.com
Request SSL certificates
ssh new_server letsencrypt:enable icepop_app
Tail the logs to ensure traffic is flowing as expected
ssh new_server logs -t icepop_app
Connect to the Rails console to check changes are reflected in the browser
ssh new_server run icepop_app "bundle exec rails console -e production"
All being well, your app is migrated (remember to check for any local file uploads etc) and the old server can be decomissioned.
I really enjoy reading Thomas’ work, it’s always deep and interesting. This is especially cool.