Skip to content

Instantly share code, notes, and snippets.

View maitrungduc1410's full-sized avatar
💪
Keep chasing your dreams!

Duc Trung Mai maitrungduc1410

💪
Keep chasing your dreams!
View GitHub Profile
@maitrungduc1410
maitrungduc1410 / resize.js
Created October 31, 2018 07:51
Resize image to squared image from input file before send server
var tmppath = URL.createObjectURL(file) // create temporary path of file
var img = new Image()
var offset = 0
let self = this
img.onload = function() {
if(this.width < this.height) {
offset = this.width
}
else {
offset = this.height
@maitrungduc1410
maitrungduc1410 / .env
Last active March 14, 2019 08:55
SG_DECODING_WEBSITE
MONGO_ROOT_USERNAME=root
MONGO_ROOT_PASSWORD=ce2pFD2jJNmqNJkG
MONGO_HOST=localhost
MONGO_PORT=27017
APP_MONGO_DB=sg-decoding
APP_MONGO_USER=user
APP_MONGO_PASS=ZfQDwQYN4T6PQARY
@maitrungduc1410
maitrungduc1410 / .env
Last active March 27, 2019 09:24
Sg-decoding-ONLINE
MONGO_ROOT_USERNAME=root
MONGO_ROOT_PASSWORD=ce2pFD2jJNmqNJkG
MONGO_HOST=localhost
MONGO_PORT=27017
APP_MONGO_DB=sg-decoding-online
APP_MONGO_USER=user
APP_MONGO_PASS=ZfQDwQYN4T6PQARY
@maitrungduc1410
maitrungduc1410 / nginx.conf
Created March 28, 2019 07:31
Nginx default configuration file
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
@maitrungduc1410
maitrungduc1410 / nginx.conf
Last active May 30, 2019 03:19
Nginx setup for Nodejs
server {
listen 80;
listen [::]:80;
server_name _; # change this to your domain name
# 2 lines of code below to hide your server info. You have to install nginx-extras to enable it
# on Ubuntu run: sudo apt-get install nginx-extras
more_clear_headers Server;
server_tokens off;
@maitrungduc1410
maitrungduc1410 / index.html
Last active November 6, 2019 09:26
Change Bootstrap tooltip content dynamically on click button
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>tooltip</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
@maitrungduc1410
maitrungduc1410 / Dockerfile
Created December 27, 2019 12:10
Docker nginx
FROM debian:buster-slim
LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"
ENV NGINX_VERSION 1.17.6
ENV NJS_VERSION 0.3.7
ENV PKG_RELEASE 1~buster
RUN set -x \
# create nginx user/group first, to be consistent throughout docker variants
@maitrungduc1410
maitrungduc1410 / nginx.conf
Created February 17, 2020 05:25
Nginx forward request to Docker container
server {
#root /var/www/html/portfolio/public;
server_name jamesisme.com www.jamesisme.com;
if ($host = jamesisme.com) {
return 301 https://www.jamesisme.com$request_uri;
}
location / {
@maitrungduc1410
maitrungduc1410 / data.json
Last active May 10, 2020 11:10
Data sample for VueJS blog
[
{
"gender": "male",
"name": {
"title": "Mr",
"first": "Apostolos",
"last": "Blohm"
},
"location": {
"street": {
@maitrungduc1410
maitrungduc1410 / app.js
Last active May 27, 2020 08:55
Editorjs
import React, { useRef } from 'react';
import EditorJS from '@editorjs/editorjs'
const App = () => {
const editor = useRef()
const init = () => {
if (!editor.current) {
editor.current = new EditorJS({
holder: 'editorjs',