Skip to content

Instantly share code, notes, and snippets.

View r17x's full-sized avatar
🤘
REconciling...

RiN r17x

🤘
REconciling...
View GitHub Profile

How to check service worker has installed in your browser

const z = await navigator.serviceWorker.getRegistrations() // return array Of [ServiceWorkerRegistration]
/***
[{
active: ServiceWorker {scriptURL: "http://localhost:5000/service-worker.js", state: "activated", onerror: null, onstatechange: ƒ}
installing: null
navigationPreload: NavigationPreloadManager {}
onupdatefound: ƒ ()
paymentManager: PaymentManager {instruments: PaymentInstruments, userHint: ""}
@r17x
r17x / dockerizeNginx.sh
Last active February 17, 2019 09:14
Dockerize Nginx with Node for static files
#!/bin/bash
# create Dockerfile
# make sure this script run in your app directory
# I'm use node v8.12.0 (you can change)
cat <<EOF > Dockerfile
FROM node:8.12.0 as buildx
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <title>Downlod File</title>
    <script>
      function downloadBlob(data, filename) {
        const responseData = window.URL.createObjectURL(new Blob([data]));
@r17x
r17x / osx-wifi.md
Last active February 7, 2019 04:09
Nothing special

Just command for forgotten wifi password

security find-generic-password -ga "ROUTERNAME" | grep "password:"
@r17x
r17x / example.md
Created January 15, 2019 16:51
Looping Assets in Create-react-app

an Example Looping Assets like CSS, JS & Font in Create-React-App

  • cra-project/public/index.html
    <% for ( var css in htmlWebpackPlugin.files.css ) { %>
        <link rel="preload" as="style" href="<%=htmlWebpackPlugin.files.css[css]%>" as="style" onload='this.rel="stylesheet"'>
    <% } %>
    <% for ( var js in htmlWebpackPlugin.files.js ) { %>
        <link rel="preload" as="script" href="<%=htmlWebpackPlugin.files.js[js] %>" as="script">
    <% } %>
# test on Mac Mojave
# this command for stuck GPG Verify
gpgconf --kill gpg-agent
@r17x
r17x / gcp_enum.sh
Created January 7, 2019 04:33 — forked from carnal0wnage/gcp_enum.sh
use the gcloud utilities to enumerate as much access as possible from a GCP service account json file. see blog post: <to insert>
# gcloud auth activate-service-account --key-file=85.json
# gcloud projects list
project="my-projet"
space=""
echo "gcloud auth list"
gcloud auth list
echo -e "$space"
@r17x
r17x / setupTest.md
Last active April 22, 2019 11:34
Setup Test in ReactJs With Jest Enzyme & etc
  • create setupTests.js in src/setupTests.js (automatically CRA read setupTest.js)
// setupTests.js
import React from "react";
import Adapter from "enzyme-adapter-react-16";
import Enzyme, { configure, shallow, mount, render } from "enzyme";
import { createSerializer } from "enzyme-to-json";
import sinon from "sinon";

expect.addSnapshotSerializer(createSerializer({ mode: "deep" }));
@r17x
r17x / gpggithub.md
Last active June 23, 2019 13:40
GPG Signing Key For Github
  • Setup Basic
$ git config --global user.name "name"
$ git config --global user.email "email"
  • Installation
# mac
$ brew install gpg
# brew install gpg2