Skip to content

Instantly share code, notes, and snippets.

View kunokdev's full-sized avatar
🦾
Using GitHub Copilot

kunokdev

🦾
Using GitHub Copilot
View GitHub Profile
@kunokdev
kunokdev / main.js
Created November 22, 2018 21:54
FizzBuzz created by kunokdev - https://repl.it/@kunokdev/FizzBuzz
function iterationCreator(num, valueFactory, actionFactory){
for (let i = 1; i <= num; i++) {
actionFactory(valueFactory(i))
}
}
function fizzBuzz(num){
if (num % 3 === 0 && num % 5 === 0) return 'FizzBuzz'
if (num % 3 === 0) return 'Fizz'
if (num % 5 === 0) return 'Buzz'
@kunokdev
kunokdev / docker-compose.yml
Last active May 3, 2019 18:49
create-react-app generated react app configured via docker-compose environment variables
version: "3.2"
services:
my-react-app:
image: my-react-app
ports:
- "3000:80"
environment:
- "API_URL=https://production.example.com"
@kunokdev
kunokdev / step1.sh
Created December 13, 2018 23:17
Create react app with with environment variable inside .env
# Generate React App
create-react-app cra-runtime-environment-variables
cd cra-runtime-environment-variables
# Create default environment variables that we want to use
touch .env
echo "API_URL=https//default.dev.api.com" >> .env
@kunokdev
kunokdev / step2.sh
Last active December 13, 2018 23:46
Create Nginx configuration
# Create directory for Ngnix configuration
mkdir -p conf/conf.d
touch conf/conf.d/default.conf conf/conf.d/gzip.conf
@kunokdev
kunokdev / default.conf
Created December 13, 2018 23:30
Minimal default Nginx configuration
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
expires -1; # Set it to different value depending on your standard requirements
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
@kunokdev
kunokdev / gzip.conf
Created December 13, 2018 23:36
Minimal gzip.conf for Nginx
gzip on;
gzip_http_version 1.0;
gzip_comp_level 5; # 1-9
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
# MIME-types
gzip_types
application/atom+xml
@kunokdev
kunokdev / step3.sh
Created December 13, 2018 23:45
Create Dockerfile and docker-compose
touch Dockerfile docker-compose.yml
version: "3.2"
services:
cra-runtime-environment-variables:
image: kunokdev/cra-runtime-environment-variables
ports:
- "5000:80"
environment:
- "API_URL=production.example.com"
@kunokdev
kunokdev / index.html
Created December 15, 2018 17:10
Include file that will inject configuration
<script src="%PUBLIC_URL%/env-config.js"></script>
@kunokdev
kunokdev / env.sh
Last active June 7, 2023 13:04
Reads each line of .env file, uses env var value is set, otherwise default value from .env file itself
#!/bin/sh
# line endings must be \n, not \r\n !
echo "window._env_ = {" > ./env-config.js
awk -F '=' '{ print $1 ": \"" (ENVIRON[$1] ? ENVIRON[$1] : $2) "\"," }' ./.env >> ./env-config.js
echo "}" >> ./env-config.js