Writing
Notes on building software — the decisions that age well, the ones that don't, and what I learn in between.
-
What It Took to Deploy This Site with Kamal
One config file, two accessories, and a one-line deploy script — plus the two things that nearly shipped placeholder posts to a live site.
-
Running my site through an MCP server
The admin area of this site has a second front door: a Model Context Protocol server at POST /mcp. Here is what that takes in Rails — JSON-RPC over one route, a bearer token, and twenty tools that go through the same models as the browser.
-
How to Use the Ls Command on Linux or Mac OS X to Sort Files based on Second in the Timestamp
Here is the one liner. ls -lhtTr It will output something like total 24152 -rw-rw-r-- 1 sean staff 1.0M May 4 14:31:42 2019 4c2caf52cb084ea39a6a65a0e68ee382 -rw-rw-r-- 1 sean staff 1.0M May 4...
-
Super Simple Router for React Without Any Dependencies
Here is some very simple code to render React components dynamically without using a framework or routing library. It doesn't cover pushState and URL parsing, so in that sense it isn't a routing...
-
Rails Style Params in Python and Flask
Ruby on Rails does a great job of parsing arrays in form data and populating a params hash, for quick and easy access in your controllers. For instance <input name="item[]" value="item 1"/ <input...
-
How to Reset and Clear a Form Field or Textarea with Stateless Components in React
Stateless components are nice. They are simple to use and understand but can become tricky when you start thinking about data and how to manage state. In general, the consensus seems to be that if...
-
How to Read and Write to a Single Cell Using PHP and Google Spreadsheets API
This post assumes you've created a project with Google's web console and downloaded a clientsecret.json file from the credentials page. If not, more info is here.....
-
How to Flatten and Merge Arrays in PHP
There is no built in function for taking a multi dimensional array in PHP and flattening it into a single array. However, it's pretty easy to accomplish in a one liner. Here is the code <?php $a =...
-
Parsing URL Parameters with Swift
Here is an extension you can use in your Swift (v4) projects that makes it easy to parse parameters from a url. Given a url like, "http://example.com/?x=1&y=2", you can extract the x and y...
-
How to Handle Uploading Really Large Files in PHP
PHP has some default limits that do not work out of the box when you want to work with uploading very large files. So there are a few configuration changes you have to make to the defaults that...
-
How to Chunk Large Files in Swift
How to Chunk Large Files in Swift (4.1) It takes a bit of work but this is the solution I found that finally worked, thanks to this Stack Overflow thread...
-
Select Basename in Postgres SQL
Postgres doesn't have a basename function per se. But it's easy to accomplish. select regexpreplace('http://www.seanbehan.com/images/logo.png', '.+/', '') ; -- Will return logo.png
-
How to Extract all Images from a Webpage with Ruby
Here is a little ruby snippet that will download all pictures from a webpage. Rather than using XPath, we are going to first reduce the source code to capture everything inside of quotes. Some...
-
How to Get GPS Location Information from Address String with Swift and iOS CLGeocoder
You can use CLGeocoder geocodeAddressString method. It will return an array of CLPlacemark objects that contain gps coords and city, location info. let address = "Burlington, Vermont"...
-
How to Get GPS Location Information from a Photo or Movie with Swift and UIImagePickerController
This code assumes you're using the UIImagePickerController. If not you will need to get an image url another way. But, If you are using UIImagePickerControllerDelegate then it will supply the...