Skip to content

Instantly share code, notes, and snippets.

View sebitcode's full-sized avatar
😎

Sebastian Herrera sebitcode

😎
View GitHub Profile
@sebitcode
sebitcode / update.sh
Created July 3, 2025 04:54
script to update ubuntu deps
apt update
apt full-upgrade -y
apt autoremove -y
apt clean
journalctl --vacuum-time=3d
rm -rf /var/log/apt/*
@sebitcode
sebitcode / setup-docker.sh
Last active July 3, 2025 04:53
bash script to install docker in linux
# Add Docker's official GPG key
apt-get update
apt-get install ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
@sebitcode
sebitcode / setImage.html
Last active May 16, 2025 04:38
A way to preview image before send form to API
<script>
function setImage(input) {
const image = document.querySelector(".profile-img")
const reader = new FileReader();
reader.onload = (e) => image.src = e.target.result
reader.readAsDataURL(input.files[0]); // Read file as data URL
}
</script>
@sebitcode
sebitcode / mediaQuery.jsx
Last active May 10, 2025 14:59
How to create a media query 100% react
import { useState, useEffect } from 'react';
export function useMediaQuery(query, defaultState = false) {
const [matches, setMatches] = useState(() => {
if (typeof window !== 'undefined') {
return window.matchMedia(query).matches;
}
return defaultState; // SSR safe default
});
@sebitcode
sebitcode / countrytz.py
Last active April 3, 2025 07:24
How to obtain all possible tz with dt of any country
from datetime import datetime
from pytz import country_timezones, timezone, country_names
from pytz.tzinfo import BaseTzInfo
from functools import cached_property
class Country:
def __init__(self, country_code: str):
self.country_code = country_code
@cached_property