sql Find duplicate rows in table with SQL There are constructs where you shouldn't have duplicate column combinations in a table. Best protection against it, is a combined unique constraint. But depending on when you join the project, it might already be to late and you might already have those duplicates in your table. It'
Check PHP extensions requirement with composer When configuring your server, you need to know which PHP extensions need to be installed and updated. But through changing dependencies it's possible that you don't need certain extensions any more. Or you've included a new dependency which needs a new extension. Previously much
Flexible CORS headers with Heroku and Capacitor CORS headers are an important security feature which you should take advantage of. There are some use cases where you have to supply specific urls for it. For example when you're building an hybrid app and use cookies and credentials in your request, as there you can'
typescript Round Moment.js to previous interval When working with dates and times it's not unusual to restrict the options a user can choose. For example when presenting the user with a dropdown of times to choose from, but only allow 5min intervals. You want to add a sensible default, for example the previous interval.
postgres Add NOT NULL constraint on column in Postgress You can't just add a new non-nullable column to a table when it already has entries in it, as those would be pre filled with NULL. An easy solution is to create it with DEFAULT NULL, update the data and then make it non-nullable. This can look like
The domain has to be simple, no abstraction Basically everybody knows the KISS principal (keep it simple, stupid). But unfortunately most of the time it get's overwritten by the DRY principle (don't repeat yourself) which gained traction through the Clean code movement. In general there is no problem with the principal itself, but as
symfony Adapt timezone for PHP worker on Heroku When working with custom timezones and Heroku, you have to make sure to add the timezone everywhere. I've published a post recently how to configure it for the web dyno and Postgres [/adapt-timezones-on-heroku]. In usual hosted environments there is a php.ini file where you add the timezone
symfony Symfony Messenger with custom serializer Using the JSON serializer makes the messages a lot more readable. But there are still instances where this is not enough or might even be a step back from the default serializer. For example when using UUIDs. When you want to have this, you need to define a custom serializer.
symfony Symfony messenger with JSON messages When you start a new project with the Symfony messenger component, the messages will be serialized through the PHP serialization. This has the advantages that you don't need a constructor with all properties and no public properties. On the other hand when you look into the database to
symfony Symfony route parameter with slash as part of the parameter Usually the parameter you put in your url looks something like this: api_with_token: path: '/api/update-user/{token}' defaults: { _controller: App\Controller\UserController::update } methods: [POST] With this there is no way for your parameter to include a /. If you call the url /api/update-user/my/token
heroku Adapt timezones on Heroku I'm using the dynos of Heroku and the Postgres database addon from Heroku. Both are on UTC by default and Heroku is specifically advising against changing it. So make sure you know the repercussions. Dynos For the dynos you can simple use an environment variable called TZ and
heroku Custom fonts on Heroku There are a few special buildpacks to deploy custom fonts to your Heroku dyno. The most straightforward way I found isn't documented with Heroku, but can be found through a few articles. Simply create a new directory called .fonts in the root of your project and put your
vuetify Checkbox group in Vuetify There is already a component for a radio group from Vuetify, but if you want to handle multiple checkboxes, you're out of luck. It doesn't seem to likely, that this will change any time soon as a Github issue for it was closed by the maintainer
typescript Record with optional keys with Typescript The Record type in Typescript is very useful. With it you can define an abstract object in more detail. This is very helpful when building a base interface for extending. With it you can do things like this: export interface CommandWithFiles { body: object; files: Record<string, File>; } export
ios Check for Safari browser Luckily browser tests aren't as necessary anymore as they used to be. But there are still situations where you going to need them. For example when using a feature only available and only needed in it (like in an hybrid app). Here is a simple expression to check
phpstorm Don't break import in PHPStorm for Typescript When ignoring max length rules for imports in Typescript [/use-ignore-pattern-of-eslint-for-max-lenth-to-allow-for-long-import-lines/], PHPStorm still will break the imports automatically be default. But there is a setting for this: Go to Editor > Code Style > Typescript > Wrapping and Braces and switch ES6 import/export from Chop down if long to Do
apache Disable cache with .htaccess Simple cache removal through .htaccess: <IfModule mod_headers.c> Header set Cache-Control "no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires 0 </IfModule> Handy when you want to make sure that a user will always load new files from the server.
symfony UUIDs with serializer in Symfony Internally I've long switched to UUIDs instead of auto increment columns for my Doctrine entities. But as soon as I'm in the realm of business logic or serialization, I always convert the UUIDs to strings. Which doesn't really makes sense as I loose a
htaccess Return empty options response through htaccess Many hybrid apps use the web container of the OS like WebView to render the app components. Those then also perform their API requests through the web container. Internally this means that every request is only done after an OPTIONS request to the same url and this means there has
git Check for git changes with bash When running a deployment, I want to make sure, that all changes have been committed to git before it's executed. There is a special flag --porcelain for the git status command which does exactly this check. Wrap this in an if command and you're good to
symfony Upload fixture files to Cloudcube on every review app creation The automatic creation of review apps is one of the biggest advantages of using Heroku. But what about using files in your S3 bucket? I've build a Symfony console command to upload files automatically to Cloudcube through flysystem. The command receives a path to a directory with fixture
heroku Add maintenance mode while still using Cors headers on Heroku Heroku offers a maintenance mode. With it, the dyno isn't reached and an iFrame with a maintenance HTML page is shown. But unfortunately it can't be customized any further than customizing the HTML page which is shown in the iFrame. This is problematic when building an
Loop through date range of two dates in PHP Very useful when creating entries from one date to another. The basic way would be the following: $startDate = new \DateTime('2020-06-01'); $endDate = new \DateTime('2020-06-30'); for($date = $startDate; $date <= $endDate; $date->modify('+1 day')){ echo $date->format(\DateTime::ATOM); } The one
typescript Use ignore pattern of eslint for max-lenth to allow for long import lines When working with Vue and Typescript the default settings for eslint are to complain about lines longer then 140 characters. Which works great for the usual code but not for imports. Putting every class / function in to a separate lines works but makes for a lot of scrolling. Using ignore
htaccess Enforce https redirect in htaccess depending on environment variable Ever run into the the problem that you need to have a htaccess redirect on the production system but don't want to have it on your local machine? Usually today it's not that difficult to setup a local self signed certificate any more. But there are