Skip to content

Instantly share code, notes, and snippets.

View ger86's full-sized avatar
🏠
Working from home

Gerardo FernΓ‘ndez Moreno ger86

🏠
Working from home
View GitHub Profile
#!/usr/bin/env python3
from dotenv import load_dotenv
from langchain.chains import RetrievalQA
from langchain.embeddings import HuggingFaceEmbeddings
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.vectorstores import Chroma
from langchain.llms import GPT4All, LlamaCpp
import os
import argparse
@ger86
ger86 / EventDistpacher.ts
Created February 9, 2023 10:09
Fully typed Event Dispatcher for TypeScript
type SquareEvent = { type: "square", x: number, y: number };
type CircleEvent = { type: "circle", radius: number };
type EventType = SquareEvent | CircleEvent;
type Events = {
square: SquareEvent;
circle: CircleEvent;
}
type ListenersMap = {
@ger86
ger86 / eslint-plugin-import.config.js
Last active February 14, 2021 10:31
eslint-plugin-import.config.js
{
"import/order": ['warn', {
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling'],
'alphabetize': {
order: 'asc'
},
"pathGroups": [
{
"pattern": "react",
"group": "builtin",
/************************************************************
*
* πŸ’ͺ🏼πŸ’ͺ🏼πŸ’ͺ🏼 Javascript Proxy πŸ’ͺ🏼πŸ’ͺ🏼πŸ’ͺ🏼
*
************************************************************/
// 1️⃣ Performing an action when accesing a property
const person = { name: "Gerardo", email: "[email protected]" };
const personProxy = new Proxy(person, {
/********************************************************************************
*
* πŸ—ΊοΈπŸ—ΊοΈπŸ—ΊοΈ Map πŸ—ΊοΈπŸ—ΊοΈπŸ—ΊοΈ
* Performs better in scenarios involving frequent additions and
* removals of key-value pairs.
*
********************************************************************************/
// 1️⃣ Main methods
/****************************************************************
*
* 🍰🍰🍰 Array slice 🍰🍰🍰
*
****************************************************************/
const animals = ['🐢', '🐱', '🐭', '🐻', '🦁'];
// Remove first element
console.log(animals.slice(1));
/****************************************************************
*
* πŸ€ΉπŸ»β€β™‚οΈπŸ€ΉπŸ»β€β™‚οΈπŸ€ΉπŸ»β€β™‚οΈ Object & Entries πŸ€ΉπŸ»β€β™‚οΈπŸ€ΉπŸ»β€β™‚οΈπŸ€ΉπŸ»β€β™‚οΈ
*
****************************************************************/
/**
* 1️⃣ Object.entries
*/
/**************************************************************************
*
* πŸ–πŸ‚πŸ„πŸ“ George Orwell explaining Javascript Prototype πŸ–πŸ‚πŸ„πŸ“
*
**************************************************************************/
function Animal(name, type) {
this.name = name;
this.type = type;
}
/************************************************
*
* πŸ“©πŸ“©πŸ“© window.postMessage() πŸ“©πŸ“©πŸ“©
*
* The window.postMessage() method safely enables cross-origin communication
* between Window objects; e.g., between a page and a pop-up that it spawned,
* or between a page and an iframe embedded within it.
*
************************************************/
@ger86
ger86 / variable-hoisting.js
Created February 5, 2020 11:07
Variable hoisting in Javascript
/******************************************************************************************************
*
* πŸ†™πŸ†™πŸ†™πŸ†™ Variable hoisting πŸ†™πŸ†™πŸ†™πŸ†™
*
* CaracterΓ­stica del lenguaje que de forma automΓ‘tica la declaraciΓ³n de las variables
* a la parte superior del bloque funcional / global
*
*******************************************************************************************************/
console.log(user); // "undefined" pero no da error