Skip to content

Instantly share code, notes, and snippets.

View sidwebworks's full-sized avatar
💫
Trying my best

Sid sidwebworks

💫
Trying my best
View GitHub Profile
@sidwebworks
sidwebworks / main.js
Created August 21, 2022 23:18
Node async test
'use strict';
const fs = require('fs');
const crypto = require('crypto');
const http = require('http');
// Current timestamp
const start = Date.now();
// Simple Logging util
@sidwebworks
sidwebworks / Autocomplete.js
Created June 20, 2022 17:54 — forked from mwrouse/Autocomplete.js
Autocompletion for an object in the monaco editor
function ShowAutocompletion(obj) {
// Disable default autocompletion for javascript
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({ noLib: true });
// Helper function to return the monaco completion item type of a thing
function getType(thing, isMember) {
isMember = (isMember == undefined) ? (typeof isMember == "boolean") ? isMember : false : false; // Give isMember a default value of false
switch ((typeof thing).toLowerCase()) {
case "object":
@sidwebworks
sidwebworks / user-socket.jsx
Last active February 12, 2022 18:10
A hook system for managing socket.io client connections
import { createContext, useContext, useMemo, useRef } from 'react';
import { io } from 'socket.io-client';
const DEFAULT = {
namespace: '/',
baseUri: process.env.NEXT_PUBLIC_SOCKET_IO_URI,
};
const createSocket = (nsp, conf = {}) => {
return io(new URL(nsp, DEFAULT.baseUri).href, conf);
@sidwebworks
sidwebworks / esbuild-plugin-template.ts
Created November 18, 2021 11:54
Basic template for esbuild javascript api plugin
import * as esbuild from "esbuild-wasm"
export const unpkgPathPlugin = () => {
return {
name: "unpkg-path-plugin",
setup(build: esbuild.PluginBuild) {
build.onResolve({ filter: /.*/ }, async (args: any) => {
console.log("onResole", args)
return { path: args.path, namespace: "a" }
})
@sidwebworks
sidwebworks / hook.js
Created September 17, 2021 22:34
Udemy course
import React, { useState, useEffect, useCallback } from "react";
import styles from "./index.css";
import mojs from "mo-js";
const initialState = {
isClicked: false,
count: 0,
countTotal: 3400,
};