Postgres Delete Duplicate Rows

This query is to delete duplicate rows on multiple selected columns for Postgres. Just plug in the table_name and columns you want to evaluate duplicates on. This query is the fastest out of several I’ve tried, evaluating and deleting 5 million duplicate rows on 8 columns in about 20 seconds.

Carbon:: First and Last Day of Previous Month

You know you have to query last month’s records all the time (instead of the last 30 days). Here’s how to get those numbers easily with Carbon. We do the extra fancy footwork for the end of the month to avoid simply getting the same last date of the month for the previous month.

Create Index in Postgres

If your query is forcing the db to search through millions of rows to fetch data, indexing a table can help improve performance. Here’s how to do it on Postgres. ELI5 Index If you’re actually five you probably haven’t seen one of those indexes in wooden box that you saw at public libraries, but it … Read more

Check NPM Package Size

If you need to pair down your main js file and want to check what packages are eating up the size, BundlePhobia is a great resource to use. While there are several other tools including CLI tools for discovery, BundlePhobia makes it easy to just search and browse. If you have another way of managing … Read more

Error: Permission denied @ apply2files

homebrew banner

If you are getting the following brew cleanup error “Permission denied @ apply2files”, the top solution is to reset permissions to /user/local. We are going to rewrite permission to the current user. In your terminal copy and paste below. Another solution is to completely reinstall brew. User the code below to uninstall and reinstall. Good … Read more

Fast Insert CSV Data to Laravel From S3

The Story (skip if ya just want the code) I’ve fussed with this problem for weeks. If you need to import massive amounts of csv data (100k to 10mil) to your Laravel site there’s a lot of broken information. Some of it is outdated, others are just bits and pieces. But here’s generally how the … Read more