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
local utils = require("gist.core.utils")
local M = {}
-- @param filename string UNSUPPOTED
-- @param content string|nil UNSUPPOTED
-- @param description string UNSUPPOTED
-- @param private boolean UNSUPPOTED
function M.create(_, content, _, _)
local config = require("gist").config.platforms.termbin
-- Set buffer to be readonly
vim.api.nvim_buf_set_option(buf, "readonly", true)
vim.api.nvim_buf_set_option(buf, "modifiable", false)
vim.api.nvim_buf_set_name(
buf,
string.format("gist://%s/%s", gist.hash, gist.name)
)
-- Set winbar
local winbar = string.format("%%=GIST `%s` [READ-ONLY]", gist.name)
#!/usr/bin/env bash
## Usage
# better_cat <file>
# better_cat package.json -r '[.name, .version] | join("@")'
# better_cat README.md
if [ -z "$1" ]; then
echo "Usage: better_cat <file>"
exit 1
WITH
query_embedding AS (
SELECT ai.openai_embed(
'text-embedding-3-small',
${query},
${OPENAI_API_KEY}
) AS embedding
),
scored AS (
SELECT
#!/bin/bash
# List uncommitted changes and
# check if the output is not empty
if [ -n "$(git status --porcelain)" ]; then
# Print error message
printf "\nError: repo has uncommitted changes\n\n"
# Exit with error code
exit 1
fi
#! /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;