Skip to content

Instantly share code, notes, and snippets.

View rawnly's full-sized avatar
🧨
fixing my printer

Federico rawnly

🧨
fixing my printer
View GitHub Profile
#! /bin/bash
# date (YYYY-MM-DD HH:MM:SS),percentage
datetime="$(date +%Y-%m-%d\ %H:%M:%S)"
memory_usage="$(ps -A -o %mem | awk '{ mem += $1 } END { print mem }')"
uptime="$(uptime | awk '{ print $3 }' | cut -d, -f1)"
# number only
battery_percentage="$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)"

Usage

type Payload = { username: string; password: string }
import { useForm, FormProvider } from 'react-hook-form'


function Form() {
  const methods = useForm<Payload>({
    mode: 'all',
 });
// Given this type
type ResultSuccess<T> = {
data: T
success: true
}
type ResultFailure<E> = {
error: E
success: false
}
"use client"
import { useMemo, useState } from "react"
import clsx from "clsx"
import { motion } from "framer-motion"
const OFFSET = 10
function SingleMagicNumber({
value,
@rawnly
rawnly / Table.tsx
Last active February 7, 2023 16:24
import { ArrowNarrowDownIcon, ArrowNarrowUpIcon } from '@smartfish/icons';
import { Column, flexRender, type Row, type Table } from '@tanstack/react-table';
import clsx from 'clsx';
import { useMemo } from 'react';
import { forwardRef } from 'react';
interface ICondensedTableProps<T> {
table: Table<T>;
onRowClick?: (row: Row<T>) => void;
stickyHeader?: boolean;
- data: VecDeque<T>
+ data: Mutex<VecDeque<T>>
+ cv: CondVar
@rawnly
rawnly / google-centered-hack.css
Created November 24, 2022 16:26
Simple Arc easel to center google search on high res screens
form.tsf:first-of-type {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
#center_col {
max-width: 1240px;
width: 100%;
import { useCalendar } from '@h6s/calendar';
import { useMachine } from '@xstate/react';
import { Button as AriaButton } from 'ariakit/button';
import clsx from 'clsx';
import { isSunday, isSameDay, addMonths, isFuture, isPast, setDate } from 'date-fns';
import format from 'date-fns/format';
import isWithinInterval from 'date-fns/isWithinInterval';
import { FC, useCallback, useMemo } from 'react';
import Select from '@components/forms/components/Select';
type IO<T, Input = never> = Input extends never ? () => T : (input: Input) => T;
export type InputType = 'text' | 'number' | 'password' | 'email' | 'date' | 'time' | 'datetime-local' | 'month' | 'week' | 'url' | 'search' | 'tel' | 'color';
export type BaseInput<Shape extends object, Metadata = Record<string, any>> = {
placeholder?: string;
required?: string | boolean;
disabled?: string | boolean;
readonly?: string | boolean;
autofocus?: string | boolean;
{
"PolymorphicFunctionComponent": {
"prefix": "fncpp",
"description": "React Function Component (Polymorphic)",
"body": [
"import React from \"react\";",
"",
"interface PolymorphicProps<C extends React.ElementType> {",
"\tas?: C",
"}",