Skip to content

Instantly share code, notes, and snippets.

View fanckush's full-sized avatar

Imad abdulkarim fanckush

View GitHub Profile
@ikupenov
ikupenov / base.ts
Created November 10, 2024 09:58
Drizzle RLS DB with Policies
// schema/entities/base.ts
export const getBaseEntityProps = () => ({
id: uuid("id")
.default(sql`gen_random_uuid()`)
.primaryKey(),
createdAt: timestamp("created_at", { precision: 3 }).notNull().defaultNow(),
});
export const getOwnedBaseEntityProps = () => ({
@ikupenov
ikupenov / db-client.ts
Created February 29, 2024 18:40
Intercepting Drizzle db calls
import { and, type DBQueryConfig, eq, type SQLWrapper } from "drizzle-orm";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres, { type Sql } from "postgres";
import { type AnyArgs } from "@/common";
import {
type DbClient,
type DbTable,
type DeleteArgs,
@betafcc
betafcc / Permutation.d.ts
Last active October 29, 2024 15:39
Typescript Union Permutation, count of keys in an object, count of cases in an Union
/**
* @example
* type P = Permutation<1 | 2 | 3>
* // [1, 2, 3] | [1, 3, 2] | [2, 1, 3] | [2, 3, 1] | [3, 1, 2] | [3, 2, 1]
*/
export type Permutation<U, T = U> = [U] extends [never]
? []
: T extends unknown
? [T, ...Permutation<Exclude<U, T>>]
: never
@jeasonstudio
jeasonstudio / bilibili.sh
Last active July 29, 2023 19:32
Use FFmpeg rtmp streaming in macOS
#! /bin/bash
#
# Diffusion bilibili live avec ffmpeg
# Make sure you have FFmpeg installed in your mac
# list avfoundation devices
ffmpeg -f avfoundation -list_devices true -i ""
# change the param after `-i` and `-f flv`
@erikfriberg
erikfriberg / _nicetype.scss
Last active September 4, 2024 15:46
SASS boiler plate for good typography. Works best in combination with normalize.css
// Sets the default text formatting & responsive sizes //----------------
$font-size-base: 1rem;
$font-size-sm: .875rem;
$font-size-h1: 2.25rem;
$font-size-h2: 2rem;
$font-size-h3: $font-size-base;
$font-size-ingress: 1.5rem;
@staltz
staltz / introrx.md
Last active April 24, 2025 06:10
The introduction to Reactive Programming you've been missing
@t-io
t-io / osx_install.sh
Last active January 17, 2025 09:54
Install most of my Apps with homebrew & cask
#!/bin/sh
echo Install all AppStore Apps at first!
# no solution to automate AppStore installs
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo Install and Set San Francisco as System Font
ruby -e "$(curl -fsSL https://raw.github.com/wellsriley/YosemiteSanFranciscoFont/master/install)"
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@douglasmiranda
douglasmiranda / gist:5408278
Created April 17, 2013 22:26
Leading zeros in django templates
{{ variable|stringformat:"02d" }}