Skip to content

Instantly share code, notes, and snippets.

View saiashirwad's full-sized avatar
🏠
Working from home

texoport saiashirwad

🏠
Working from home
View GitHub Profile
export function optimisticallyUpdateArray<Data>(
condition: (data: Data) => boolean,
replacement: Data | ((data: Data) => Data),
) {
return (data: Data[] | undefined) => {
if (!data) return data
const index = data.findIndex(condition)
if (index === -1) return data
const newData = [...data]
newData.splice(
Plug 'kana/vim-textobj-entire'
set easymotion
set surround
set clipboard+=unnamed
set ideajoin
set multiple-cursors
set visualbell
let mapleader = " "
const createFormSchema = (
items: FormItem[],
): z.ZodObject<Record<string, never>> => {
const entries = items.map((formItem) => {
let schema = match<FormItem, z.ZodType>(formItem)
.with({ type: "DATE" }, () => z.date())
.with({ type: "NUMBER", data: { type: "NUMBER" } }, (item) => {
let schema = z.number();
if (item.data.min) {
schema = schema.min(item.data.min);
const threads = await ctx.db
.selectFrom("email")
.innerJoin("emailContact", "emailContact.emailId", "email.id")
.select([sql`max(timestamp)`.as("timestamp"), "threadId"])
.select(["emailContact.contactEmailId"])
.select((eb) =>
jsonObjectFrom(
eb
.selectFrom("email as e")
.select(allColumns(Columns.Email, "e"))
exec --no-startup-id /usr/bin/gnome-keyring-daemon --start --components=ssh,secrets,pkcs11
exec --no-startup-id remaps
set $super Mod4
floating_modifier $super
for_window [class="^.*"] border pixel 1
font pango:Fira Mono 14
@saiashirwad
saiashirwad / redis.conf
Created June 10, 2023 18:55
redis conf
bind 0.0.0.0 ::1
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
supervised no
pidfile /var/run/redis/redis-server.pid
loglevel notice
logfile /var/log/redis/redis-server.log
import {
Queue,
Worker,
type ConnectionOptions,
type Job,
type QueueOptions,
type RedisConnection,
type WorkerOptions,
} from "bullmq";
import { partial } from "ramda";
@saiashirwad
saiashirwad / create-cache.ts
Created May 25, 2023 11:10
super basic cache setup
import { type Duration } from "date-fns";
// RedisClientType is super chonky and I can't be bothered to lug that around everywhere
export type RedisClient = {
get: (key: string) => Promise<string | null>;
set: (key: string, value: string) => Promise<void>;
mSet: (records: Record<string, string>) => Promise<void>;
del: (key: string) => Promise<void>;
mGet: (keys: string[]) => Promise<string[]>;
Plug 'kana/vim-textobj-entire'
set surround
set clipboard+=unnamed
set ideajoin
set multiple-cursors
set visualbell
set sneak
let mapleader = " "
[
{
"command": "-workbench.action.gotoLine",
"key": "ctrl+g"
},
{
"command": "-extension.vim_ctrl+g",
"key": "ctrl+g",
"when": "editorTextFocus && vim.active && vim.use<C-g> && !inDebugRepl"
},