Skip to content

Instantly share code, notes, and snippets.

@emdecr
emdecr / nginx_production_images.conf
Last active July 28, 2020 22:44
Serve missing media from a production server when dev site is at a subdirectory.
# Case: Dev site hosted at subdirectory (NGINX)
# ie. https://dev.site/sub
# Serve Missing Media from a Production Server
# https://rzen.net/serve-missing-media-production-apache-nginx/
location ~* \.(js|css|png|jpe?g|gif|ico)$ {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
}
@emdecr
emdecr / get-non-unique-values.js
Last active August 19, 2020 22:10
Get all non-unique values (i.e.: duplicate/more than one occurrence) in an array
// https://stackoverflow.com/questions/840781/get-all-non-unique-values-i-e-duplicate-more-than-one-occurrence-in-an-array
// Approach 1
var names = ['Mike', 'Matt', 'Nancy', 'Adam', 'Jenny', 'Nancy', 'Carl']
// Use .map to return an array of objects with two keys (count, name)
// Use .reduce to get an object with total count for each unique Name { Mike: 1 ... }
var unique = names
.map((name) => {
return {