Skip to content

Instantly share code, notes, and snippets.

View Geezgus's full-sized avatar
🎯
Focusing

Gustavo Duarte Geezgus

🎯
Focusing
View GitHub Profile
@Geezgus
Geezgus / create-state-context.jsx
Last active July 18, 2025 22:23
A generic, type-safe React context factory that simplifies creating stateful contexts with built-in useState management, lazy initialization support, automatic displayName assignment for better debugging, memoized context value to optimize re-renders, and runtime checks to ensure correct usage, making it easy to share isolated state across compo…
// You can use this if not using typescript
'use client';
import { createContext, useContext, useMemo, useState } from 'react';
export function createStateContext(displayName) {
if (typeof displayName !== 'string' || !displayName.trim()) {
throw new Error(
'Invalid displayName: expected a non-empty string. ' +
{
"export default class": {
"scope": "typescript, typescriptreact",
"prefix": "exdefc",
"body": [
"export default class $TM_FILENAME_BASE {",
" constructor(${1:readonly }${2:arg}: ${3:any}) { $0 }",
"}"
],
"description": "\"export default\" a class with file name"
[
{
"codigo": "987654",
"referencia": "PN1234567890",
"descricao": "Disco de Freio Dianteiro",
"marca": "Frenomatic"
},
{
"codigo": "123456",
"referencia": "PN0987654321",
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner input = new Scanner(System.in);
// Menu
Item[] menu = new Item[] { new Item(1, "Cachorro Quente", 4.00),
org 100h
main:
mov si, init_si
mov cx, bufsize
jmp write_file_name
jmp open_file
jmp read_from_file
; write 77h to memory address 69807h
org 100h
mov bx, 6000h
mov ds, bx
mov al, 77h
mov [9807h], al
ret