Skip to content

Instantly share code, notes, and snippets.

View sturmenta's full-sized avatar
🌌

Nicolas Sturm sturmenta

🌌
  • Argentina
  • 01:46 (UTC -03:00)
View GitHub Profile
@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 / snippets.json
Last active March 25, 2024 13:22
VSCode snippets
{
// TODO: remember: save changes of this on https://gist.github.com/sturmenta/eb93a8e1367d445b2bb81f5263db05f7
//
// ─── rust ─────────────────────────────────────────────────────────────────────────────
//
"println": {
"prefix": "prt",
"body": [
"println!(\"$1 = {:#?}\", $1);"
],
@sturmenta
sturmenta / dashboard-example.tsx
Last active March 18, 2024 09:29
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">
@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 / useGetDivDimensions.ts
Last active March 3, 2024 05:13
get dimensions of div with ResizeObserver and hooks
import { useEffect, useRef, useState } from "react";
export const useGetDivDimensions = () => {
const [dimensions, setDimensions] = useState({ height: 0, width: 0 });
const div_ref = useRef<HTMLDivElement | null>(null);
useEffect(() => {
const resizeObserver = new ResizeObserver((event) => {
setDimensions({
@sturmenta
sturmenta / GetContainerDimensions.js
Last active February 22, 2024 19:49
react get div dimensions - using react hooks
import { useState, useEffect } from 'react';
const useContainerDimensions = containerRef => {
const getDimensions = () => ({
width: containerRef.offsetWidth,
height: containerRef.offsetHeight
});
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
@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 / readme.md
Last active January 11, 2024 10:27
use "react-native-vector-icons" in "create-react-app" with "react-app-rewired"

guide of how to use react-native-vector-icons on web with webpack and react-app-rewired

  1. yarn add react-native-vector-icons react-native-web
  2. yarn add react-app-rewired -D
  3. update package.json scripts (before react-scripts start/build/test)
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom",
@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": [