Skip to content

Instantly share code, notes, and snippets.

View reyhansofian's full-sized avatar

Reyhan Sofian reyhansofian

View GitHub Profile
apiVersion: v1
kind: Service
metadata:
labels:
test-app: test
name: test
namespace: default
spec:
externalTrafficPolicy: Cluster
ports:
// @ts-check
const express = require("express");
const app = express();
const fs = require("fs");
const bodyParser = require('body-parser');
// volume mount path
const mountPath = "/etc/config";
@reyhansofian
reyhansofian / app.js
Last active September 1, 2020 13:26
Using environment variable on NodeJS app
const http = require('http');
const PORT = 8080;
const server = http.createServer((req, res) => {
const MYSQL_CONNECTION = process.env.MYSQL_CONNECTION;
const MYSQL_USER = process.env.MYSQL_USER;
const MYSQL_PASSWORD = process.env.MYSQL_PASSWORD;
});

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

@reyhansofian
reyhansofian / SingletonEnforcer.js
Created December 11, 2017 01:49 — forked from uran1980/SingletonEnforcer.js
ES6 singleton pattern: use Symbol to ensure singularity
// http://stackoverflow.com/a/26227662/1527470
const singleton = Symbol();
const singletonEnforcer = Symbol();
class SingletonEnforcer {
constructor(enforcer) {
if (enforcer !== singletonEnforcer) {
throw new Error('Cannot construct singleton');
}
const express = require('express');
const { graphqlExpress, graphiqlExpress } = require('apollo-server-express');
const bodyParser = require('body-parser');
const bunyan = require('bunyan');
const mysql = require('mysql2');
const graphQLServer = express();
const logger = bunyan.createLogger({ name: 'server' });
const GRAPHQL_PORT = 3003;
let g:neoformat_javascript_prettier = {
  \ 'exe': 'prettier',
  \ 'args': ['--single-quote'],
  \ 'replace': 0,
  \ 'stdin': 1,
  \ 'no_append': 1
  \ }
let g:neoformat_enabled_javascript = ['prettier']
if filereadable(glob(".vimrc.local"))
source .vimrc.local
endif
// FilmDetail.js
import React, { Component, PropTypes } from 'react';
import { gql, graphql } from 'react-apollo';
import {
Text,
View,
} from 'react-native';
@graphql(gql`
query($id: ID!) {
@graphql(gql`
query($id: ID!) {
film(id: $id) {
title
openingCrawl
director
producers
releaseDate
}
}