Skip to content

Instantly share code, notes, and snippets.

View danybeltran's full-sized avatar

Dany Beltran danybeltran

View GitHub Profile
@danybeltran
danybeltran / data.csv
Last active October 1, 2021 16:16
data for graphics
Orders 10 30-01-2021
Persons 20 30-01-2021
@danybeltran
danybeltran / atomic-state.min.js
Last active June 27, 2022 07:25
Minified Atomic State for production apps
/** @license Atomic State
* Copyright (c) Dany Beltran
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/ /**
* An observable class that uses the observer pattern
*/ class Observervable{constructor(){this.suscribers={}}async addSubscriber(a,b){a in this.suscribers||(this.suscribers[a]={});let c=Object.keys(this.suscribers[a]).length+1;"__proto__"!==a&&"prototype"!==a?this.suscribers[a][c]=b:console.warn('"prototype" and "__proto__" are not valid message names')}async removeSubscriber(a,c){for(let b in this.suscribers[a])this.suscribers[a][b]===c&&delete this.suscribers[a][b]}async update(a,b){for(let c in this.suscribers[a])await this.suscribers[a][c](b)}}function createObserver(){let a=new Observervable;return{observer:a,notify:function(b,c,d){a.update(b,{storeName:b,hookCall:c,payload:d})}}}const{createContext:a,useCallback:b,useContext:c,useEffect:d,useMemo:e,useRef:f,useState:g}=React,atomObservables={},defaultAtomsValue
@danybeltran
danybeltran / gist:4d8661bc67635406e67ccb06c0878695
Last active February 1, 2022 17:42
Observer pattern in javascript
const { randomUUID } = require("crypto")
/**
* Create an observable value
*/
class Observable {
observableValue
subscribers = {}
/**
@danybeltran
danybeltran / [email protected]
Last active May 4, 2022 16:57
atomic-state for browsers
"use strict"
/** @license Atomic State
* Copyright (c) Dany Beltran
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReflectOwnKeys,
R = "object" == typeof Reflect ? Reflect : null,
@danybeltran
danybeltran / [email protected]
Last active May 4, 2022 16:54
Http React Fetcher for browsers
"use strict"
/**
* @license http-react-fetcher
* Copyright (c) Dany Beltran
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var __assign =
(this && this.__assign) ||
@danybeltran
danybeltran / observer.ts
Last active June 22, 2022 15:19
observer
/**
* An observable class that uses the observer pattern
*/
class Observervable {
private suscribers: any
constructor() {
this.suscribers = {}
}
async addSubscriber(messageName: string, subscriber: any) {
if (!(messageName in this.suscribers)) {
@danybeltran
danybeltran / factorial.js
Last active November 20, 2022 18:12
Obtener el factorial de un número recursivamente
function factorial(numero) {
let multiplicador1 = numero
// Un número abajo
let multiplicador2 = numero - 1
// Aquí se va sumando el resultado de cada vuelta
let resultado = 0
// Si el número es 1, sólo retornamos 1
@danybeltran
danybeltran / index.tsx
Last active April 14, 2023 02:09
http-react is a data manager
import useFetch from 'http-react'
// The store. Because no url is passed, no request is sent
function useCount() {
const { data, mutate } = useFetch({
id: 'count',
default: 0
})
return [
@danybeltran
danybeltran / f-general.py
Created September 23, 2023 00:26
formula general
import math
def cuadratica(a, b, c):
parte2 = math.sqrt(b**2 - 4 * a * c)
resultado1 = -b + parte2
resultado2 = -b - parte2
\documentclass{article}
\usepackage{amsmath}
\usepackage{parskip}
\title{Boletin 1 - Termodinámica}
\author{Daniel Beltran Argueta}
\date{18 de diciembre de 2023}
\begin{document}