Skip to content

Instantly share code, notes, and snippets.

View nicolasmelo1's full-sized avatar
🤰
Cooking

Nicolas Leal nicolasmelo1

🤰
Cooking
View GitHub Profile
#!/usr/bin/env bash
set -euo pipefail
TASK="${*:-}"
if [ -z "$TASK" ]; then
echo "Uso: sh do-task.sh \"<minha_tarefa>\""
exit 1
fi
@nicolasmelo1
nicolasmelo1 / agent-loop.sh
Last active June 8, 2026 14:26
Agent loop
#!/usr/bin/env bash
set -Eeuo pipefail
# ============================================================
# agent-loop.sh
#
# Orquestra:
# 1. Claude Code -> planejamento
# 2. Hermes Agent -> execução
# 3. Codex -> revisão estruturada
@nicolasmelo1
nicolasmelo1 / main.m
Created April 27, 2026 20:10
Check if its a palindrome
#import <Metal/Metal.h>
#include <iostream>
#include <cstring>
int main() {
@autoreleasepool {
const char* input = "Anotaram a data da maratona";
NSString *objcString = [NSString stringWithUTF8String:input];
NSString *lowerString = [objcString lowercaseString];
NSString *normalized = [[lowerString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] componentsJoinedByString:@""];
@nicolasmelo1
nicolasmelo1 / cli.ts
Last active April 11, 2026 15:18
A simple typescript CLI Code
import { dirname, join } from "node:path";
import { existsSync, readFileSync } from "node:fs";
export function getClosestPackageVersionSync(startDir = import.meta.dir) {
for (let dir = startDir; ; dir = dirname(dir)) {
const filePath = join(dir, "package.json");
if (existsSync(filePath)) {
const pkg = JSON.parse(readFileSync(filePath, "utf8")) as {
version?: string;
@nicolasmelo1
nicolasmelo1 / mark-all-nullable.ts
Last active February 27, 2026 14:58
Marking all nullable through extends or through recreating the object
import { z } from "zod";
const originalSchema = z
.object({
age: z.number(),
name: z.string()
})
// Strict defined on the original object schema
.strict();
type EventTypes = 'rateLimitExceeded' | 'rateLimitDismissed'
function simplePubSub() {
const callbacks = new Map<symbol, (event: EventTypes) => void>
return {
subscribe: (callback: (event: EventTypes) => void) => {
const key = Symbol()
callbacks.set(key, callback);
return () => callbacks.delete(key)
import { stdin as input, stdout as output } from 'process';
import { emitKeypressEvents } from 'readline';
function clearConsole(lengthOfOptions) {
//adapted from sindresorhus ansi-escape module
const ESC = '\u001B['
const eraseLine = ESC + '2K';
const cursorUp = (count = 1) => ESC + count + 'A'
const cursorLeft = ESC + 'G'
/**
* Isso é uma factory function, basicamente é como se tivesse instanciando uma classe, mas faço isso com function,
* prefiro esse padrão do que usar classes. Eu tenho que chamar essa função globalmente antes de começar o app.
*
* IMPORTANTE: Não demorei nem 10 minutos fazendo essa porcaria, então sei lá, recomendo algo mais parrudão pra usar em prod.
* Principalmente algo com tipagem melhor que vc consiga listar os eventos disponiveis e os parâmetros que cada callback recebe.
*/
function simplePubSubFactory() {
const subscribed = new Map<string, Map<symbol, (...args: any[]) => void>>
import { AppState, Linking } from "react-native";
import { useEffect, useRef, useState } from "react";
import { Audio, InterruptionModeIOS } from "expo-av";
import { getNetworkStateAsync } from "expo-network";
import Voice, {
SpeechRecognizedEvent,
SpeechResultsEvent,
} from "@react-native-voice/voice";
import BackgroundTimer from "react-native-background-timer";
{
"app_id": 1966818,
"billing_address": {
"address1": "2259 Park Ct",
"address2": "Apartment 5",
"city": "Drayton Valley",
"company": null,
"country": "Canada",
"first_name": "Christopher",
"last_name": "Gorski",