Skip to content

Instantly share code, notes, and snippets.

View pochito427's full-sized avatar
💡
Working

Alfonso Neil Jimenez Casallas pochito427

💡
Working
View GitHub Profile
@pochito427
pochito427 / Hanoi.js
Created April 23, 2023 17:45
Hanoi Towers with Stacks
class Disk {
constructor(value) {
this.value = value;
this.next = null;
}
}
class Peg {
constructor() {
this.top = null;
@pochito427
pochito427 / CarBuilder.js
Last active June 4, 2023 19:09
Builder pattern
export class CarBuilder {
// Tu código aquí 👇
constructor() {
this.year = 0;
this.model = '';
this.brand = '';
this.color = '';
this.price = 0;
this.isAvailable = false;
}
@pochito427
pochito427 / Chat.js
Created April 12, 2023 02:01
Singleton Chat
import { User } from "./user";
export class Chat {
constructor() {
if (!Chat.instance) {
this.users = [];
Chat.instance = Object.freeze(this);
}
return Chat.instance;
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
@nicobytes
nicobytes / example.js
Created March 23, 2022 23:09
example
(()=> {
const myCart = [];
const products = [];
const limit = 2;
async function getProducts() {
const rta = await fetch('http://api.escuelajs.co/api/v1/products', {
mehtod: 'GET'
});
const data = await rta.parseJson();
@y56
y56 / git stash clear
Created July 16, 2020 08:52
git stash clear -- How can I delete all of my Git stashes at once?
How can I delete all of my Git stashes at once?
https://stackoverflow.com/questions/11369375/how-can-i-delete-all-of-my-git-stashes-at-once
Stack Overflow
Products
Customers
Use cases
@Klerith
Klerith / Instalaciones-React.md
Last active May 11, 2024 22:25
Instalaciones recomendadas para mi curso de React de cero a experto
@cassidoo
cassidoo / useMedia.jsx
Last active October 27, 2022 16:13
An example of checking on a media query with React Hooks
function useMedia(query) {
const [matches, setMatches] = useState(window.matchMedia(query).matches)
useEffect(() => {
const media = window.matchMedia(query)
if (media.matches !== matches) {
setMatches(media.matches)
}
const listener = () => {
setMatches(media.matches)
@pochito427
pochito427 / web_scraping_counting_tags.py
Created February 20, 2020 03:12
Python script for scraping HTML contents and counting tags from an URL source with Beautiful Soup 4 library
# To run this, you can install BeautifulSoup
# https://pypi.python.org/pypi/beautifulsoup4
# Or download the file
# http://www.py4e.com/code3/bs4.zip
# and unzip it in the same directory as this file
import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import ssl
@danesparza
danesparza / gist:1093992
Created July 19, 2011 23:21
Javascript date range overlap
var e1start = e1.start.getTime();
var e1end = e1.end.getTime();
var e2start = e2.start.getTime();
var e2end = e2.end.getTime();
return (e1start > e2start && e1start < e2end || e2start > e1start && e2start < e1end);