Skip to content

Instantly share code, notes, and snippets.


emily dela cruz emdecr

View GitHub Profile
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.
# Serve Missing Media from a Production Server
location ~* \.(js|css|png|jpe?g|gif|ico)$ {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
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
// 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 {