Skip to content

Instantly share code, notes, and snippets.

View ozantunca's full-sized avatar

Ozan Tunca ozantunca

View GitHub Profile
@ozantunca
ozantunca / Dockerfile
Created August 18, 2019 13:41
Dockerfile example for Medium
FROM node:12
COPY . /app
WORKDIR /app
RUN npm install
CMD ["npm", "test"]
FROM node:5.10
RUN apt-get -y update && apt-get clean
RUN apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3 && \
echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install yarn
RUN yarn global add pm2
ADD . /srv/www
WORKDIR /srv/www
@ozantunca
ozantunca / nestedPick.js
Last active August 29, 2015 13:57
An underscore.js mixin for picking nested properties by keeping the nested structure.
_.mixin({
nestedPick: function (obj, wantedKeys) {
var resultObj = {};
_.forEach(wantedKeys, function (key) {
// Parsing nested keys. Making it so that a[b] equals a.b
var nestedKeys = key.replace(/\[(["']?)([^\1]+?)\1?\]/g, '.$2').replace(/^\./, '').split('.')
, finalVal = {}
, dummy = {}
, recVal = obj[nestedKeys[0]]
, j = 1