Skip to content

Instantly share code, notes, and snippets.

View aofleejay's full-sized avatar
🐢
Keep going

aofleejay

🐢
Keep going
View GitHub Profile
@aofleejay
aofleejay / Dockerfile
Created June 28, 2019 10:44
Dockerfile for deploy React application from create-react-app using Docker multi-stage builds.
FROM node:12.4.0-alpine as build
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY src ./src
COPY public ./public
RUN yarn build
FROM nginx:1.17.0-alpine
COPY --from=build /usr/src/app/build /usr/share/nginx/html
@aofleejay
aofleejay / index.js
Last active September 20, 2019 03:52
Set mongodb document expiration from mongoose.
const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost:27017/playground', {
useNewUrlParser: true,
})
const catSchema = mongoose.Schema(
{
name: String,
age: Number,
@aofleejay
aofleejay / yarnOrNpm.js
Created March 3, 2020 12:46
Script to choose between yarn or npm.
const path = require('path')
const spawn = require('cross-spawn')
const execSync = require('child_process').execSync
const root = path.resolve('project')
let command
let args = []
try {
execSync('yarn -v', { stdio: 'ignore' })
@aofleejay
aofleejay / index.jsx
Last active February 25, 2022 15:42
Reduce size of images and videos before upload to server using react-native-image-picker. ref: https://github.com/react-native-image-picker/react-native-image-picker#options
import React, {useState} from 'react';
import {Pressable, Text, View} from 'react-native';
import {launchImageLibrary} from 'react-native-image-picker';
import RNFetchBlob from 'rn-fetch-blob';
const App = () => {
const [selectedAssets, setSelectedAssets] = useState([]);
const selectAssets = async () => {
const response = await launchImageLibrary({