Skip to content

Instantly share code, notes, and snippets.

View sturmenta's full-sized avatar
🌌

Nicolas Sturm sturmenta

🌌
  • Argentina
View GitHub Profile
@sturmenta
sturmenta / script.sh
Last active March 19, 2025 11:32
driver printer hp laserjet p1005 mac
curl -o ~/Downloads/hpdrivers.dmg https://updates.cdn-apple.com/2020/macos/001-41745-20201210-DBC9B46B-88B2-4032-87D9-449AF1D20804/HewlettPackardPrinterDrivers.dmg
hdiutil attach ~/Downloads/hpdrivers.dmg
pkgutil --expand /Volumes/HP_PrinterSupportManual/HewlettPackardPrinterDrivers.pkg ~/Downloads/hp-expand
hdiutil eject /Volumes/HP_PrinterSupportManual
sed -i '' 's/12.0/16.0/' ~/Downloads/hp-expand/Distribution
@sturmenta
sturmenta / StarsRating.tsx
Last active February 13, 2025 20:25
Render stars for calification (convert number into amount of stars of each type)
const convertAverageRatingIntoStarsStatusObject = (
averageRating: number
) => {
const parseDecimalToStar = {
1: 0,
2: 0,
3: 0.5,
4: 0.5,
5: 0.5,
6: 0.5,
@sturmenta
sturmenta / image-picker.tsx
Last active January 27, 2025 23:55
simple react image picker
import { ArrowUpFromLine, Pencil, Trash2 } from "lucide-react";
import { ChangeEvent, useEffect, useRef, useState } from "react";
import { useClickOutside } from "@/hooks/use-click-outside";
import { Touchable } from "./touchable";
export const ImagePicker = ({
id = 1, // 2, 3, ...
image,
@sturmenta
sturmenta / useOnlyCallOnce.ts
Created September 30, 2024 17:52
useOnlyCallOnce
import { useEffect, useRef } from 'react';
export const useOnlyCallOnce = (cb, condition = true) => {
const isCalledRef = useRef(false);
useEffect(() => {
if (condition && !isCalledRef.current) {
isCalledRef.current = true;
cb();
}
@sturmenta
sturmenta / readme.md
Created March 28, 2024 10:41
raspberry pico w hello world (without probe) blink example

using embassy

  1. git clone https://github.com/embassy-rs/embassy.git & cd embassy/examples/rp
  2. edit the .cargo/config.toml file and replace runner line with this: runner = "elf2uf2-rs -d"
  3. cargo run --bin wifi_blinky --release
@sturmenta
sturmenta / useWindowSize.ts
Created March 10, 2024 22:58
window addEventListener resize
import { useEffect, useState } from "react"
export const useWindowSize = () => {
const [size, setSize] = useState({ vh: 0, vw: 0 })
const onResize = (props: any) =>
setSize({
vh: props.target.innerHeight,
vw: props.target.innerWidth
})
@sturmenta
sturmenta / global.css
Created March 10, 2024 05:39
show / hide scroll - css
/* Hide scrollbar with class .hide-scroll */
/* for Chrome, Safari and Opera */
.hide-scroll::-webkit-scrollbar {
display: none;
/* Hide scrollbar for IE, Edge and Firefox */
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
/* Always show scrollbar with class .always-show-scroll */
@sturmenta
sturmenta / RemainingTime.tsx
Created February 10, 2024 23:07
show remaining time in react (59:59 - 00:00) with dayjs
import dayjs from "dayjs"
import { useEffect, useState } from "react"
import { Text } from "react-native"
// NOTE:
// show max 59:59 time remaining
// show 00:00 when time is expired
export const RemainingTime = ({ expired_time }: { expired_time: string }) => {
const [time, setTime] = useState("00:00")
@sturmenta
sturmenta / supabase-edge-functions--starter.md
Last active December 31, 2023 17:14
supabase edge functions - starter

supabase edge functions - starter

  • this need a workspace to work because supabase-edge-functions run on deno and the linter and config is different for typescript and deno
  1. move existing files to a folder (website, frontend, etc)
  2. create a new workspace file to vscode config called name-of-your-project.code-workspace and inside put this:
{
 "folders": [
@sturmenta
sturmenta / dashboard-example.tsx
Last active October 14, 2024 20:30
Sidebar for mobile and desktop using shadcn-ui
"use client"
import { WithSidebar } from "@/components/with-sidebar"
export const Dashboard = () => {
return (
<WithSidebar
sidebarContent={SidebarContent}
mobileDashboardHeader={CustomHeader}>
<div className="p-10">