Skip to content

Instantly share code, notes, and snippets.

View antonybudianto's full-sized avatar

Antony Budianto antonybudianto

View GitHub Profile
find . -name '*.tmp' -delete
{
"name": "my-razzle-app",
"version": "2.0.0-alpha.8",
"license": "MIT",
"scripts": {
"start": "razzle start",
"build": "razzle build",
"pkg": "npx pkg build/server.js -t node8-macos -d",
"test": "razzle test --env=jsdom",
"start:prod": "NODE_ENV=production node build/server.js"
@antonybudianto
antonybudianto / compile.js
Created August 7, 2018 06:34
Egold old compile.js
// const fs = require('fs-extra')
const webpack = require('webpack')
const debug = require('debug')('app:bin:compile')
const webpackClientConfig = require('../config/webpack.client.config')
const webpackServerConfig = require('../config/webpack.server.config')
const project = require('../config/project.config')
// Wrapper around webpack to promisify its compiler and supply friendly logging
const webpackCompiler = (webpackConfig) =>
new Promise((resolve, reject) => {
@antonybudianto
antonybudianto / Modalportal.js
Created September 10, 2018 10:48
Modal using portal
import React from 'react';
import ReactDOM from 'react-dom';
import css from './Modal.css';
let modalRoot;
class Modal extends React.Component {
constructor(props) {
super(props);
server {
location ~* (serviceworker\.js)$ {
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
expires off;
proxy_no_cache 1;
}
}
@antonybudianto
antonybudianto / nginx.conf
Created January 20, 2019 04:57 — forked from johngrimes/nginx.conf
Ideal Nginx configuration for JavaScript single-page app
server {
listen 80;
root /usr/share/nginx/html;
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
gzip_comp_level 9;
etag on;
location / {
try_files $uri $uri/ /index.html;
}
server {
listen 80;
listen [::]:80;
server_name hello.antonybudianto.com;
# root /usr/share/nginx/html;
root /home/ec2-user/web/hello/build;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
}
function cur (n) {
let minus = n < 0
n = minus ? Math.abs(n) : n
return (minus ? '-' : '') + (n).toString().split('').reverse().reduce((a,b,i) => i % 3 === 0 ? a+'.'+b : a+b).split('').reverse().join('')
}
const registerServiceWorker = async () => {
const swRegistration = await navigator.serviceWorker.register(
'/service-worker.js'
)
return swRegistration
}
const requestNotificationPermission = async () => {
const permission = await window.Notification.requestPermission()
// value of permission can be 'granted', 'default', 'denied'
location.search.substring(1).split('&').map(p => p.split('=')).reduce((a,c) => {
a[c[0]] = c[1]
return a
}, {})