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,
};
<!-- !CONTACT -->
<section id="contact" class="text-gray-600 body-font relative">
<div class="container mx-auto px-5 lg:px-24 py-10 my-8 flex sm:flex-nowrap flex-wrap">
<div
class="lg:w-2/3 md:w-1/2 bg-gray-300 rounded-lg overflow-hidden sm:mr-10 p-10 flex items-end justify-start relative">
<iframe width="100%" height="100%" class="absolute inset-0" frameborder="0" title="map"
marginheight="0" marginwidth="0" scrolling="no"
src="https://maps.google.com/maps?width=100%&height=600&hl=en&q=%C4%B0zmir+(My%20Business%20Name)&ie=UTF8&t=&z=14&iwloc=B&output=embed"
style="filter: grayscale(1) contrast(1.2) opacity(0.4);"></iframe>
<div class="bg-white relative flex flex-wrap py-6 rounded shadow-md">
@sidwebworks
sidwebworks / Learning Javscript
Created February 1, 2021 18:17
Learning Javscript
var dataBase = [{
username: "User 1",
password: "pass@user1"
},
{
username: "User 2",
password: "pass@user2"
},
{
username: "User 3",