Skip to content

Instantly share code, notes, and snippets.

View kmylo's full-sized avatar
🎯
Focusing

kmylo kmylo

🎯
Focusing
View GitHub Profile
@MarceloPrado
MarceloPrado / useToggleStorybook.ts
Created October 18, 2023 12:32
Dynamically toggle between storybook and app
import { config } from "@/app/config";
import { createLogger } from "@/app/observability";
import { useEffect } from "react";
const { appEnv } = config;
const logger = createLogger("developer/storybook");
export const useToggleStorybook = () => {
const [isStorybookEnabled, setIsStorybookEnabled] = useState(false)
@jacob-ebey
jacob-ebey / deferred-overview.md
Last active February 28, 2025 05:42
Deferred Overview

Remix Deferred

Remix Deferred is currently implemented on top of React's Suspense model but is not limited to React. This will be a quick dive into how "promise over the wire" is accomplished.

SSR + Hydration

It isn't rocket science, but a quick recap of how frameworks such as react do SSR:

  1. Load data
  2. Render the app
@dcatanzaro
dcatanzaro / botcito_galicia.js
Last active January 26, 2024 22:36
Botcito para el Galicia
const axios = require("axios");
let lastIndexMovement = 0;
const TELEGRAM_BOTID = "";
const TELEGRAM_CHATID = "";
class Telegram {
sendTelegramMessage(message) {
const botId = TELEGRAM_BOTID;
@getify
getify / 1.md
Last active March 2, 2023 21:24
In defense of using blocks to create localized scope for variables... (part 1 of 2)
@colinhacks
colinhacks / log_json_shortcuts.json
Created January 16, 2022 23:50
VSCode shortcuts for console.log and JSON.stringify
// keybindings.json
// Command Pallette > Open Keyboard Shortcuts (JSON)
[
{
"key": "cmd+shift+l",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "console.log(${TM_SELECTED_TEXT}$1)$0;"
@viannaandreBR
viannaandreBR / .wslconfig
Last active November 10, 2024 19:14
.wslconfig
# Settings apply across all Linux distros running on WSL 2
# https://docs.microsoft.com/pt-br/windows/wsl/wsl-config
[wsl2]
# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
#memory=4GB
memory=4GB
# Sets the VM to use two virtual processors
#processors=2
@pshaddel
pshaddel / simples_class_decorator.ts
Created December 22, 2021 15:50
Simple Class Decorator That Logs on Console
function firstClassDecorator(constructor: Function) {
console.log("first class decorator");
}
@firstClassDecorator
class User {
public isActive: boolean;
public role: "admin" | "user";
constructor() {
console.log("calling class constructor");
interface Task {
  id: number;
  title: string;
  completed: boolean;
  createdAt: Date;
}

interface CreateTaskDto extends Omit<Task, 'id' | 'createdAt'> {}
interface UpdateTaskDto extends Omit<Partial<Task>, 'id'> {}
@9paradox
9paradox / usePartialState.tsx
Last active September 24, 2024 12:40
Easy to use Generic Typescript React custom Hook for Handling multiple inputs and saving state for properties of type or object.
import react, { useState } from "react";
const usePartialState = <T extends Partial<T>>(): [T | {}, (fieldName: string, value: any) => void, (state: T) => void] => {
const [state, setState] = useState<T | {}>({});
const setStateByFiled = (fieldName: string, value: any) => {
setState(_s => {
return {
..._s,
[fieldName]: value,
@roshanlabh
roshanlabh / react-phone-book.js
Created January 24, 2021 13:10
Coderbyte - React Phone Book [solution]
import React, { useState } from "react";
import ReactDOM from "react-dom";
const style = {
table: {
borderCollapse: "collapse",
},
tableCell: {
border: "1px solid gray",
margin: 0,