Skip to content

Instantly share code, notes, and snippets.

Avatar

emily dela cruz emdecr

View GitHub Profile
@emdecr
emdecr / get-non-unique-values.js
Last active Aug 19, 2020
Get all non-unique values (i.e.: duplicate/more than one occurrence) in an array
View get-non-unique-values.js
// 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 {
@emdecr
emdecr / nginx_production_images.conf
Last active Jul 28, 2020
Serve missing media from a production server when dev site is at a subdirectory.
View nginx_production_images.conf
# 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;
}
You can’t perform that action at this time.