Skip to content

Instantly share code, notes, and snippets.

@Lightnet
Lightnet / AuthProvider.jsx
Created March 7, 2022 22:43
token setup idea and prototype for one token and other refresh token. reactjs
/*
LICENSE: MIT
Created by: Lightnet
*/
import React,{ createContext, useState, useMemo, useContext, useEffect } from "react";
//import useFetch from "../hook/useFetch.mjs";
import {
parseJwt
//, isEmpty
@Lightnet
Lightnet / README.md
Last active March 8, 2022 19:42
use Axios refresh Token API to reduce code repeat

use search engine to learn hook and axios for clean up and reuse.

Worked on refine the code to deal with the user interacting when type when render components.

Create the init instance when it mount.

Added isLoading to make sure the axios instance. One reason is that useEffect mount on when user doing get url on render to get data.

Watch variables and mount interceptors that check for the token expire. If events it will change in interceptors and clean up.

@Lightnet
Lightnet / README.md
Last active March 10, 2022 00:04
react vite express testing logging for file path open link.

Creating logging for React.js.

Note that nodejs and broswer is different one is file path and other is browser path.

Notice that broswer js is tricky depend on the build which is webpack bundle.js if there change in format it goes back to bundle.js instead of src path.

let e = new Error(args);
let stack = String(e.stack)
// fail, go to bundle.js url
@Lightnet
Lightnet / EntityTransformControl.vue
Last active March 23, 2022 22:25
Vuejs TransformControls troisjs
<script setup>
/*
LICENSE: MIT
Created by: Lightnet
*/
// https://sbcode.net/threejs/transform-controls/
// https://github.com/mrdoob/three.js/blob/master/examples/misc_controls_transform.html
// https://threejs.org/examples/#misc_controls_transform
import { TransformControls } from 'three/examples/jsm/controls/TransformControls';
@Lightnet
Lightnet / README.md
Last active March 24, 2022 22:18
Vue 3 Event Bus Plugin
@Lightnet
Lightnet / GunKeys.mjs
Created March 26, 2022 20:21
vue 3.x gun plugin
export const GunInjectKey = Symbol();
@Lightnet
Lightnet / README.md
Last active March 28, 2022 18:36
Vue 3 express

Just simple paste files how simple vue 3 setup on server side.

Notes:

<script type="importmap">
  {
    "imports": {
      "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js"
    }
 }
@Lightnet
Lightnet / denooak.ts
Created July 6, 2022 03:15
Testing the Deno and Oak config type for detail testing.
import {
Application,
Router
} from "https://deno.land/x/oak/mod.ts";
const port = 8000;
const app = new Application({
logErrors: false
});
@Lightnet
Lightnet / README.md
Last active July 18, 2022 17:10
bun js http server cookie simple
@Lightnet
Lightnet / server.js
Created July 28, 2022 02:42 — forked from Jxck/server.js
WebSocket Server Sample Impliment
// Reference
// http://tools.ietf.org/html/rfc6455
// http://www.w3.org/TR/2011/WD-websockets-20110929/
// https://github.com/einaros/ws
// https://github.com/Worlize/WebSocket-Node
// http://ja.wikipedia.org/wiki/WebSocket
// http://www.slideshare.net/You_Kinjoh/javascript-websocket P.68
// http://d.hatena.ne.jp/gtk2k/20120203/1328274962
var log = console.log.bind(console);