Skip to content

Instantly share code, notes, and snippets.

View paolodina's full-sized avatar
🔋
always on

Paolo Dina paolodina

🔋
always on
  • 13:22 (UTC +01:00)
View GitHub Profile
@musistudio
musistudio / gemini-cli.js
Last active December 5, 2025 08:00
GeminiCLITransformer
const os = require("os");
const path = require("path");
const fs = require("fs/promises");
const OAUTH_FILE = path.join(os.homedir(), ".gemini", "oauth_creds.json");
// Type enum equivalent in JavaScript
const Type = {
TYPE_UNSPECIFIED: "TYPE_UNSPECIFIED",
STRING: "STRING",
@antirez
antirez / life.c
Created July 5, 2025 13:38
Game of life as implemented in the YouTube C video lessons
#include <stdio.h>
#include <unistd.h>
#define GRID_COLS 20
#define GRID_ROWS 20
#define GRID_CELLS (GRID_COLS*GRID_ROWS)
#define ALIVE '*'
#define DEAD '.'
/* Translate the specified x,y grid point into the index in
import os
from google import genai
from google.genai import types
client = genai.Client(api_key=os.getenv("GEMINI_API_KEY","xxx"))
# Repalce with the youtube url you want to analyze
youtube_url = "https://www.youtube.com/watch?v=RDOMKIw1aF4"
# Prompt to analyze and summarize the Youtube Video
@karljuhlpep
karljuhlpep / dspy_codegen.py
Last active May 11, 2025 23:17
DSPy Module - CodeGen + Debugging
import subprocess
import dspy
### Note this code is not tested, and likely includes errors that need to be refined.
class IterativeCodeRefinement(dspy.Module):
def __init__(self):
super().__init__()
self.generate_pseudocode = dspy.ChainOfThought("task -> pseudocode")
@seanchatmangpt
seanchatmangpt / model_maker.py
Created February 23, 2024 00:48
Simplest pydantic instance creator.
import ast
import inspect
import dspy
from typing import Type
from pydantic import BaseModel
class User(BaseModel):
name: str
@seanchatmangpt
seanchatmangpt / gen_pydantic_instance.py
Last active May 29, 2025 09:18
Convert your prompt into a pydantic instance.
import ast
import logging
import inspect
from typing import Type, TypeVar
from dspy import Assert, Module, ChainOfThought, Signature, InputField, OutputField
from pydantic import BaseModel, ValidationError
logger = logging.getLogger(__name__)
logger.setLevel(logging.ERROR)
@elitan
elitan / utils.ts
Created November 5, 2023 10:13
Parse Open AI function calls JSON response with JavaScript/TypeScript
function escapeNewLines(str: string) {
return str.replace(/\n/g, '\\n');
}
function fixOpenAiNewLineResponse(str: string) {
return str
.split('"')
.map((chunk, index) => {
// Only replace \n inside the JSON string values, which are in every other index after splitting by "
if (index % 2 === 1) {
@342b45
342b45 / magic_link.ts
Last active June 26, 2023 06:46
Magic Link Implementation using lucia auth
@pmuens
pmuens / DB.test.ts
Created February 21, 2022 19:24
SQLite as a Graph Database
import DB from './DB'
describe('DB', () => {
let db: DB
const data = { name: 'Tom Cook', type: ['person', 'CEO'] }
beforeEach(() => {
db = new DB()
db.addNode('1', { name: 'Apple Computer Company', type: ['company', 'start-up'], founded: 'April 1, 1976' })
@dsebastien
dsebastien / svelte.config.cjs
Last active December 25, 2022 03:55
Svelte config that loads the postcss config
const sveltePreprocess = require('svelte-preprocess');
module.exports = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: sveltePreprocess({
// WARNING: Mandatory for the postcss config (postcss.config.js) and Tailwind to be loaded
postcss: {}, // <------ this is the important part :)
}), // can pass the options here using { }, but we use svelte.preprocess.config.js for that (gives us more context)
};