Skip to content

Instantly share code, notes, and snippets.

@Kristian-Roopnarine
Kristian-Roopnarine / example.js
Created November 27, 2020 17:44
example NODE_ENV
let dbURI;
if (process.env.NODE_ENV ==='development'){
dbURI = process.env.DATABASE_LOCAL_DB
}
if (process.env.NODE_ENV ==='test'){
dbURI = process.env.DATABASE_TEST_DB
}
if (process.env.NODE_ENV ==='production'){
dbURI = process.env.DATABASE_PROD_DB
}
@Kristian-Roopnarine
Kristian-Roopnarine / .env
Created November 27, 2020 17:41
node_env blog
NODE_ENV=development
DATABASE_DEV_URL=<insert_URI_to_local_db>
DATABASE_TEST_URL=<insert_URI_to_test_db>
DATABASE_PROD_URL=<insert_URI_to_prod_db>
@Kristian-Roopnarine
Kristian-Roopnarine / .dockerignore
Created November 18, 2020 01:55
Docker ignore
node_modules
version: '3.7'
services:
web:
stdin_open: true
image: #insert app name
build:
context: .
dockerfile: Dockerfile.dev
volumes:
@Kristian-Roopnarine
Kristian-Roopnarine / Dockerfile
Created November 18, 2020 01:51
Dev Dockerfile
# base image that comes with NodeJS
FROM node:14.15-alpine
# set working directory inside Docker container
WORKDIR /app
# add node to path to access npm commands from cli
ENV PATH /app/node_modules/.bin:$PATH
# copy package.json and package-lock to install dependencies in Docker container
@Kristian-Roopnarine
Kristian-Roopnarine / reverse_linked_list.py
Created July 8, 2020 12:02
Code to reverse a singly linked list
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
# check if head exists or if there are at least 2 nodes.
if head is None or head.next is None:
return head
else:
current_node = head
while current_node.next is not None:
const ProjectCard = (props) => {
const renderDemoButton = () => {
if (props.demo === ""){
return (
<button className="ui disabled button">
Demo
</button>
)
const Projects = () => {
const [projectInfo,setProjectInfo] = useState([]);
const fetchProjects = async () =>{
const response = await projects.get('/projects/')
setProjectInfo(response.data)
}
const createProjectCards = () => {
return(
import React, {useState,useEffect} from 'react'
import ProjectCard from './ProjectCard'
import projects from '../apis/projects'
const Projects = () => {
const [projectInfo,setProjectInfo] = useState([]);
const fetchProjects = async () =>{
const response = await projects.get('/projects/')
setProjectInfo(response.data)
import axios from 'axios'
export default axios.create({
baseURL:'http://localhost:8000/api'
})