Skip to content

Instantly share code, notes, and snippets.

View revskill10's full-sized avatar
🎯
Focusing

Truong Hoang Dung revskill10

🎯
Focusing
  • Freelancer
  • Haiphong, Vietnam
View GitHub Profile
@revskill10
revskill10 / nginx.conf
Created November 11, 2018 04:29 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs
# Advanced config for NGINX
server_tokens off;
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options nosniff;
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
@revskill10
revskill10 / server.js
Created November 8, 2018 06:35 — forked from magicspon/server.js
using https with next
const https = require('https')
const { parse } = require('url')
const next = require('next')
const fs = require('fs')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
const options = {
@revskill10
revskill10 / index.js
Created November 8, 2018 05:56 — forked from tkh44/index.js
Getting react-leaflet working with SSR (next.js)
import React from 'react'
export default class extends React.Component {
constructor () {
super()
this.state = { components: undefined }
this.markers = new WeakMap()
}
componentDidMount () {
@revskill10
revskill10 / App.js
Created October 25, 2018 18:31 — forked from aweary/App.js
import React from "react";
import useMutableReducer from "./useMutableReducer";
const reducer = (draft, action, state) => {
switch (action) {
case "increment":
draft.count++;
break;
case "decrement":
draft.count--;
@revskill10
revskill10 / react-cloudinary.js
Created October 20, 2018 01:47 — forked from stolinski/react-cloudinary.js
Client side Image Upload To Cloudinary React Dropzone
// get's called from react dropzone when file is dropped
onImageDrop = (files) => {
this.handleImageUpload(files[0]);
}
async handleImageUpload(file) {
const data = new FormData();
data.append('file', file);
data.append('upload_preset', CLOUDINARY_UPLOAD_PRESET);
const upload = await fetch(CLOUDINARY_UPLOAD_URL, {
@revskill10
revskill10 / mapDispatchToProps.md
Created October 11, 2018 21:10 — forked from heygrady/mapDispatchToProps.md
Redux containers: mapDispatchToProps

Redux containers: mapDispatchToProps

This document details some tips and tricks for creating redux containers. Specifically, this document is looking at the mapDispatchToProps argument of the connect function from [react-redux][react-redux]. There are many ways to write the same thing in redux. This gist covers the various forms that mapDispatchToProps can take.

@revskill10
revskill10 / index.ts
Created October 6, 2018 11:53 — forked from josephktcheung/index.ts
Stitching schema with subscription
import { GraphQLServer, Options } from 'graphql-yoga'
import { mergeSchemas } from 'graphql-tools';
import { getRemoteSchema } from "./remoteSchema";
import { SubscriptionClient } from 'subscriptions-transport-ws';
import * as ws from 'ws';
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config()
}
@revskill10
revskill10 / 1.js
Created September 14, 2018 18:54 — forked from getify/1.js
tag function for formatting console.log(..) statements
function logger(strings,...values) {
var str = "";
for (let i = 0; i < strings.length; i++) {
if (i > 0) {
if (values[i-1] && typeof values[i-1] == "object") {
if (values[i-1] instanceof Error) {
if (values[i-1].stack) {
str += values[i-1].stack;
continue;
}
@revskill10
revskill10 / index.md
Created September 10, 2018 15:36 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

Create React App

At the moment, the only way to enable production profiling in CRA apps is to eject and modify the production Webpack configuration file (config/webpack.config.prod.js) as shown below:

react-dom@^16.5.0 / schedule@^0.4.0

module.exports = {
  output: {
@revskill10
revskill10 / Emotion.go
Created September 2, 2018 10:47 — forked from owulveryck/Emotion.go
Rekognition test
package main
import (
"bufio"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/rekognition"
"github.com/blackjack/webcam"
"os"