Skip to content

Instantly share code, notes, and snippets.

View azlekov's full-sized avatar

Asen Lekov azlekov

View GitHub Profile
@j4w8n
j4w8n / implement-user-api-keys-with-supabase.md
Last active August 22, 2024 19:09
Implement user API keys with Supabase

Implement user API keys with Supabase

This is pretty much my first crack at this. I'm sure things could be improved or done differently.

Rationale

JWTs are at the heart of Supabase authorization, but sometimes we wanna build an app that also gives users access via API keys; or perhaps only exclusively via API keys. As you may know, using JWTs as API keys makes them difficult to revoke and therefore a security issue.

We also want to ensure this doesn't significantly add to RLS polices, if at all.

Finally, we'd love to have this handled by Supabase and do as little as possible in our framework. This simplifies our code and reduces third-party libraries.

@JohnDinhDev
JohnDinhDev / Reset Udemy Progress.md
Last active September 7, 2024 17:34
Reset Udemy Progress

Reset Udemy Progress

Last Updated: 06/18/2024

Step 1. Go to the Udemy course in your browser

Go to the course and have any video up. The following code relies on the right sidebar to be visible to uncheck all your progress.

Step 2. Open browser console

You can do this with ctrl+shift+j and making sure the console tab is selected for chrome/brave

@karigrooms
karigrooms / swiftui-resize-image-and-maintain-aspect-ratio.swift
Last active April 6, 2023 11:54
ViewModifier for resizing images in SwiftUI. Resize an image to any size (square, circle, rectangle) while maintaining its aspect ratio.
import SwiftUI
/// Common aspect ratios
public enum AspectRatio: CGFloat {
case square = 1
case threeToFour = 0.75
case fourToThree = 1.75
}
/// Fit an image to a certain aspect ratio while maintaining its aspect ratio
@Moumouls
Moumouls / buildSchema.ts
Last active May 14, 2021 11:02
DREPECATED: Static Schema for Parse Server (TS/JS) (tested, and production ready)
// DEPRECATED: If Defined Schema PR not already merged on parse-server repo, feel free to use my forked build
// add "parse-server": "moumouls/parse-server#beta.26" in your package.json
// Linked comment: https://gist.github.com/Moumouls/e4f0c6470398efc7a6a74567982185fa#gistcomment-3742504
// This function update, migrate and create Classes
export const buildSchemas = async (localSchemas: any[]) => {
try {
const timeout = setTimeout(() => {
if (process.env.NODE_ENV === 'production') process.exit(1)
}, 20000)
import kotlinx.cinterop.memScoped
import kotlinx.cinterop.allocArrayOf
import kotlinx.cinterop.addressOf
import kotlinx.cinterop.usePinned
import platform.Foundation.NSData
import platform.Foundation.create
import platform.posix.memcpy
public fun ByteArray.toData(): NSData = memScoped {
NSData.create(bytes = allocArrayOf(this@toData),
@mimukit
mimukit / fish_shell_abbreviations.md
Last active August 24, 2022 20:34
Fish shell abbreviations for mac

abbr -a -U -- abbra 'abbr --add'

abbr -a -U -- addfishpath 'set --universal --append fish_user_paths'

abbr -a -U -- brewup 'brew update && brew upgrade && brew cleanup'

abbr -a -U -- c clear

abbr -a -U -- ct 'cloudflared tunnel'

@vganin
vganin / ComposeNumberPicker.kt
Last active January 14, 2024 11:53
Jetpack Compose simple number picker
@Composable
fun NumberPicker(
state: MutableState<Int>,
modifier: Modifier = Modifier,
range: IntRange? = null,
textStyle: TextStyle = LocalTextStyle.current,
onStateChanged: (Int) -> Unit = {},
) {
val coroutineScope = rememberCoroutineScope()
val numbersColumnHeight = 36.dp
unsigned char dscrc_table[] =
{
0x00, 0x5E, 0xBC, 0xE2, 0x61, 0x3F, 0xDD, 0x83, 0xC2, 0x9C,
0x7E, 0x20, 0xA3, 0xFD, 0x1F, 0x41, 0x9D, 0xC3, 0x21, 0x7F,
0xFC, 0xA2, 0x40, 0x1E, 0x5F, 0x01, 0xE3, 0xBD, 0x3E, 0x60,
0x82, 0xDC, 0x23, 0x07, 0x9F, 0xC1, 0x42, 0x1C, 0xFE, 0xA0,
0xE1, 0xBF, 0x5D, 0x03, 0x80, 0xDE, 0x3C, 0x62, 0xBE, 0xE0,
0x02, 0x5C, 0xDF, 0x81, 0x63, 0x3D, 0x7C, 0x22, 0xC0, 0x9E,
0x1D, 0x43, 0xA1, 0xFF, 0x46, 0x18, 0xFA, 0xA4, 0x27, 0x79,
0x9B, 0xC5, 0x84, 0xDA, 0x38, 0x66, 0xE5, 0xBB, 0x59, 0x07,
@mecid
mecid / Calendar.swift
Last active August 23, 2024 16:39
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@diachedelic
diachedelic / deep-link-from-browser.js
Last active September 19, 2024 10:32
Deep link to a native app from a browser, with a fallback